Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2150 mathias 1
<html>
2
	<head>
3
		<title>testing dojo.query()</title>
4
		<style type="text/css">
5
			@import "../../resources/dojo.css";
6
		</style>
7
		<script type="text/javascript" src="../../dojo.js"
8
			djConfig="isDebug: true, debugAtAllCosts: true, noFirebugLite: true"></script>
9
		<script type="text/javascript" src="../../../util/doh/runner.js"></script>
10
		<script type="text/javascript">
11
			dojo.require("doh.runner");
12
			dojo.addOnLoad(function(){
13
				doh.register("t",
14
					[
15
						"doh.is(4, (dojo.query('h3')).length);",
16
						"doh.is(1, (dojo.query('h1:first-child')).length);",
17
						"doh.is(2, (dojo.query('h3:first-child')).length);",
18
						"doh.is(1, (dojo.query('#t')).length);",
19
						"doh.is(1, (dojo.query('#bug')).length);",
20
						"doh.is(4, (dojo.query('#t h3')).length);",
21
						"doh.is(1, (dojo.query('div#t')).length);",
22
						"doh.is(4, (dojo.query('div#t h3')).length);",
23
						"doh.is(0, (dojo.query('span#t')).length);",
24
						"doh.is(1, (dojo.query('#t div > h3')).length);",
25
						"doh.is(2, (dojo.query('.foo')).length);",
26
						"doh.is(1, (dojo.query('.foo.bar')).length);",
27
						"doh.is(2, (dojo.query('.baz')).length);",
28
						"doh.is(3, (dojo.query('#t > h3')).length);",
29
						"doh.is(12, (dojo.query('#t > *')).length);",
30
						"doh.is(12, (dojo.query('#t >')).length);",
31
						"doh.is(3, (dojo.query('.foo >')).length);",
32
						"doh.is(3, (dojo.query('.foo > *')).length);",
33
						"doh.is(3, (dojo.query('> *', 'container')).length);",
34
						"doh.is(3, (dojo.query('> h3', 't')).length);",
35
						"doh.is(2, (dojo.query('.foo, .bar')).length);",
36
						"doh.is(2, (dojo.query('.foo,.bar')).length);",
37
						"doh.is(1, (dojo.query('.foo.bar')).length);",
38
						"doh.is(2, (dojo.query('.foo')).length);",
39
						"doh.is(2, (dojo.query('.baz')).length);",
40
						"doh.is(1, (dojo.query('span.baz')).length);",
41
						"doh.is(1, (dojo.query('sPaN.baz')).length);",
42
						"doh.is(1, (dojo.query('SPAN.baz')).length);",
43
						// FIXME: need to support [foo="foo bar"]. We're incorrectly tokenizing!
44
						"doh.is(2, (dojo.query('[foo~=\"bar\"]')).length);",
45
						"doh.is(2, (dojo.query('[ foo ~= \"bar\" ]')).length);",
46
						// "t.is(0, (dojo.query('[ foo ~= \"\\'bar\\'\" ]')).length);",
47
						"doh.is(3, (dojo.query('[foo]')).length);",
48
						"doh.is(1, (dojo.query('[foo$=\"thud\"]')).length);",
49
						"doh.is(1, (dojo.query('[foo$=thud]')).length);",
50
						"doh.is(1, (dojo.query('[foo$=\"thudish\"]')).length);",
51
						"doh.is(1, (dojo.query('#t [foo$=thud]')).length);",
52
						"doh.is(1, (dojo.query('#t [ title $= thud ]')).length);",
53
						"doh.is(0, (dojo.query('#t span[ title $= thud ]')).length);",
54
						"doh.is(1, (dojo.query('[foo|=\"bar\"]')).length);",
55
						"doh.is(1, (dojo.query('[foo|=\"bar-baz\"]')).length);",
56
						"doh.is(0, (dojo.query('[foo|=\"baz\"]')).length);",
57
						"doh.is(dojo.byId('_foo'), dojo.query('.foo:nth-child(2)')[0]);",
58
						"doh.is(dojo.query('style')[0], dojo.query(':nth-child(2)')[0]);",
59
						"doh.is(3, dojo.query('>', 'container').length);",
60
						"doh.is(3, dojo.query('> *', 'container').length);",
61
						"doh.is(2, dojo.query('> [qux]', 'container').length);",
62
						"doh.is('child1', dojo.query('> [qux]', 'container')[0].id);",
63
						"doh.is('child3', dojo.query('> [qux]', 'container')[1].id);",
64
						"doh.is(3, dojo.query('>', 'container').length);",
65
						"doh.is(3, dojo.query('> *', 'container').length);",
66
						"doh.is('passed', dojo.query('#bug')[0].value);",
67
						"doh.is(1, dojo.query('#t span.foo:not(span:first-child)').length);",
68
						"doh.is(1, dojo.query('#t span.foo:not(:first-child)').length);",
69
						"doh.is(2, dojo.query('#t > h3:nth-child(odd)').length);",
70
						"doh.is(3, dojo.query('#t h3:nth-child(odd)').length);",
71
						"doh.is(3, dojo.query('#t h3:nth-child(2n+1)').length);",
72
						"doh.is(1, dojo.query('#t h3:nth-child(even)').length);",
73
						"doh.is(1, dojo.query('#t h3:nth-child(2n)').length);",
74
						"doh.is(0, dojo.query('#t h3:nth-child(2n+3)').length);",
75
						"doh.is(2, dojo.query('#t h3:nth-child(1)').length);",
76
						"doh.is(1, dojo.query('#t > h3:nth-child(1)').length);",
77
						"doh.is(3, dojo.query('#t :nth-child(3)').length);",
78
						"doh.is(0, dojo.query('#t > div:nth-child(1)').length);",
79
						"doh.is(7, dojo.query('#t span').length);",
80
						"doh.is(4, dojo.query('#t > span:empty').length);",
81
						"doh.is(6, dojo.query('#t span:empty').length);",
82
						"doh.is(0, dojo.query('h3 span:empty').length);",
83
						"doh.is(1, dojo.query('h3 :not(:empty)').length);",
84
						function silly_IDs1(){
85
							doh.t(document.getElementById("silly:id::with:colons"));
86
							doh.is(1, dojo.query("#silly\\:id\\:\\:with\\:colons").length);
87
						},
88
						function NodeList_identity(){
89
							var foo = new dojo.NodeList([dojo.byId("container")]);
90
							doh.is(foo, dojo.query(foo));
91
						},
92
						function xml(){
93
							try{
94
								dojo.require("dojox.data.dom");
95
								var doc = dojox.data.dom.createDocument("<ResultSet><Result>One</Result><Result>Two</Result></ResultSet>");
96
								console.debug(doc);
97
								console.debug(doc.documentElement);
98
								console.debug(dojo.query("Result", doc.documentElement));
99
							}catch(e){ console.debug(e); }
100
						}
101
					]
102
				);
103
				doh.run();
104
			});
105
		</script>
106
	</head>
107
	<body>
108
		<h1>testing dojo.query()</h1>
109
		<div id="t">
110
			<h3>h3 <span>span</span> endh3 </h3>
111
			<!-- comment to throw things off -->
112
			<div class="foo bar" id="_foo">
113
				<h3>h3</h3>
114
				<span id="foo"></span>
115
				<span></span>
116
			</div>
117
			<h3>h3</h3>
118
			<h3 class="baz" title="thud">h3</h3>
119
			<span class="foobar baz foo"></span>
120
			<span foo="bar"></span>
121
			<span foo="baz bar thud"></span>
122
			<!-- FIXME: should foo="bar-baz-thud" match? [foo$=thud] ??? -->
123
			<span foo="bar-baz-thudish" id="silly:id::with:colons"></span>
124
			<div id="container">
125
				<div id="child1" qux="true"></div>
126
				<div id="child2"></div>
127
				<div id="child3" qux="true"></div>
128
			</div>
129
			<div qux="true"></div>
130
			<input id="notbug" name="bug" type="hidden" value="failed" />
131
			<input id="bug" type="hidden" value="passed" />
132
		</div>
133
	</body>
134
</html>
135