Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / 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, 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     var nodeIterator;
59     try {
60         nodeIterator = document.createNodeIterator(document, 
61                                                    NodeFilter.SHOW_ELEMENT, 
62                                                    function () { return NodeFilter.FILTER_ACCEPT; }, 
63                                                    false);
64     } catch(e) {
65         nodeIterator = new Object();
66     }
67     
68     nodeFilter = nodeIterator.filter;
69     shouldBe("nodeFilter.FILTER_ACCEPT", 1);
70     shouldBe("nodeFilter.FILTER_REJECT", 2);
71     shouldBe("nodeFilter.FILTER_SKIP", 3);
72     shouldBe("nodeFilter.SHOW_ALL", 4294967295);
73     shouldBe("nodeFilter.SHOW_ELEMENT", 0x00000001);
74     shouldBe("nodeFilter.SHOW_ATTRIBUTE", 0x00000002);
75     shouldBe("nodeFilter.SHOW_TEXT", 0x00000004);
76     shouldBe("nodeFilter.SHOW_CDATA_SECTION", 0x00000008);
77     shouldBe("nodeFilter.SHOW_ENTITY_REFERENCE", 0x00000010);
78     shouldBe("nodeFilter.SHOW_ENTITY", 0x00000020);
79     shouldBe("nodeFilter.SHOW_PROCESSING_INSTRUCTION", 0x00000040);
80     shouldBe("nodeFilter.SHOW_COMMENT", 0x00000080);
81     shouldBe("nodeFilter.SHOW_DOCUMENT", 0x00000100);
82     shouldBe("nodeFilter.SHOW_DOCUMENT_TYPE", 0x00000200);
83     shouldBe("nodeFilter.SHOW_DOCUMENT_FRAGMENT", 0x00000400);
84     shouldBe("nodeFilter.SHOW_NOTATION", 0x00000800);
85
86     shouldBe("window.NodeFilter.FILTER_ACCEPT", 1);
87     shouldBe("window.NodeFilter.FILTER_REJECT", 2);
88     shouldBe("window.NodeFilter.FILTER_SKIP", 3);
89     shouldBe("window.NodeFilter.SHOW_ALL", 4294967295);
90     shouldBe("window.NodeFilter.SHOW_ELEMENT", 0x00000001);
91     shouldBe("window.NodeFilter.SHOW_ATTRIBUTE", 0x00000002);
92     shouldBe("window.NodeFilter.SHOW_TEXT", 0x00000004);
93     shouldBe("window.NodeFilter.SHOW_CDATA_SECTION", 0x00000008);
94     shouldBe("window.NodeFilter.SHOW_ENTITY_REFERENCE", 0x00000010);
95     shouldBe("window.NodeFilter.SHOW_ENTITY", 0x00000020);
96     shouldBe("window.NodeFilter.SHOW_PROCESSING_INSTRUCTION", 0x00000040);
97     shouldBe("window.NodeFilter.SHOW_COMMENT", 0x00000080);
98     shouldBe("window.NodeFilter.SHOW_DOCUMENT", 0x00000100);
99     shouldBe("window.NodeFilter.SHOW_DOCUMENT_TYPE", 0x00000200);
100     shouldBe("window.NodeFilter.SHOW_DOCUMENT_FRAGMENT", 0x00000400);
101     shouldBe("window.NodeFilter.SHOW_NOTATION", 0x00000800);
102
103     event = document.createEvent("Event");
104     shouldBe("event.NONE", 0);
105     shouldBe("event.CAPTURING_PHASE", 1);
106     shouldBe("event.AT_TARGET", 2);
107     shouldBe("event.BUBBLING_PHASE", 3);
108     shouldBe("event.MOUSEDOWN", 1);    
109     shouldBe("event.MOUSEUP", 2);    
110     shouldBe("event.MOUSEOVER", 4);    
111     shouldBe("event.MOUSEOUT", 8);    
112     shouldBe("event.MOUSEMOVE", 16);   
113     shouldBe("event.MOUSEDRAG", 32);   
114     shouldBe("event.CLICK", 64);   
115     shouldBe("event.DBLCLICK", 128);  
116     shouldBe("event.KEYDOWN", 256);  
117     shouldBe("event.KEYUP", 512);  
118     shouldBe("event.KEYPRESS", 1024); 
119     shouldBe("event.DRAGDROP", 2048); 
120     shouldBe("event.FOCUS", 4096); 
121     shouldBe("event.BLUR", 8192); 
122     shouldBe("event.SELECT", 16384);
123     shouldBe("event.CHANGE", 32768);
124
125     shouldBe("window.Event.NONE", 0);
126     shouldBe("window.Event.CAPTURING_PHASE", 1);
127     shouldBe("window.Event.AT_TARGET", 2);
128     shouldBe("window.Event.BUBBLING_PHASE", 3);
129     shouldBe("window.Event.MOUSEDOWN", 1);    
130     shouldBe("window.Event.MOUSEUP", 2);    
131     shouldBe("window.Event.MOUSEOVER", 4);    
132     shouldBe("window.Event.MOUSEOUT", 8);    
133     shouldBe("window.Event.MOUSEMOVE", 16);   
134     shouldBe("window.Event.MOUSEDRAG", 32);   
135     shouldBe("window.Event.CLICK", 64);   
136     shouldBe("window.Event.DBLCLICK", 128);  
137     shouldBe("window.Event.KEYDOWN", 256);  
138     shouldBe("window.Event.KEYUP", 512);  
139     shouldBe("window.Event.KEYPRESS", 1024); 
140     shouldBe("window.Event.DRAGDROP", 2048); 
141     shouldBe("window.Event.FOCUS", 4096); 
142     shouldBe("window.Event.BLUR", 8192); 
143     shouldBe("window.Event.SELECT", 16384);
144     shouldBe("window.Event.CHANGE", 32768);
145 }
146 </script>
147 </head>
148 <body onload="test();">
149 <p>This page tests CSSRule, NodeFilter, and Event. It tests:</p>
150 <ol>
151     <li>Whether their global constructors have the correct constant values</li>
152     <li>Whether their objects have the correct constant values</li>
153 </ol>
154 <hr>
155 <div id='console'></div>
156 </body>
157 </html>