| 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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 | 348 |
| 349 // 14.9.3 If observedAttributesIterable is not undefined, then set observedAttri
butes | 349 // 14.9.3 If observedAttributesIterable is not undefined, then set observedAttri
butes |
| 350 // to the result of converting observedAttributesIterable to a sequence<D
OMString>. | 350 // to the result of converting observedAttributesIterable to a sequence<D
OMString>. |
| 351 // Rethrow any exceptions. | 351 // Rethrow any exceptions. |
| 352 test_with_window((w) => { | 352 test_with_window((w) => { |
| 353 let invocations = []; | 353 let invocations = []; |
| 354 let element = w.document.createElement('a-a'); | 354 let element = w.document.createElement('a-a'); |
| 355 element.setAttribute('a', '1'); | 355 element.setAttribute('a', '1'); |
| 356 element.setAttribute('b', '2'); | 356 element.setAttribute('b', '2'); |
| 357 element.setAttribute('c', '3'); | 357 element.setAttribute('c', '3'); |
| 358 let constructor = function () {}; | 358 let constructor = function () { |
| 359 constructor.prototype.attributeChangedCallback = function () { | 359 return Reflect.construct(w.HTMLElement, [], constructor); |
| 360 invocations.push(arguments[0]); | 360 }; |
| 361 constructor.prototype.attributeChangedCallback = function () { |
| 362 invocations.push(arguments[0]); |
| 361 }; | 363 }; |
| 362 constructor.observedAttributes = {[Symbol.iterator]: | 364 constructor.observedAttributes = {[Symbol.iterator]: |
| 363 function* () { | 365 function* () { |
| 364 yield 'a'; | 366 yield 'a'; |
| 365 yield 'c'; | 367 yield 'c'; |
| 366 } | 368 } |
| 367 }; | 369 }; |
| 368 w.customElements.define('a-a', constructor); | 370 w.customElements.define('a-a', constructor); |
| 369 w.document.body.appendChild(element); | 371 w.document.body.appendChild(element); |
| 370 assert_array_equals(invocations, ['a', 'c'], 'attributeChangedCallback should
be invoked twice for "a" and "c"'); | 372 assert_array_equals(invocations, ['a', 'c'], 'attributeChangedCallback should
be invoked twice: once for "a" and once for "c"'); |
| 371 }, 'ObservedAttributes are retrieved from iterators'); | 373 }, 'ObservedAttributes are retrieved from iterators'); |
| 372 | 374 |
| 373 test_with_window((w) => { | 375 test_with_window((w) => { |
| 374 let constructor = function () {}; | 376 let constructor = function () {}; |
| 375 constructor.prototype.attributeChangedCallback = function () { }; | 377 constructor.prototype.attributeChangedCallback = function () { }; |
| 376 constructor.observedAttributes = {[Symbol.iterator]: 1}; | 378 constructor.observedAttributes = {[Symbol.iterator]: 1}; |
| 377 assert_throws(TypeError.prototype, () => { | 379 assert_throws(TypeError.prototype, () => { |
| 378 w.customElements.define('a-a', constructor); | 380 w.customElements.define('a-a', constructor); |
| 379 }, 'converting value that is not an object should throw TypeError'); | 381 }, 'converting value that is not an object should throw TypeError'); |
| 380 }, 'Converting non-object observedAttributes to sequence<DOMString>'); | 382 }, 'Converting non-object observedAttributes to sequence<DOMString>'); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 static get observedAttributes() { | 424 static get observedAttributes() { |
| 423 return attributes; | 425 return attributes; |
| 424 } | 426 } |
| 425 } | 427 } |
| 426 assert_throws(TypeError.prototype, () => { | 428 assert_throws(TypeError.prototype, () => { |
| 427 w.customElements.define('x-x', X); | 429 w.customElements.define('x-x', X); |
| 428 }); | 430 }); |
| 429 }, 'Throwing an exception in observedAttributes'); | 431 }, 'Throwing an exception in observedAttributes'); |
| 430 </script> | 432 </script> |
| 431 </body> | 433 </body> |
| OLD | NEW |