| 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 <script> | 8 <script> |
| 9 description("Testing document.register() basic behaviors."); | 9 description("Testing document.register() basic behaviors."); |
| 10 | 10 |
| 11 if (window.testRunner) | 11 if (window.testRunner) |
| 12 testRunner.dumpAsText(); | 12 testRunner.dumpAsText(); |
| 13 | 13 |
| 14 function createRegisterParamters() | 14 function createRegisterParamters() |
| 15 { | 15 { |
| 16 return { | 16 return { |
| 17 prototype: Object.create(HTMLElement.prototype, { thisIsPrototype: { val
ue: true } }) | 17 prototype: Object.create(HTMLElement.prototype, { thisIsPrototype: { val
ue: true } }) |
| 18 }; | 18 }; |
| 19 } | 19 } |
| 20 | 20 |
| 21 // Invalid names | 21 // Invalid names |
| 22 shouldThrow("document.register('foo', createRegisterParamters())", "'Error: Inva
lidCharacterError: DOM Exception 5'"); | 22 shouldThrow("document.register('foo', createRegisterParamters())", "'InvalidChar
acterError: An invalid or illegal character was specified, such as in an XML nam
e.'"); |
| 23 shouldThrow("document.register('xfoo', createRegisterParamters())", "'Error: Inv
alidCharacterError: DOM Exception 5'"); | 23 shouldThrow("document.register('xfoo', createRegisterParamters())", "'InvalidCha
racterError: An invalid or illegal character was specified, such as in an XML na
me.'"); |
| 24 shouldThrow("document.register('missing-glyph', createRegisterParamters())", "'E
rror: InvalidCharacterError: DOM Exception 5'"); | 24 shouldThrow("document.register('missing-glyph', createRegisterParamters())", "'I
nvalidCharacterError: An invalid or illegal character was specified, such as in
an XML name.'"); |
| 25 | 25 |
| 26 var fooConstructor = document.register("x-foo", createRegisterParamters()); | 26 var fooConstructor = document.register("x-foo", createRegisterParamters()); |
| 27 shouldBe("typeof fooConstructor", "'function'"); | 27 shouldBe("typeof fooConstructor", "'function'"); |
| 28 shouldBe("fooConstructor.prototype.__proto__", "HTMLElement.prototype"); | 28 shouldBe("fooConstructor.prototype.__proto__", "HTMLElement.prototype"); |
| 29 shouldBeTrue("fooConstructor.prototype.thisIsPrototype"); | 29 shouldBeTrue("fooConstructor.prototype.thisIsPrototype"); |
| 30 | 30 |
| 31 // Name conflicts | 31 // Name conflicts |
| 32 shouldThrow("document.register('x-foo', createRegisterParamters())", "'Error: In
validStateError: DOM Exception 11'"); | 32 shouldThrow("document.register('x-foo', createRegisterParamters())", "'InvalidSt
ateError: An attempt was made to use an object that is not, or is no longer, usa
ble.'"); |
| 33 shouldThrow("document.register('X-FOO', createRegisterParamters())", "'Error: In
validStateError: DOM Exception 11'"); | 33 shouldThrow("document.register('X-FOO', createRegisterParamters())", "'InvalidSt
ateError: An attempt was made to use an object that is not, or is no longer, usa
ble.'"); |
| 34 | 34 |
| 35 // Bad prototype: constructor property exists | 35 // Bad prototype: constructor property exists |
| 36 shouldThrow("document.register('x-bad-a', { prototype: HTMLElement.prototype })"
, "'Error: InvalidStateError: DOM Exception 11'"); | 36 shouldThrow("document.register('x-bad-a', { prototype: HTMLElement.prototype })"
, "'InvalidStateError: An attempt was made to use an object that is not, or is n
o longer, usable.'"); |
| 37 // Bad prototype: missing __proto__ | 37 // Bad prototype: missing __proto__ |
| 38 shouldThrow("document.register('x-bad-b', { prototype: {} })", "'Error: InvalidS
tateError: DOM Exception 11'"); | 38 shouldThrow("document.register('x-bad-b', { prototype: {} })", "'InvalidStateErr
or: An attempt was made to use an object that is not, or is no longer, usable.'"
); |
| 39 // Bad prototype: wrong __proto__ | 39 // Bad prototype: wrong __proto__ |
| 40 shouldThrow("document.register('x-bad-c', { prototype: Object.create(Document.pr
ototype) })", "'Error: InvalidStateError: DOM Exception 11'"); | 40 shouldThrow("document.register('x-bad-c', { prototype: Object.create(Document.pr
ototype) })", "'InvalidStateError: An attempt was made to use an object that is
not, or is no longer, usable.'"); |
| 41 // Call as function | 41 // Call as function |
| 42 shouldThrow("fooConstructor()", "'TypeError: DOM object constructor cannot be ca
lled as a function.'") | 42 shouldThrow("fooConstructor()", "'TypeError: DOM object constructor cannot be ca
lled as a function.'") |
| 43 | 43 |
| 44 // Constructor initiated instantiation | 44 // Constructor initiated instantiation |
| 45 var createdFoo = new fooConstructor(); | 45 var createdFoo = new fooConstructor(); |
| 46 | 46 |
| 47 // JS built-in properties | 47 // JS built-in properties |
| 48 shouldBe("createdFoo.__proto__", "fooConstructor.prototype"); | 48 shouldBe("createdFoo.__proto__", "fooConstructor.prototype"); |
| 49 shouldBe("createdFoo.constructor", "fooConstructor"); | 49 shouldBe("createdFoo.constructor", "fooConstructor"); |
| 50 | 50 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 107 |
| 108 // Constructor shouldn't interfere each otehr | 108 // Constructor shouldn't interfere each otehr |
| 109 shouldBe("(new fooConstructor).tagName", "'X-FOO'"); | 109 shouldBe("(new fooConstructor).tagName", "'X-FOO'"); |
| 110 shouldBe("(new barConstructor).tagName", "'X-BAR'"); | 110 shouldBe("(new barConstructor).tagName", "'X-BAR'"); |
| 111 shouldBe("(new bazConstructor).tagName", "'X-BAZ'"); | 111 shouldBe("(new bazConstructor).tagName", "'X-BAZ'"); |
| 112 | 112 |
| 113 </script> | 113 </script> |
| 114 <script src="../../js/resources/js-test-post.js"></script> | 114 <script src="../../js/resources/js-test-post.js"></script> |
| 115 </body> | 115 </body> |
| 116 </html> | 116 </html> |
| OLD | NEW |