OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharness-helpers.js"></script> |
| 4 <script src="../resources/testharnessreport.js"></script> |
| 5 <script src="spec/resources/custom-elements-helpers.js"></script> |
| 6 <body> |
| 7 <script> |
| 8 'use strict'; |
| 9 (() => { |
| 10 |
| 11 if (!window.testRunner) { |
| 12 // Requires evaluateScriptInIsolatedWorld |
| 13 return; |
| 14 } |
| 15 |
| 16 promise_test((t) => { |
| 17 return create_window_in_test(t) |
| 18 .then((w) => { |
| 19 function in_isolated_world() { |
| 20 let f = document.querySelector('iframe'); |
| 21 let w = f.contentWindow; |
| 22 let e = w.document.body.lastChild; |
| 23 w.postMessage( |
| 24 e.localName == 'a-a' && |
| 25 Object.getPrototypeOf(e) === w.HTMLElement.prototype, |
| 26 '*'); |
| 27 } |
| 28 |
| 29 var p = new Promise((resolve) => { |
| 30 w.addEventListener('message', t.step_func((event) => { |
| 31 assert_true(event.data, |
| 32 'the custom element prototype should not appear in ' + |
| 33 'isolated worlds'); |
| 34 resolve(); |
| 35 })); |
| 36 }); |
| 37 |
| 38 class X extends w.HTMLElement {} |
| 39 w.customElements.define('a-a', X); |
| 40 w.document.body.appendChild(new X); |
| 41 |
| 42 testRunner.evaluateScriptInIsolatedWorld( |
| 43 1, |
| 44 `(${in_isolated_world.toString()})();`); |
| 45 |
| 46 return p; |
| 47 }); |
| 48 }, 'Retrieve a custom element in an isolated world'); |
| 49 |
| 50 // TODO(dominicc): Test retrieving a custom element that has not been wrapped |
| 51 // before in any world, when upgrades are implemented. |
| 52 |
| 53 promise_test((t) => { |
| 54 return create_window_in_test(t) |
| 55 .then((w) => { |
| 56 function in_isolated_world() { |
| 57 let f = document.querySelector('iframe'); |
| 58 let w = f.contentWindow; |
| 59 w.postMessage(`customElements=${w.customElements}`, '*'); |
| 60 } |
| 61 |
| 62 var p = new Promise((resolve) => { |
| 63 w.addEventListener('message', t.step_func((event) => { |
| 64 assert_equals(event.data, |
| 65 'customElements=null', |
| 66 'the customElements property should be null ' + |
| 67 'in isolated worlds'); |
| 68 resolve(); |
| 69 })); |
| 70 }); |
| 71 |
| 72 testRunner.evaluateScriptInIsolatedWorld( |
| 73 1, |
| 74 `(${in_isolated_world.toString()})();`); |
| 75 |
| 76 return p; |
| 77 }); |
| 78 }, 'No custom elements registry in isolated worlds'); |
| 79 |
| 80 })(); |
| 81 </script> |
OLD | NEW |