| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <script src="../../js/resources/js-test-pre.js"></script> | 4 <script src="../../js/resources/js-test-pre.js"></script> |
| 5 </head> | 5 </head> |
| 6 <body> | 6 <body> |
| 7 <div id="container"></div> | 7 <div id="container"></div> |
| 8 <form id="testForm"></form> | 8 <form id="testForm"></form> |
| 9 <script> | 9 <script> |
| 10 description("Testing document.register() type extension behaviours through creat
eElement()."); | 10 description("Testing document.register() type extension behaviours through creat
eElement()."); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // HTMLElement <- input <- x-bar <- x-qux | 24 // HTMLElement <- input <- x-bar <- x-qux |
| 25 // <- x-foo <- x-baz | 25 // <- x-foo <- x-baz |
| 26 // | 26 // |
| 27 | 27 |
| 28 fooConstructor = document.register('x-foo', { prototype: Object.create(HTMLEleme
nt.prototype) }); | 28 fooConstructor = document.register('x-foo', { prototype: Object.create(HTMLEleme
nt.prototype) }); |
| 29 barConstructor = document.register('x-bar', { prototype: Object.create(HTMLInput
Element.prototype) }); | 29 barConstructor = document.register('x-bar', { prototype: Object.create(HTMLInput
Element.prototype) }); |
| 30 bazConstructor = document.register('x-baz', { prototype: Object.create(fooConstr
uctor.prototype) }); | 30 bazConstructor = document.register('x-baz', { prototype: Object.create(fooConstr
uctor.prototype) }); |
| 31 quxConstructor = document.register('x-qux', { prototype: Object.create(barConstr
uctor.prototype) }); | 31 quxConstructor = document.register('x-qux', { prototype: Object.create(barConstr
uctor.prototype) }); |
| 32 | 32 |
| 33 // Same name, different local name | 33 // Same name, different local name |
| 34 shouldThrow("document.register('x-foo', { prototype: Object.create(HTMLDivElemen
t.prototype) })", "'Error: InvalidStateError: DOM Exception 11'"); | 34 shouldThrow("document.register('x-foo', { prototype: Object.create(HTMLDivElemen
t.prototype) })", "'InvalidStateError: An attempt was made to use an object that
is not, or is no longer, usable.'"); |
| 35 | 35 |
| 36 // | 36 // |
| 37 // Generated constructors | 37 // Generated constructors |
| 38 // | 38 // |
| 39 | 39 |
| 40 fooNewed = new fooConstructor(); | 40 fooNewed = new fooConstructor(); |
| 41 fooOuterHTML = "'<x-foo></x-foo>'"; | 41 fooOuterHTML = "'<x-foo></x-foo>'"; |
| 42 shouldBe("fooNewed.outerHTML", fooOuterHTML); | 42 shouldBe("fooNewed.outerHTML", fooOuterHTML); |
| 43 shouldBeTrue("fooNewed instanceof fooConstructor && fooNewed instanceof HTMLElem
ent"); | 43 shouldBeTrue("fooNewed instanceof fooConstructor && fooNewed instanceof HTMLElem
ent"); |
| 44 shouldBeFalse("fooNewed instanceof HTMLUnknownElement"); | 44 shouldBeFalse("fooNewed instanceof HTMLUnknownElement"); |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 shouldBeTrue("barFooCreated instanceof HTMLElement"); | 116 shouldBeTrue("barFooCreated instanceof HTMLElement"); |
| 117 | 117 |
| 118 fooCreatedNull = document.createElement("x-foo", null); | 118 fooCreatedNull = document.createElement("x-foo", null); |
| 119 shouldBe("fooCreatedNull.outerHTML", fooOuterHTML); | 119 shouldBe("fooCreatedNull.outerHTML", fooOuterHTML); |
| 120 shouldBeTrue("fooCreatedNull instanceof fooConstructor"); | 120 shouldBeTrue("fooCreatedNull instanceof fooConstructor"); |
| 121 | 121 |
| 122 fooCreatedEmpty = document.createElement("x-foo", ""); | 122 fooCreatedEmpty = document.createElement("x-foo", ""); |
| 123 shouldBe("fooCreatedEmpty.outerHTML", fooOuterHTML); | 123 shouldBe("fooCreatedEmpty.outerHTML", fooOuterHTML); |
| 124 shouldBeTrue("fooCreatedEmpty instanceof fooConstructor"); | 124 shouldBeTrue("fooCreatedEmpty instanceof fooConstructor"); |
| 125 | 125 |
| 126 shouldThrow("document.createElement('@invalid', 'x-bar')", "'Error: InvalidChara
cterError: DOM Exception 5'"); | 126 shouldThrow("document.createElement('@invalid', 'x-bar')", "'InvalidCharacterErr
or: An invalid or illegal character was specified, such as in an XML name.'"); |
| 127 | 127 |
| 128 // | 128 // |
| 129 // createElementNS() with type extensions | 129 // createElementNS() with type extensions |
| 130 // | 130 // |
| 131 | 131 |
| 132 fooCreatedNS = document.createElementNS("http://www.w3.org/1999/xhtml", "x-foo",
null); | 132 fooCreatedNS = document.createElementNS("http://www.w3.org/1999/xhtml", "x-foo",
null); |
| 133 shouldBe("fooCreatedNS.outerHTML", fooOuterHTML); | 133 shouldBe("fooCreatedNS.outerHTML", fooOuterHTML); |
| 134 shouldBeTrue("fooCreatedNS instanceof fooConstructor"); | 134 shouldBeTrue("fooCreatedNS instanceof fooConstructor"); |
| 135 | 135 |
| 136 barCreatedNS = document.createElementNS("http://www.w3.org/1999/xhtml", "input",
"x-bar"); | 136 barCreatedNS = document.createElementNS("http://www.w3.org/1999/xhtml", "input",
"x-bar"); |
| 137 shouldBe("barCreatedNS.outerHTML", barOuterHTML); | 137 shouldBe("barCreatedNS.outerHTML", barOuterHTML); |
| 138 shouldBeTrue("barCreatedNS instanceof barConstructor"); | 138 shouldBeTrue("barCreatedNS instanceof barConstructor"); |
| 139 shouldBeTrue("isFormControl(barCreatedNS)"); | 139 shouldBeTrue("isFormControl(barCreatedNS)"); |
| 140 | 140 |
| 141 shouldThrow("document.createElementNS('http://example.com/2013/no-such-namespace
', 'xml:lang', 'x-bar')", "'Error: NamespaceError: DOM Exception 14'"); | 141 shouldThrow("document.createElementNS('http://example.com/2013/no-such-namespace
', 'xml:lang', 'x-bar')", "'NamespaceError: An attempt was made to create or cha
nge an object in a way which is incorrect with regard to namespaces.'"); |
| 142 | 142 |
| 143 // parser | 143 // parser |
| 144 function createElementFromHTML(html) { | 144 function createElementFromHTML(html) { |
| 145 var container = document.createElement("div"); | 145 var container = document.createElement("div"); |
| 146 container.innerHTML = html; | 146 container.innerHTML = html; |
| 147 return container.firstChild; | 147 return container.firstChild; |
| 148 } | 148 } |
| 149 | 149 |
| 150 fooParsed = createElementFromHTML('<x-foo>'); | 150 fooParsed = createElementFromHTML('<x-foo>'); |
| 151 shouldBeTrue("fooParsed instanceof fooConstructor"); | 151 shouldBeTrue("fooParsed instanceof fooConstructor"); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 164 shouldBeTrue("namedBarParsed instanceof HTMLElement"); | 164 shouldBeTrue("namedBarParsed instanceof HTMLElement"); |
| 165 | 165 |
| 166 divBarParsed = createElementFromHTML('<div is=x-bar>') | 166 divBarParsed = createElementFromHTML('<div is=x-bar>') |
| 167 shouldBeFalse("divBarParsed instanceof barConstructor"); | 167 shouldBeFalse("divBarParsed instanceof barConstructor"); |
| 168 shouldBeTrue("divBarParsed instanceof HTMLDivElement"); | 168 shouldBeTrue("divBarParsed instanceof HTMLDivElement"); |
| 169 | 169 |
| 170 </script> | 170 </script> |
| 171 <script src="../../js/resources/js-test-post.js"></script> | 171 <script src="../../js/resources/js-test-post.js"></script> |
| 172 </body> | 172 </body> |
| 173 </html> | 173 </html> |
| OLD | NEW |