| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Custom Elements: defineElement</title> | 2 <title>Custom Elements: defineElement</title> |
| 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#cus
tomelementsregistry"> | 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#cus
tomelementsregistry"> |
| 4 <meta name="author" title="Dominic Cooney" href="mailto:dominicc@chromium.org"> | 4 <meta name="author" title="Dominic Cooney" href="mailto:dominicc@chromium.org"> |
| 5 <script src="../../resources/testharness.js"></script> | 5 <script src="../../resources/testharness.js"></script> |
| 6 <script src="../../resources/testharnessreport.js"></script> | 6 <script src="../../resources/testharnessreport.js"></script> |
| 7 <script src="resources/custom-elements-helpers.js"></script> | 7 <script src="resources/custom-elements-helpers.js"></script> |
| 8 <body> | 8 <body> |
| 9 <script> | 9 <script> |
| 10 // TODO(dominicc): Merge these tests with | 10 // TODO(dominicc): Merge these tests with |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 w.customElements.define('a-a', X); | 84 w.customElements.define('a-a', X); |
| 85 assert_throws_dom_exception(w, 'NotSupportedError', () => { | 85 assert_throws_dom_exception(w, 'NotSupportedError', () => { |
| 86 w.customElements.define('a-b', X); | 86 w.customElements.define('a-b', X); |
| 87 }, 'defining an element with a constructor that is already in the ' + | 87 }, 'defining an element with a constructor that is already in the ' + |
| 88 'registry should throw a NotSupportedError'); | 88 'registry should throw a NotSupportedError'); |
| 89 }, 'Reused constructor'); | 89 }, 'Reused constructor'); |
| 90 | 90 |
| 91 promise_test((t) => { | 91 promise_test((t) => { |
| 92 return Promise.all([create_window_in_test(t), create_window_in_test(t)]) | 92 return Promise.all([create_window_in_test(t), create_window_in_test(t)]) |
| 93 .then(([w1, w2]) => { | 93 .then(([w1, w2]) => { |
| 94 class X extends w2.HTMLElement { }; | 94 class X extends w1.HTMLElement { }; |
| 95 w1.customElements.define('first-name', X); | 95 w1.customElements.define('first-name', X); |
| 96 w2.customElements.define('second-name', X); | 96 w2.customElements.define('second-name', X); |
| 97 assert_equals( | 97 assert_equals( |
| 98 new X().localName, 'second-name', | 98 new X().localName, 'first-name', |
| 99 'the current global object should determine which definition is ' + | 99 'the current global object should determine which definition is ' + |
| 100 'operative; because X extends w2.HTMLElement, w2 is operative'); | 100 'operative; because X extends w1.HTMLElement, w1 is operative'); |
| 101 }); | 101 }); |
| 102 }, 'HTMLElement constructor looks up definitions in the current global-' + | 102 }, 'HTMLElement constructor looks up definitions in the current global-' + |
| 103 'reused constructor'); | 103 'reused constructor'); |
| 104 | 104 |
| 105 promise_test((t) => { | 105 promise_test((t) => { |
| 106 return Promise.all([create_window_in_test(t), create_window_in_test(t)]) | 106 return Promise.all([create_window_in_test(t), create_window_in_test(t)]) |
| 107 .then(([w1, w2]) => { | 107 .then(([w1, w2]) => { |
| 108 class X extends w2.HTMLElement { }; | 108 class X extends w2.HTMLElement { }; |
| 109 w1.customElements.define('x-x', X); | 109 w1.customElements.define('x-x', X); |
| 110 assert_throws( | 110 assert_throws( |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 static get observedAttributes() { | 424 static get observedAttributes() { |
| 425 return attributes; | 425 return attributes; |
| 426 } | 426 } |
| 427 } | 427 } |
| 428 assert_throws(TypeError.prototype, () => { | 428 assert_throws(TypeError.prototype, () => { |
| 429 w.customElements.define('x-x', X); | 429 w.customElements.define('x-x', X); |
| 430 }); | 430 }); |
| 431 }, 'Throwing an exception in observedAttributes'); | 431 }, 'Throwing an exception in observedAttributes'); |
| 432 </script> | 432 </script> |
| 433 </body> | 433 </body> |
| OLD | NEW |