OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../resources/js-test.js"></script> | 3 <script src="../../resources/js-test.js"></script> |
4 <script> | 4 <script> |
5 var elem; | 5 'use strict'; |
| 6 var elem, select; |
6 var ns = "http://not-html.test"; | 7 var ns = "http://not-html.test"; |
7 | 8 |
8 function testDocumentProperty(attributeName, elementName, base) { | 9 function testDocumentProperty(attributeName, elementName, base) { |
9 var elem; | 10 var elem; |
10 if (typeof base == 'undefined') | 11 if (typeof base == 'undefined') |
11 base = 0; | 12 base = 0; |
12 | 13 |
13 elem = document.createElementNS(ns, elementName); | 14 elem = document.createElementNS(ns, elementName); |
14 document.body.appendChild(elem); | 15 document.body.appendChild(elem); |
15 shouldBe("document." + attributeName + ".length", base + ""); | 16 shouldBe("document." + attributeName + ".length", base + ""); |
16 document.body.removeChild(elem); | 17 document.body.removeChild(elem); |
17 | 18 |
18 elem = document.createElement(elementName); | 19 elem = document.createElement(elementName); |
19 document.body.appendChild(elem); | 20 document.body.appendChild(elem); |
20 shouldBe("document." + attributeName + ".length", base + 1 + ""); | 21 shouldBe("document." + attributeName + ".length", base + 1 + ""); |
21 document.body.removeChild(elem); | 22 document.body.removeChild(elem); |
22 } | 23 } |
23 | 24 |
24 function testDocumentPropertyWithAttribute(attributeName, elementName, elementAt
tributeName, base) { | 25 function testDocumentPropertyWithAttributes(attributeName, elementName, attribut
es, base) { |
25 var elem; | 26 var elem; |
26 if (typeof base == 'undefined') | 27 if (typeof base == 'undefined') |
27 base = 0; | 28 base = 0; |
28 | 29 |
29 elem = document.createElementNS(ns, elementName); | 30 elem = document.createElementNS(ns, elementName); |
30 elem.setAttribute(elementAttributeName, "foo"); | 31 for (let k in attributes) |
| 32 elem.setAttribute(k, attributes[k]); |
31 document.body.appendChild(elem); | 33 document.body.appendChild(elem); |
32 shouldBe("document." + attributeName + ".length", base + ""); | 34 shouldBe("document." + attributeName + ".length", base + ""); |
33 document.body.removeChild(elem); | 35 document.body.removeChild(elem); |
34 | 36 |
35 elem = document.createElement(elementName); | 37 elem = document.createElement(elementName); |
36 elem.setAttribute(elementAttributeName, "foo"); | 38 for (let k in attributes) |
| 39 elem.setAttribute(k, attributes[k]); |
37 document.body.appendChild(elem); | 40 document.body.appendChild(elem); |
38 shouldBe("document." + attributeName + ".length", base + 1 + ""); | 41 shouldBe("document." + attributeName + ".length", base + 1 + ""); |
39 document.body.removeChild(elem); | 42 document.body.removeChild(elem); |
40 } | 43 } |
41 | 44 |
42 function testElementProperty(elementName, attributeName, subelementName, base) { | 45 function testElementProperty(elementName, attributeName, subelementName, base) { |
43 var subelem; | 46 var subelem; |
44 if (typeof base == 'undefined') | 47 if (typeof base == 'undefined') |
45 base = 0; | 48 base = 0; |
46 | 49 |
(...skipping 21 matching lines...) Expand all Loading... |
68 select.appendChild(elem); | 71 select.appendChild(elem); |
69 shouldBe("select.options.length", "0"); | 72 shouldBe("select.options.length", "0"); |
70 shouldBe("select.selectedOptions.length", "0"); | 73 shouldBe("select.selectedOptions.length", "0"); |
71 | 74 |
72 elem = document.createElement("option"); | 75 elem = document.createElement("option"); |
73 select.appendChild(elem); | 76 select.appendChild(elem); |
74 shouldBe("select.options.length", "1"); | 77 shouldBe("select.options.length", "1"); |
75 | 78 |
76 testDocumentProperty("images", "img"); | 79 testDocumentProperty("images", "img"); |
77 testDocumentProperty("forms", "form"); | 80 testDocumentProperty("forms", "form"); |
78 testDocumentProperty("applets", "applet"); | 81 testDocumentPropertyWithAttributes("applets", "object", {type: "application/x-
java-applet"}); |
79 testDocumentProperty("embeds", "embed"); | 82 testDocumentProperty("embeds", "embed"); |
80 | 83 |
81 // Note that this is run before the final script element on this page is inser
ted | 84 // Note that this is run before the final script element on this page is inser
ted |
82 testDocumentProperty("scripts", "script", 3); | 85 testDocumentProperty("scripts", "script", 3); |
83 | 86 |
84 testDocumentPropertyWithAttribute("links", "a", "href"); | 87 testDocumentPropertyWithAttributes("links", "a", {href: "foo"}); |
85 testDocumentPropertyWithAttribute("links", "area", "href"); | 88 testDocumentPropertyWithAttributes("links", "area", {href: "foo"}); |
86 testDocumentPropertyWithAttribute("anchors", "a", "name"); | 89 testDocumentPropertyWithAttributes("anchors", "a", {name: "foo"}); |
87 | 90 |
88 testElementProperty("map", "areas", "area"); | 91 testElementProperty("map", "areas", "area"); |
89 testElementProperty("table", "rows", "tr"); | 92 testElementProperty("table", "rows", "tr"); |
90 testElementProperty("table", "tBodies", "tbody"); | 93 testElementProperty("table", "tBodies", "tbody"); |
91 testElementProperty("tr", "cells", "td"); | 94 testElementProperty("tr", "cells", "td"); |
92 testElementProperty("thead", "rows", "tr"); | 95 testElementProperty("thead", "rows", "tr"); |
93 testElementProperty("tbody", "rows", "tr"); | 96 testElementProperty("tbody", "rows", "tr"); |
94 testElementProperty("tfoot", "rows", "tr"); | 97 testElementProperty("tfoot", "rows", "tr"); |
95 } | 98 } |
96 </script> | 99 </script> |
97 </head> | 100 </head> |
98 <body> | 101 <body> |
99 <script>runTest();</script> | 102 <script>runTest();</script> |
100 </body> | 103 </body> |
101 </html> | 104 </html> |
OLD | NEW |