Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html |
| diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html b/third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html |
| index e6b3842870b1a0607f3fa1db488604b4d26bccd6..7a502daa56cb70787261821e48bd9e68919f0578 100644 |
| --- a/third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html |
| +++ b/third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html |
| @@ -124,12 +124,18 @@ test_with_content((w) => { |
| <script> |
| // Custom element constructors do not set the insertion point, which |
| // makes document.write() "destructive." However they increment the |
| - // ignore-destructive-writes counter, which blocks document.write. |
| + // throw-on-dynamic-insertion counter, which blocks document.write and |
| + // throws "InvalidStateError"DOMException. |
|
dominicc (has gone to gerrit)
2016/09/28 08:01:03
Space before D
|
| // https://html.spec.whatwg.org/#create-an-element-for-the-token |
| - // https://github.com/whatwg/html/issues/1630 |
| // https://html.spec.whatwg.org/#document.write() |
| 'use strict'; |
| + window.errors = []; |
| + window.onerror = function (event, source, lineno, colno, error) { |
| + errors.push(error.name); |
| + return true; // Cancel the error event. |
| + }; |
| + |
| window.invocations = []; |
| customElements.define('a-a', class extends HTMLElement { |
| constructor() { |
| @@ -155,20 +161,31 @@ test_with_content((w) => { |
| test_with_content((w) => { |
| assert_array_equals( |
| w.invocations, |
| - ['constructor', 'connected', 'parsed'], |
| - 'the destructive document.write content should have been ignored'); |
| + ['constructor', 'parsed'], |
| + 'the destructive document.write content should have been ignored; ' + |
| + 'connectedCallback should not be executed, since the constructor threw'); |
| + assert_array_equals( |
| + w.errors, |
| + ['InvalidStateError'], |
| + 'create an element for the token should report the exception'); |
| }); |
| </script> |
| <template data-test="non-destructive writes are not blocked"> |
| <script> |
| // Script running sets the insertion point, which makes makes |
| - // document.write() "non-destructive." Custom elements do not block |
| + // document.write() "non-destructive." Custom elements should block |
| // non-destructive writes. |
| // https://html.spec.whatwg.org/#create-an-element-for-the-token |
| // https://html.spec.whatwg.org/#document.write() |
| 'use strict'; |
| + window.errors = []; |
| + window.onerror = function (event, source, lineno, colno, error) { |
| + errors.push(error.name); |
| + return true; // Cancel the error event. |
| + }; |
| + |
| window.invocations = []; |
| customElements.define('a-a', class extends HTMLElement { |
| constructor() { |
| @@ -195,8 +212,13 @@ test_with_content((w) => { |
| test_with_content((w) => { |
| assert_array_equals( |
| w.invocations, |
| - ['constructor', 'connected', 'post write', 'written', 'parsed'], |
| - 'the non-destructive document.write content should have been inserted'); |
| + ['constructor', 'post write', 'parsed'], |
| + 'the non-destructive document.write content should have been ignored' + |
| + 'connectedCallback should not be executed, since the constructor threw'); |
| + assert_array_equals( |
| + w.errors, |
| + ['InvalidStateError'], |
| + 'create an element for the token should report the exception'); |
| }); |
| </script> |