Upstream version 5.34.104.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / wrapper-classes.html
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 <style id="style" media="screen">
5 .non-existent-class {
6     color: rgb(0, 0, 0);
7     clip: rect(0, 0, 1, 1);
8     content: counter(dummy, square);
9 }
10 </style>
11 </head>
12 <body>
13 <script>
14
15 if (window.testRunner)
16     testRunner.waitUntilDone();
17
18 function classString(node)
19 {
20     if (!node)
21         return "[null]";
22     var string = Object.prototype.toString.apply(node);
23     return string.substr(8, string.length - 9);
24 }
25
26 function tagClassString(tagName)
27 {
28     return classString(document.createElement(tagName));
29 }
30
31 function tagPrototypeClassString(tagName)
32 {
33     return classString(document.createElement(tagName).__proto__);
34 }
35
36 function tagConstructorClassString(tagName)
37 {
38     return classString(document.createElement(tagName).constructor);
39 }
40
41 function tagConstructorName(tagName)
42 {
43     return document.createElement(tagName).constructor.name;
44 }
45
46 function testTag(tagName, className, prototypeName, constructorName)
47 {
48     if (!prototypeName)
49         prototypeName = className + "Prototype";
50     if (!constructorName)
51         constructorName = className;
52     shouldBeEqualToString("tagClassString('" + tagName + "')", className);
53     shouldBeEqualToString("tagPrototypeClassString('" + tagName + "')", prototypeName);
54     shouldBeEqualToString("tagConstructorClassString('" + tagName + "')", "Function");
55     shouldBeEqualToString("tagConstructorName('" + tagName + "')", constructorName);
56 }
57
58 function test(expression, className, prototypeName, constructorName)
59 {
60     if (!prototypeName)
61         prototypeName = className + "Prototype";
62     if (!constructorName)
63         constructorName = className;
64     shouldBeEqualToString("classString(" + expression + ")", className);
65     shouldBeEqualToString("classString(" + expression + ".__proto__)", prototypeName);
66     shouldBeEqualToString("classString(" + expression + ".constructor)", "Function");
67     shouldBeEqualToString(expression + ".constructor.name", constructorName);
68 }
69
70 function runTest()
71 {
72     description("This tests wrapper class names for JavaScript.");
73
74     stylesheet = document.getElementById("style").sheet;
75     root = document.documentElement;
76     xmlDocument = document.getElementById("xmlframe").contentDocument;
77
78     debug('Basics');
79     debug('');
80
81     test("document.createAttribute()", "Attr");
82     test("document.createComment('')", "Comment");
83     test("document.createDocumentFragment()", "DocumentFragment");
84     test("document.implementation", "DOMImplementation");
85     test("root.attributes", "NamedNodeMap");
86     test("document.createNodeIterator(root, 0, null, false)", "NodeIterator");
87     test("document.getElementsByTagName('div')", "HTMLCollection");
88     test("document.createRange()", "Range");
89     test("document.createTextNode('')", "Text");
90     test("document.createTreeWalker(root, 0, null, false)", "TreeWalker");
91
92     debug('');
93     debug('XML');
94     debug('');
95
96     test("xmlDocument", "XMLDocument");
97     test("xmlDocument.createCDATASection()", "CDATASection");
98     test("xmlDocument.createElementNS('x', 'x', 'x')", "Element");
99     test("xmlDocument.createProcessingInstruction('x', '')", "ProcessingInstruction");
100
101     debug('');
102     debug('Events');
103     debug('');
104
105     test("document.createEvent('Event')", "Event");
106     test("document.createEvent('KeyboardEvent')", "KeyboardEvent");
107     test("document.createEvent('MouseEvent')", "MouseEvent");
108     test("document.createEvent('MutationEvent')", "MutationEvent");
109     test("document.createEvent('OverflowEvent')", "OverflowEvent");
110     test("document.createEvent('TextEvent')", "TextEvent");
111     test("document.createEvent('UIEvent')", "UIEvent");
112     test("document.createEvent('WheelEvent')", "WheelEvent");
113
114     debug('');
115     debug('CSS DOM');
116     debug('');
117
118     test("document.styleSheets", "StyleSheetList");
119     test("stylesheet", "CSSStyleSheet");
120     test("stylesheet.cssRules", "CSSRuleList");
121     test("stylesheet.cssRules.item(0)", "CSSStyleRule");
122     test("stylesheet.cssRules.item(0).style", "CSSStyleDeclaration");
123     test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('color')", "CSSPrimitiveValue");
124     test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('color').getRGBColorValue()", "RGBColor");
125     test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('clip').getRectValue()", "Rect");
126     test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('content')", "CSSValueList");
127     test("stylesheet.cssRules.item(0).style.getPropertyCSSValue('content').item(0).getCounterValue()", "Counter");
128     test("stylesheet.media", "MediaList");
129
130     debug('');
131     debug('XPath');
132     debug('');
133
134     test("document.createExpression('//*', document.createNSResolver(document))", "XPathExpression");
135     test("document.evaluate('//*', document, document.createNSResolver(document), 0, null)", "XPathResult");
136
137     debug('');
138     debug('Other');
139     debug('');
140
141     test("window", "Window");
142
143     debug('');
144     debug('HTML DOM');
145     debug('');
146
147     test("root.children", "HTMLCollection");
148     test("document", "HTMLDocument");
149     test("document.createElement('select').options", "HTMLOptionsCollection");
150
151     debug('');
152     debug('HTML Elements');
153     debug('');
154
155     testTag("a", "HTMLAnchorElement");
156     testTag("abbr", "HTMLElement");
157     testTag("acronym", "HTMLElement");
158     testTag("address", "HTMLElement");
159     testTag("applet", "HTMLAppletElement");
160     testTag("area", "HTMLAreaElement");
161     testTag("article", "HTMLElement");
162     testTag("aside", "HTMLElement");
163     testTag("b", "HTMLElement");
164     testTag("base", "HTMLBaseElement");
165     testTag("basefont", "HTMLElement");
166     testTag("bdo", "HTMLElement");
167     testTag("big", "HTMLElement");
168     testTag("blockquote", "HTMLQuoteElement");
169     testTag("body", "HTMLBodyElement");
170     testTag("br", "HTMLBRElement");
171     testTag("button", "HTMLButtonElement");
172     testTag("canvas", "HTMLCanvasElement");
173     testTag("caption", "HTMLTableCaptionElement");
174     testTag("center", "HTMLElement");
175     testTag("cite", "HTMLElement");
176     testTag("code", "HTMLElement");
177     testTag("col", "HTMLTableColElement");
178     testTag("colgroup", "HTMLTableColElement");
179     testTag("dd", "HTMLElement");
180     testTag("del", "HTMLModElement");
181     testTag("dfn", "HTMLElement");
182     testTag("dir", "HTMLDirectoryElement");
183     testTag("div", "HTMLDivElement");
184     testTag("dl", "HTMLDListElement");
185     testTag("dt", "HTMLElement");
186     testTag("em", "HTMLElement");
187     testTag("embed", "HTMLEmbedElement");
188     testTag("fieldset", "HTMLFieldSetElement");
189     testTag("font", "HTMLFontElement");
190     testTag("footer", "HTMLElement");
191     testTag("form", "HTMLFormElement");
192     testTag("frame", "HTMLFrameElement");
193     testTag("frameset", "HTMLFrameSetElement");
194     testTag("head", "HTMLHeadElement");
195     testTag("h1", "HTMLHeadingElement");
196     testTag("h2", "HTMLHeadingElement");
197     testTag("h3", "HTMLHeadingElement");
198     testTag("h4", "HTMLHeadingElement");
199     testTag("h5", "HTMLHeadingElement");
200     testTag("h6", "HTMLHeadingElement");
201     testTag("head", "HTMLHeadElement");
202     testTag("header", "HTMLElement");
203     testTag("hgroup", "HTMLElement");
204     testTag("hr", "HTMLHRElement");
205     testTag("html", "HTMLHtmlElement");
206     testTag("i", "HTMLElement");
207     testTag("iframe", "HTMLIFrameElement");
208     testTag("image", "HTMLUnknownElement");
209     testTag("img", "HTMLImageElement");
210     testTag("input", "HTMLInputElement");
211     testTag("ins", "HTMLModElement");
212     testTag("kbd", "HTMLElement");
213     testTag("keygen", "HTMLKeygenElement");
214     testTag("label", "HTMLLabelElement");
215     testTag("layer", "HTMLElement");
216     testTag("legend", "HTMLLegendElement");
217     testTag("li", "HTMLLIElement");
218     testTag("link", "HTMLLinkElement");
219     testTag("listing", "HTMLPreElement");
220     testTag("main", "HTMLElement");
221     testTag("map", "HTMLMapElement");
222     testTag("marquee", "HTMLMarqueeElement");
223     testTag("menu", "HTMLMenuElement");
224     testTag("meta", "HTMLMetaElement");
225     testTag("nav", "HTMLElement");
226     testTag("nobr", "HTMLElement");
227     testTag("noembed", "HTMLElement");
228     testTag("noframes", "HTMLElement");
229     testTag("nolayer", "HTMLElement");
230     testTag("noscript", "HTMLElement");
231     testTag("object", "HTMLObjectElement");
232     testTag("ol", "HTMLOListElement");
233     testTag("optgroup", "HTMLOptGroupElement");
234     testTag("option", "HTMLOptionElement");
235     testTag("p", "HTMLParagraphElement");
236     testTag("param", "HTMLParamElement");
237     testTag("plaintext", "HTMLElement");
238     testTag("pre", "HTMLPreElement");
239     testTag("q", "HTMLQuoteElement");
240     testTag("rp", "HTMLElement");
241     testTag("rt", "HTMLElement");
242     testTag("ruby", "HTMLElement");
243     testTag("s", "HTMLElement");
244     testTag("samp", "HTMLElement");
245     testTag("script", "HTMLScriptElement");
246     testTag("section", "HTMLElement");
247     testTag("select", "HTMLSelectElement");
248     testTag("small", "HTMLElement");
249     testTag("span", "HTMLSpanElement");
250     testTag("strike", "HTMLElement");
251     testTag("strong", "HTMLElement");
252     testTag("style", "HTMLStyleElement");
253     testTag("sub", "HTMLElement");
254     testTag("sup", "HTMLElement");
255     testTag("table", "HTMLTableElement");
256     testTag("tbody", "HTMLTableSectionElement");
257     testTag("td", "HTMLTableCellElement");
258     testTag("textarea", "HTMLTextAreaElement");
259     testTag("tfoot", "HTMLTableSectionElement");
260     testTag("th", "HTMLTableCellElement");
261     testTag("thead", "HTMLTableSectionElement");
262     testTag("title", "HTMLTitleElement");
263     testTag("tr", "HTMLTableRowElement");
264     testTag("tt", "HTMLElement");
265     testTag("u", "HTMLElement");
266     testTag("ul", "HTMLUListElement");
267     testTag("var", "HTMLElement");
268     testTag("wbr", "HTMLElement");
269     testTag("xmp", "HTMLPreElement");
270
271     // Not yet tested:
272
273     // CSSCharsetRule
274     // CSSFontFaceRule
275     // CSSImportRule
276     // CSSMediaRule
277     // CSSPageRule
278     // CSSRule
279     // CSSVariablesRule
280     // WebKitCSSKeyframeRule
281     // WebKitCSSKeyframesRule
282     // CSSValue
283     // SVGColor
284     // SVGPaint
285     // SVGZoomEvent
286
287     // Conditional elements, VIDEO, RUBY.
288
289     // the various window sub-objects
290
291     // what else is missing?
292
293     if (window.testRunner)
294         testRunner.notifyDone();
295 }
296
297 function frameLoaded()
298 {
299     runTest();
300 }
301
302 </script>
303 <iframe id="xmlframe" onload="frameLoaded()" style="height:0px" src="data:application/xhtml+xml,<?xml version='1.0' encoding='UTF-8'?><body/>"></iframe>
304 </body>
305 </html>