Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / dom-constructors.html
blobe3e6f361b0afe64890b16e5b8c4d369b94c37219
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 </head>
5 <body>
6 <div id="element" name="element_name"></div>
7 <script>
8 description('This test checks that all but a handful of dom constructors throw exceptions, and the rest return reasonable objects. It also tests that those constructors have higher precedence than a document element with the same ID or name.');
10 var element = document.getElementById("element");
12 // These objects should throw an exception when their constructor is called
13 // with no arguments. (Some of them may have working constructors that require
14 // arguments to be valid.)
15 var objects_exception = [
16 'Attr',
17 'CharacterData',
18 'CDATASection',
19 'Document',
20 'DocumentType',
21 'Element',
22 'EventTarget',
23 'HTMLDocument',
24 'Node',
25 'ProcessingInstruction',
26 'HTMLAllCollection',
27 'HTMLAnchorElement',
28 'HTMLAreaElement',
29 'HTMLBaseElement',
30 'HTMLBodyElement',
31 'HTMLBRElement',
32 'HTMLButtonElement',
33 'HTMLCanvasElement',
34 'HTMLDirectoryElement',
35 'HTMLDivElement',
36 'HTMLDListElement',
37 'HTMLEmbedElement',
38 'HTMLFieldSetElement',
39 'HTMLFontElement',
40 'HTMLFormElement',
41 'HTMLFrameElement',
42 'HTMLFrameSetElement',
43 'HTMLHeadingElement',
44 'HTMLHeadElement',
45 'HTMLHRElement',
46 'HTMLHtmlElement',
47 'HTMLIFrameElement',
48 'HTMLImageElement',
49 'HTMLInputElement',
50 'HTMLLabelElement',
51 'HTMLLegendElement',
52 'HTMLLIElement',
53 'HTMLLinkElement',
54 'HTMLMapElement',
55 'HTMLMarqueeElement',
56 'HTMLMenuElement',
57 'HTMLMetaElement',
58 'HTMLModElement',
59 'HTMLObjectElement',
60 'HTMLOListElement',
61 'HTMLOptGroupElement',
62 'HTMLOptionElement',
63 'HTMLParagraphElement',
64 'HTMLParamElement',
65 'HTMLPreElement',
66 'HTMLQuoteElement',
67 'HTMLScriptElement',
68 'HTMLSelectElement',
69 'HTMLStyleElement',
70 'HTMLTableCaptionElement',
71 'HTMLTableColElement',
72 'HTMLTableElement',
73 'HTMLTableSectionElement',
74 'HTMLTableCellElement',
75 'HTMLTableRowElement',
76 'HTMLTextAreaElement',
77 'HTMLTitleElement',
78 'HTMLUListElement',
79 'HTMLElement',
80 'CanvasRenderingContext2D',
81 'CSSFontFaceRule',
82 'CSSImportRule',
83 'CSSMediaRule',
84 'CSSPageRule',
85 'CSSRule',
86 'CSSRuleList',
87 'CSSStyleDeclaration',
88 'CSSStyleRule',
89 'CSSStyleSheet',
90 'DOMImplementation',
91 'DataTransfer',
92 'HTMLCollection',
93 'MediaList',
94 'MimeType',
95 'MimeTypeArray',
96 'MutationEvent',
97 'NamedNodeMap',
98 'NodeFilter',
99 'NodeList',
100 'Plugin',
101 'PluginArray',
102 'StyleSheet',
103 'StyleSheetList',
104 'TextEvent',
105 'XPathResult',
106 'BarInfo',
107 'CanvasGradient',
108 'CanvasPattern',
109 'Console',
110 'Selection',
111 'Window',
112 'History',
113 'HTMLOptionsCollection',
114 'Location',
115 'Navigator',
116 'NodeIterator',
117 'Screen',
118 'TreeWalker',
119 'XPathExpression',
120 'Worker'
123 // These objects should have a working constructor.
124 var objects_constructor = [
125 'Comment',
126 'DOMParser',
127 'DocumentFragment',
128 'Range',
129 'Text',
130 'XMLHttpRequest',
131 'XMLSerializer',
132 'XPathEvaluator',
133 'XSLTProcessor'
136 // These objects should have no constructor.
137 var objects_no_constructor = [
138 'EventTargetNode',
139 'UndetectableHTMLCollection',
140 'XPathNSResolver',
141 'EventListener',
142 'NPObject'
145 // These objects should have a working constructor, but their constructed
146 // object names differ. This is therefore a map from constructor name to
147 // constructed object.
148 var objects_different_constructor = {
149 'Audio': 'HTMLAudioElement',
150 'Option': 'HTMLOptionElement',
151 'Image': 'HTMLImageElement'
154 function TryAllocate(node) {
155 var Cons = this[node];
156 if (!Cons) return 'no constructor';
157 try { return Object.prototype.toString.call(new Cons()); }
158 catch (e) { return 'exception'; }
161 function check(name, expected) {
162 actual = TryAllocate(node);
163 if (actual == expected) {
164 document.write("PASS: " + name + " '" + expected + "'<br>");
165 } else {
166 document.write("FAIL: " + name + " wanted '" + expected + "', got '" +
167 actual + "'<br>");
171 for (var i = 0; i < objects_exception.length; i++) {
172 var obj = objects_exception[i];
173 shouldBe("TryAllocate('" + obj + "')", "'exception'");
176 for (var i = 0; i < objects_no_constructor.length; i++) {
177 var obj = objects_no_constructor[i];
178 shouldBe("TryAllocate('" + obj + "')", "'no constructor'");
181 for (var i = 0; i < objects_constructor.length; i++) {
182 var obj = objects_constructor[i];
183 shouldBe("TryAllocate('" + obj + "')", "'[object " + obj + "]'");
184 element.id = obj;
185 shouldBe("TryAllocate('" + obj + "')", "'[object " + obj + "]'");
186 element.id = "element";
187 element.name = obj;
188 shouldBe("TryAllocate('" + obj + "')", "'[object " + obj + "]'");
189 element.name = "element_name";
192 for (var obj in objects_different_constructor) {
193 shouldBe("TryAllocate('" + obj + "')",
194 "'[object " + objects_different_constructor[obj] + "]'");
195 element.id = obj;
196 shouldBe("TryAllocate('" + obj + "')",
197 "'[object " + objects_different_constructor[obj] + "]'");
198 element.id = "element";
199 element.name = obj;
200 shouldBe("TryAllocate('" + obj + "')",
201 "'[object " + objects_different_constructor[obj] + "]'");
202 element.name = "element_name";
204 </script>
205 </body>
206 </html>