OLD | NEW |
(Empty) | |
| 1 <script> |
| 2 'use strict'; |
| 3 |
| 4 let constructors = []; |
| 5 |
| 6 test(() => { |
| 7 assert_equals(constructors.length, 0); |
| 8 |
| 9 class MyElement extends HTMLElement { |
| 10 constructor() { |
| 11 super(); |
| 12 constructors.push(this); |
| 13 } |
| 14 } |
| 15 |
| 16 customElements.define('a-a', MyElement); |
| 17 |
| 18 // createElement should synchronously call constructor. |
| 19 let a = document.createElement('a-a'); |
| 20 assert_equals(constructors.length, 1); |
| 21 assert_equals(a.ownerDocument, document); |
| 22 |
| 23 let importDoc = document.currentScript.ownerDocument; |
| 24 |
| 25 // TODO(kochi): crbug.com/640465 createElement returns wrong ownerDocument |
| 26 // createElement should work in imported document. |
| 27 let b = importDoc.createElement('a-a') |
| 28 assert_equals(b.ownerDocument, importDoc); |
| 29 assert_equals(constructors.length, 2); |
| 30 |
| 31 // new MyElement() should synchronously call constructor. |
| 32 let c = new MyElement(); |
| 33 assert_equals(c.ownerDocument, document); |
| 34 assert_equals(constructors.length, e); |
| 35 |
| 36 assert_array_equals(constructors, [a, b, c]); |
| 37 }, 'createElement() and new MyElement should work in imported document.'); |
| 38 </script> |
OLD | NEW |