Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(726)

Unified Diff: third_party/WebKit/LayoutTests/custom-elements/spec/parsing.html

Issue 2369853002: HTML parser: implementing throw-on-dynamic-markup-insertion counter (Closed)
Patch Set: copyright comment update Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9826f8aab3b5bbf7f5161c8fb2d3a0c3f5c18f83 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.
// 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>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698