Use testRunner instead of layoutTestController in fast/doctypes, dom, dynamic, encodi...
[WebKit-https.git] / LayoutTests / fast / dom / constants.html
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);
12 }
13
14 function shouldBe(a, b)
15 {
16     var message, color;
17     var evalA;
18     try {
19         evalA = eval(a);
20     } catch (e) {
21         evalA = e;
22     }
23     
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 + ".";
30     }
31     
32     print(message, color);
33 }
34
35 var cssRule, cssValue, nodeFilter, event;
36
37 function test() {
38     if (window.testRunner)
39         testRunner.dumpAsText();
40         
41     cssRule = document.styleSheets[0].cssRules[0];
42     shouldBe("cssRule.UNKNOWN_RULE", 0);
43     shouldBe("cssRule.STYLE_RULE", 1);
44     shouldBe("cssRule.CHARSET_RULE", 2);
45     shouldBe("cssRule.IMPORT_RULE", 3);
46     shouldBe("cssRule.MEDIA_RULE", 4);
47     shouldBe("cssRule.FONT_FACE_RULE", 5);
48     shouldBe("cssRule.PAGE_RULE", 6);
49
50     shouldBe("window.CSSRule.UNKNOWN_RULE", 0);
51     shouldBe("window.CSSRule.STYLE_RULE", 1);
52     shouldBe("window.CSSRule.CHARSET_RULE", 2);
53     shouldBe("window.CSSRule.IMPORT_RULE", 3);
54     shouldBe("window.CSSRule.MEDIA_RULE", 4);
55     shouldBe("window.CSSRule.FONT_FACE_RULE", 5);
56     shouldBe("window.CSSRule.PAGE_RULE", 6);
57
58     cssValue = cssRule.style.getPropertyCSSValue("color");
59     shouldBe("cssValue.CSS_INHERIT", 0);
60     shouldBe("cssValue.CSS_PRIMITIVE_VALUE", 1);
61     shouldBe("cssValue.CSS_VALUE_LIST", 2);
62     shouldBe("cssValue.CSS_CUSTOM", 3);
63     
64     shouldBe("window.CSSValue.CSS_INHERIT", 0);
65     shouldBe("window.CSSValue.CSS_PRIMITIVE_VALUE", 1);
66     shouldBe("window.CSSValue.CSS_VALUE_LIST", 2);
67     shouldBe("window.CSSValue.CSS_CUSTOM", 3);
68
69     var nodeIterator;
70     try {
71         nodeIterator = document.createNodeIterator(document, 
72                                                    NodeFilter.SHOW_ELEMENT, 
73                                                    function () { return NodeFilter.FILTER_ACCEPT; }, 
74                                                    false);
75     } catch(e) {
76         nodeIterator = new Object();
77     }
78     
79     nodeFilter = nodeIterator.filter;
80     shouldBe("nodeFilter.FILTER_ACCEPT", 1);
81     shouldBe("nodeFilter.FILTER_REJECT", 2);
82     shouldBe("nodeFilter.FILTER_SKIP", 3);
83     shouldBe("nodeFilter.SHOW_ALL", -1);
84     shouldBe("nodeFilter.SHOW_ELEMENT", 0x00000001);
85     shouldBe("nodeFilter.SHOW_ATTRIBUTE", 0x00000002);
86     shouldBe("nodeFilter.SHOW_TEXT", 0x00000004);
87     shouldBe("nodeFilter.SHOW_CDATA_SECTION", 0x00000008);
88     shouldBe("nodeFilter.SHOW_ENTITY_REFERENCE", 0x00000010);
89     shouldBe("nodeFilter.SHOW_ENTITY", 0x00000020);
90     shouldBe("nodeFilter.SHOW_PROCESSING_INSTRUCTION", 0x00000040);
91     shouldBe("nodeFilter.SHOW_COMMENT", 0x00000080);
92     shouldBe("nodeFilter.SHOW_DOCUMENT", 0x00000100);
93     shouldBe("nodeFilter.SHOW_DOCUMENT_TYPE", 0x00000200);
94     shouldBe("nodeFilter.SHOW_DOCUMENT_FRAGMENT", 0x00000400);
95     shouldBe("nodeFilter.SHOW_NOTATION", 0x00000800);
96
97     shouldBe("window.NodeFilter.FILTER_ACCEPT", 1);
98     shouldBe("window.NodeFilter.FILTER_REJECT", 2);
99     shouldBe("window.NodeFilter.FILTER_SKIP", 3);
100     shouldBe("window.NodeFilter.SHOW_ALL", -1);
101     shouldBe("window.NodeFilter.SHOW_ELEMENT", 0x00000001);
102     shouldBe("window.NodeFilter.SHOW_ATTRIBUTE", 0x00000002);
103     shouldBe("window.NodeFilter.SHOW_TEXT", 0x00000004);
104     shouldBe("window.NodeFilter.SHOW_CDATA_SECTION", 0x00000008);
105     shouldBe("window.NodeFilter.SHOW_ENTITY_REFERENCE", 0x00000010);
106     shouldBe("window.NodeFilter.SHOW_ENTITY", 0x00000020);
107     shouldBe("window.NodeFilter.SHOW_PROCESSING_INSTRUCTION", 0x00000040);
108     shouldBe("window.NodeFilter.SHOW_COMMENT", 0x00000080);
109     shouldBe("window.NodeFilter.SHOW_DOCUMENT", 0x00000100);
110     shouldBe("window.NodeFilter.SHOW_DOCUMENT_TYPE", 0x00000200);
111     shouldBe("window.NodeFilter.SHOW_DOCUMENT_FRAGMENT", 0x00000400);
112     shouldBe("window.NodeFilter.SHOW_NOTATION", 0x00000800);
113
114     event = document.createEvent("Event");
115     shouldBe("event.NONE", 0);
116     shouldBe("event.CAPTURING_PHASE", 1);
117     shouldBe("event.AT_TARGET", 2);
118     shouldBe("event.BUBBLING_PHASE", 3);
119     shouldBe("event.MOUSEDOWN", 1);    
120     shouldBe("event.MOUSEUP", 2);    
121     shouldBe("event.MOUSEOVER", 4);    
122     shouldBe("event.MOUSEOUT", 8);    
123     shouldBe("event.MOUSEMOVE", 16);   
124     shouldBe("event.MOUSEDRAG", 32);   
125     shouldBe("event.CLICK", 64);   
126     shouldBe("event.DBLCLICK", 128);  
127     shouldBe("event.KEYDOWN", 256);  
128     shouldBe("event.KEYUP", 512);  
129     shouldBe("event.KEYPRESS", 1024); 
130     shouldBe("event.DRAGDROP", 2048); 
131     shouldBe("event.FOCUS", 4096); 
132     shouldBe("event.BLUR", 8192); 
133     shouldBe("event.SELECT", 16384);
134     shouldBe("event.CHANGE", 32768);
135
136     shouldBe("window.Event.NONE", 0);
137     shouldBe("window.Event.CAPTURING_PHASE", 1);
138     shouldBe("window.Event.AT_TARGET", 2);
139     shouldBe("window.Event.BUBBLING_PHASE", 3);
140     shouldBe("window.Event.MOUSEDOWN", 1);    
141     shouldBe("window.Event.MOUSEUP", 2);    
142     shouldBe("window.Event.MOUSEOVER", 4);    
143     shouldBe("window.Event.MOUSEOUT", 8);    
144     shouldBe("window.Event.MOUSEMOVE", 16);   
145     shouldBe("window.Event.MOUSEDRAG", 32);   
146     shouldBe("window.Event.CLICK", 64);   
147     shouldBe("window.Event.DBLCLICK", 128);  
148     shouldBe("window.Event.KEYDOWN", 256);  
149     shouldBe("window.Event.KEYUP", 512);  
150     shouldBe("window.Event.KEYPRESS", 1024); 
151     shouldBe("window.Event.DRAGDROP", 2048); 
152     shouldBe("window.Event.FOCUS", 4096); 
153     shouldBe("window.Event.BLUR", 8192); 
154     shouldBe("window.Event.SELECT", 16384);
155     shouldBe("window.Event.CHANGE", 32768);
156 }
157 </script>
158 </head>
159 <body onload="test();">
160 <p>This page tests CSSRule, CSSValue, NodeFilter, and Event. It tests:</p>
161 <ol>
162     <li>Whether their global constructors have the correct constant values</li>
163     <li>Whether their objects have the correct constant values</li>
164 </ol>
165 <hr>
166 <div id='console'></div>
167 </body>
168 </html>