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 <div id="container-a"><span is="x-a" id="x"></span></div> | 4 <div id="container-a"><span is="x-a" id="x"></span></div> |
5 <div id="container-b"><span is="x-a" id="y"></span></div> | 5 <div id="container-b"><span is="x-a" id="y"></span></div> |
6 <script> | 6 <script> |
7 description('Tests that accessing custom elements from an isolated world ' + | 7 description('Tests that accessing custom elements from an isolated world ' + |
8 'does not cause worlds to collide and destroy the galaxy.'); | 8 'does not cause worlds to collide and destroy the galaxy.'); |
9 | 9 |
10 shouldBeNonNull('window.testRunner', 'this test requires testRunner'); | 10 shouldBeNonNull('window.testRunner', 'this test requires testRunner'); |
(...skipping 10 matching lines...) Expand all Loading... |
21 | 21 |
22 // Registering an exception in the isolated world should raise an exception. | 22 // Registering an exception in the isolated world should raise an exception. |
23 result = testRunner.evaluateScriptInIsolatedWorldAndReturnValue( | 23 result = testRunner.evaluateScriptInIsolatedWorldAndReturnValue( |
24 world, | 24 world, |
25 '(function () { ' + | 25 '(function () { ' + |
26 ' var proto = Object.create(HTMLSpanElement.prototype); ' + | 26 ' var proto = Object.create(HTMLSpanElement.prototype); ' + |
27 ' proto.createdCallback = function () { ' + | 27 ' proto.createdCallback = function () { ' + |
28 ' console.log(this.id + " entered (isolated)"); ' + | 28 ' console.log(this.id + " entered (isolated)"); ' + |
29 ' }; ' + | 29 ' }; ' + |
30 ' try { ' + | 30 ' try { ' + |
31 ' document.register("x-a", {extends: "span", prototype: proto}); ' + | 31 ' document.registerElement("x-a", {extends: "span", prototype: proto}); '
+ |
32 ' return "register succeeded"; ' + | 32 ' return "register succeeded"; ' + |
33 ' } catch (e) { ' + | 33 ' } catch (e) { ' + |
34 ' return e.code; ' + | 34 ' return e.code; ' + |
35 ' } ' + | 35 ' } ' + |
36 '})()'); | 36 '})()'); |
37 | 37 |
38 shouldBe('result', 'DOMException.NOT_SUPPORTED_ERR', | 38 shouldBe('result', 'DOMException.NOT_SUPPORTED_ERR', |
39 'calling register from an isolated world should throw an exception'); | 39 'calling register from an isolated world should throw an exception'); |
40 | 40 |
41 // Now access this element from the main world. | 41 // Now access this element from the main world. |
42 a = containerA.querySelector('#x'); | 42 a = containerA.querySelector('#x'); |
43 shouldBe('a.__proto__', 'HTMLSpanElement.prototype', | 43 shouldBe('a.__proto__', 'HTMLSpanElement.prototype', |
44 'the main world should see the usual main world prototype'); | 44 'the main world should see the usual main world prototype'); |
45 | 45 |
46 // Upgrade from the main world | 46 // Upgrade from the main world |
47 | 47 |
48 var proto = Object.create(HTMLSpanElement.prototype); | 48 var proto = Object.create(HTMLSpanElement.prototype); |
49 invocations = []; | 49 invocations = []; |
50 proto.enteredViewCallback = function () { | 50 proto.attachedCallback = function () { |
51 invocations.push(this.id + ' entered (main)'); | 51 invocations.push(this.id + ' entered (main)'); |
52 }; | 52 }; |
53 document.register('x-a', {extends: 'span', prototype: proto}); | 53 document.registerElement('x-a', {extends: 'span', prototype: proto}); |
54 shouldBe('invocations', '["y entered (main)"]', | 54 shouldBe('invocations', '["y entered (main)"]', |
55 'only the element in the document should generate entered events'); | 55 'only the element in the document should generate entered events'); |
56 | 56 |
57 // Insert from the isolated world | 57 // Insert from the isolated world |
58 | 58 |
59 invocations = []; | 59 invocations = []; |
60 testRunner.evaluateScriptInIsolatedWorld(world++, | 60 testRunner.evaluateScriptInIsolatedWorld(world++, |
61 'document.body.appendChild(a);'); | 61 'document.body.appendChild(a);'); |
62 shouldBe('invocations', '["x entered (main)"]', | 62 shouldBe('invocations', '["x entered (main)"]', |
63 'modification in the isolated world should have caused callbacks ' + | 63 'modification in the isolated world should have caused callbacks ' + |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 ' y prototype is HTMLSpanElement.prototype? true,' + | 95 ' y prototype is HTMLSpanElement.prototype? true,' + |
96 ' y.p ~> undefined,' + | 96 ' y.p ~> undefined,' + |
97 ' y.q ~> undefined"', | 97 ' y.q ~> undefined"', |
98 'the isolated world should not see main world prototypes'); | 98 'the isolated world should not see main world prototypes'); |
99 | 99 |
100 // Lastly, collect some wrappers (e.g #b in isolated world) | 100 // Lastly, collect some wrappers (e.g #b in isolated world) |
101 document.querySelector('#container-b').innerHTML = ''; | 101 document.querySelector('#container-b').innerHTML = ''; |
102 gc(); | 102 gc(); |
103 testPassed('did not crash'); | 103 testPassed('did not crash'); |
104 </script> | 104 </script> |
OLD | NEW |