Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / constants.html
blobf1da2359e7a4fb1499d9fb05fa9bc908dce0bcfb
1 <html>
2 <head>
3 <link rel="stylesheet" href="resources/stylesheet.css">
4 <script>
5 function print(message, color) {
6 var paragraph = document.createElement("div");
7 paragraph.appendChild(document.createTextNode(message));
8 paragraph.style.fontFamily = "monospace";
9 if (color)
10 paragraph.style.color = color;
11 document.getElementById("console").appendChild(paragraph);
14 function shouldBe(a, b)
16 var message, color;
17 var evalA;
18 try {
19 evalA = eval(a);
20 } catch (e) {
21 evalA = e;
24 if (evalA == b) {
25 color = "green";
26 message = "PASS: " + a + " should be " + b + " and is.";
27 } else {
28 color = "red";
29 message = "FAIL: " + a + " should be " + b + " but instead is " + evalA + ".";
32 print(message, color);
35 var cssRule, nodeFilter, event;
37 function test() {
38 if (window.testRunner)
39 testRunner.dumpAsText();
41 cssRule = document.styleSheets[0].cssRules[0];
42 shouldBe("cssRule.STYLE_RULE", 1);
43 shouldBe("cssRule.CHARSET_RULE", 2);
44 shouldBe("cssRule.IMPORT_RULE", 3);
45 shouldBe("cssRule.MEDIA_RULE", 4);
46 shouldBe("cssRule.FONT_FACE_RULE", 5);
47 shouldBe("cssRule.PAGE_RULE", 6);
49 shouldBe("window.CSSRule.STYLE_RULE", 1);
50 shouldBe("window.CSSRule.CHARSET_RULE", 2);
51 shouldBe("window.CSSRule.IMPORT_RULE", 3);
52 shouldBe("window.CSSRule.MEDIA_RULE", 4);
53 shouldBe("window.CSSRule.FONT_FACE_RULE", 5);
54 shouldBe("window.CSSRule.PAGE_RULE", 6);
56 var nodeIterator;
57 try {
58 nodeIterator = document.createNodeIterator(document,
59 NodeFilter.SHOW_ELEMENT,
60 function () { return NodeFilter.FILTER_ACCEPT; },
61 false);
62 } catch(e) {
63 nodeIterator = new Object();
66 nodeFilter = nodeIterator.filter;
67 shouldBe("nodeFilter.FILTER_ACCEPT", 1);
68 shouldBe("nodeFilter.FILTER_REJECT", 2);
69 shouldBe("nodeFilter.FILTER_SKIP", 3);
70 shouldBe("nodeFilter.SHOW_ALL", 4294967295);
71 shouldBe("nodeFilter.SHOW_ELEMENT", 0x00000001);
72 shouldBe("nodeFilter.SHOW_ATTRIBUTE", 0x00000002);
73 shouldBe("nodeFilter.SHOW_TEXT", 0x00000004);
74 shouldBe("nodeFilter.SHOW_CDATA_SECTION", 0x00000008);
75 shouldBe("nodeFilter.SHOW_ENTITY_REFERENCE", 0x00000010);
76 shouldBe("nodeFilter.SHOW_ENTITY", 0x00000020);
77 shouldBe("nodeFilter.SHOW_PROCESSING_INSTRUCTION", 0x00000040);
78 shouldBe("nodeFilter.SHOW_COMMENT", 0x00000080);
79 shouldBe("nodeFilter.SHOW_DOCUMENT", 0x00000100);
80 shouldBe("nodeFilter.SHOW_DOCUMENT_TYPE", 0x00000200);
81 shouldBe("nodeFilter.SHOW_DOCUMENT_FRAGMENT", 0x00000400);
82 shouldBe("nodeFilter.SHOW_NOTATION", 0x00000800);
84 shouldBe("window.NodeFilter.FILTER_ACCEPT", 1);
85 shouldBe("window.NodeFilter.FILTER_REJECT", 2);
86 shouldBe("window.NodeFilter.FILTER_SKIP", 3);
87 shouldBe("window.NodeFilter.SHOW_ALL", 4294967295);
88 shouldBe("window.NodeFilter.SHOW_ELEMENT", 0x00000001);
89 shouldBe("window.NodeFilter.SHOW_ATTRIBUTE", 0x00000002);
90 shouldBe("window.NodeFilter.SHOW_TEXT", 0x00000004);
91 shouldBe("window.NodeFilter.SHOW_CDATA_SECTION", 0x00000008);
92 shouldBe("window.NodeFilter.SHOW_ENTITY_REFERENCE", 0x00000010);
93 shouldBe("window.NodeFilter.SHOW_ENTITY", 0x00000020);
94 shouldBe("window.NodeFilter.SHOW_PROCESSING_INSTRUCTION", 0x00000040);
95 shouldBe("window.NodeFilter.SHOW_COMMENT", 0x00000080);
96 shouldBe("window.NodeFilter.SHOW_DOCUMENT", 0x00000100);
97 shouldBe("window.NodeFilter.SHOW_DOCUMENT_TYPE", 0x00000200);
98 shouldBe("window.NodeFilter.SHOW_DOCUMENT_FRAGMENT", 0x00000400);
99 shouldBe("window.NodeFilter.SHOW_NOTATION", 0x00000800);
101 event = document.createEvent("Event");
102 shouldBe("event.NONE", 0);
103 shouldBe("event.CAPTURING_PHASE", 1);
104 shouldBe("event.AT_TARGET", 2);
105 shouldBe("event.BUBBLING_PHASE", 3);
106 shouldBe("event.MOUSEDOWN", 1);
107 shouldBe("event.MOUSEUP", 2);
108 shouldBe("event.MOUSEOVER", 4);
109 shouldBe("event.MOUSEOUT", 8);
110 shouldBe("event.MOUSEMOVE", 16);
111 shouldBe("event.MOUSEDRAG", 32);
112 shouldBe("event.CLICK", 64);
113 shouldBe("event.DBLCLICK", 128);
114 shouldBe("event.KEYDOWN", 256);
115 shouldBe("event.KEYUP", 512);
116 shouldBe("event.KEYPRESS", 1024);
117 shouldBe("event.DRAGDROP", 2048);
118 shouldBe("event.FOCUS", 4096);
119 shouldBe("event.BLUR", 8192);
120 shouldBe("event.SELECT", 16384);
121 shouldBe("event.CHANGE", 32768);
123 shouldBe("window.Event.NONE", 0);
124 shouldBe("window.Event.CAPTURING_PHASE", 1);
125 shouldBe("window.Event.AT_TARGET", 2);
126 shouldBe("window.Event.BUBBLING_PHASE", 3);
127 shouldBe("window.Event.MOUSEDOWN", 1);
128 shouldBe("window.Event.MOUSEUP", 2);
129 shouldBe("window.Event.MOUSEOVER", 4);
130 shouldBe("window.Event.MOUSEOUT", 8);
131 shouldBe("window.Event.MOUSEMOVE", 16);
132 shouldBe("window.Event.MOUSEDRAG", 32);
133 shouldBe("window.Event.CLICK", 64);
134 shouldBe("window.Event.DBLCLICK", 128);
135 shouldBe("window.Event.KEYDOWN", 256);
136 shouldBe("window.Event.KEYUP", 512);
137 shouldBe("window.Event.KEYPRESS", 1024);
138 shouldBe("window.Event.DRAGDROP", 2048);
139 shouldBe("window.Event.FOCUS", 4096);
140 shouldBe("window.Event.BLUR", 8192);
141 shouldBe("window.Event.SELECT", 16384);
142 shouldBe("window.Event.CHANGE", 32768);
144 </script>
145 </head>
146 <body onload="test();">
147 <p>This page tests CSSRule, NodeFilter, and Event. It tests:</p>
148 <ol>
149 <li>Whether their global constructors have the correct constant values</li>
150 <li>Whether their objects have the correct constant values</li>
151 </ol>
152 <hr>
153 <div id='console'></div>
154 </body>
155 </html>