OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/js-test.js"></script> | 2 <script src="../../../resources/js-test.js"></script> |
3 <body> | 3 <body> |
4 <span is="x-x" id="a"></span> | 4 <span is="x-x" id="a"></span> |
5 <script> | 5 <script> |
6 description('Test that changing an instantiated custom element\'s \'is\' attribu
te does not affect its element type.'); | 6 description('Test that changing an instantiated custom element\'s \'is\' attribu
te does not affect its element type.'); |
7 shouldBeNonNull('window.testRunner', 'This test requires testRunner.'); | 7 shouldBeNonNull('window.testRunner', 'This test requires testRunner.'); |
8 | 8 |
9 // Some custom definition lookup happens at wrapper generation time so | 9 // Some custom definition lookup happens at wrapper generation time so |
10 // do the change in another world to avoid hiding the bug. | 10 // do the change in another world to avoid hiding the bug. |
11 var worldId = 1; | 11 var worldId = 1; |
12 testRunner.evaluateScriptInIsolatedWorld( | 12 testRunner.evaluateScriptInIsolatedWorld( |
13 worldId, | 13 worldId, |
14 'var a = document.querySelector("#a");' + | 14 'var a = document.querySelector("#a");' + |
15 'a.setAttribute("is", "x-y");'); | 15 'a.setAttribute("is", "x-y");'); |
16 | 16 |
17 var createdCallCount = 0; | 17 var createdCallCount = 0; |
18 var createdBy = ''; | 18 var createdBy = ''; |
19 function onCreate(msg) { | 19 function onCreate(msg) { |
20 return function () { | 20 return function () { |
21 createdBy = msg; | 21 createdBy = msg; |
22 createdCallCount++; | 22 createdCallCount++; |
23 }; | 23 }; |
24 } | 24 } |
25 | 25 |
26 var protoX = Object.create(HTMLSpanElement.prototype); | 26 var protoX = Object.create(HTMLSpanElement.prototype); |
27 protoX.createdCallback = onCreate('X'); | 27 protoX.createdCallback = onCreate('X'); |
28 var X = document.register('x-x', {extends: 'span', prototype: protoX}); | 28 var X = document.registerElement('x-x', {extends: 'span', prototype: protoX}); |
29 | 29 |
30 var protoY = Object.create(HTMLSpanElement.prototype); | 30 var protoY = Object.create(HTMLSpanElement.prototype); |
31 protoY.createdCallback = onCreate('Y'); | 31 protoY.createdCallback = onCreate('Y'); |
32 var Y = document.register('x-y', {extends: 'span', prototype: protoY}); | 32 var Y = document.registerElement('x-y', {extends: 'span', prototype: protoY}); |
33 | 33 |
34 var a = document.querySelector('#a'); | 34 var a = document.querySelector('#a'); |
35 shouldBe('a.getAttribute("is")', '"x-y"'); | 35 shouldBe('a.getAttribute("is")', '"x-y"'); |
36 shouldBeTrue('a instanceof X'); | 36 shouldBeTrue('a instanceof X'); |
37 shouldBe('createdBy', '"X"'); | 37 shouldBe('createdBy', '"X"'); |
38 shouldBe('createdCallCount', '1'); | 38 shouldBe('createdCallCount', '1'); |
39 </script> | 39 </script> |
OLD | NEW |