From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- ...up-insertion-counter-construct-xml-parser.xhtml | 134 +++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 testing/web-platform/tests/custom-elements/throw-on-dynamic-markup-insertion-counter-construct-xml-parser.xhtml (limited to 'testing/web-platform/tests/custom-elements/throw-on-dynamic-markup-insertion-counter-construct-xml-parser.xhtml') diff --git a/testing/web-platform/tests/custom-elements/throw-on-dynamic-markup-insertion-counter-construct-xml-parser.xhtml b/testing/web-platform/tests/custom-elements/throw-on-dynamic-markup-insertion-counter-construct-xml-parser.xhtml new file mode 100644 index 0000000000..c0a7f622fb --- /dev/null +++ b/testing/web-platform/tests/custom-elements/throw-on-dynamic-markup-insertion-counter-construct-xml-parser.xhtml @@ -0,0 +1,134 @@ + + + +Custom Elements: create an element for a token must increment and decrement document's throw-on-dynamic-markup-insertion counter + + + + + + + + + +
+ + +`); + let content_document; + try { + content_document = content_window.document; + } catch (error) { } + assert_true(executed, 'Must synchronously instantiate a custom element'); + return {window: content_window, document: content_document, exception}; +} + +promise_test(async function () { + const result = await construct_custom_element_in_parser(this, `document.open()`); + assert_throws_dom('InvalidStateError', result.window.DOMException, () => { throw result.exception; }, 'Must throw an InvalidStateError'); + }, 'document.open() must throw an InvalidStateError when synchronously constructing a custom element'); + +promise_test(async function () { + const result = await construct_custom_element_in_parser(this, `document.open('text/html')`); + assert_throws_dom('InvalidStateError', result.window.DOMException, () => { throw result.exception; }, 'Must throw an InvalidStateError'); +}, 'document.open("text/html") must throw an InvalidStateError when synchronously constructing a custom element'); + +// https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-document-open-window +promise_test(async function () { + let load_promise = new Promise((resolve) => window.onmessage = (event) => resolve(event.data)); + const url = top.location.href.substring(0, top.location.href.lastIndexOf('/')) + '/resources/navigation-destination.html'; + const result = await construct_custom_element_in_parser(this, `document.open('${url}', '_self', '')`); + assert_equals(result.exception, null); + assert_equals(await load_promise, 'didNavigate'); +}, 'document.open(URL) must NOT throw an InvalidStateError when synchronously constructing a custom element'); + +promise_test(async function () { + const result = await construct_custom_element_in_parser(this, `document.close()`); + assert_not_equals(result.exception, null); + assert_throws_dom('InvalidStateError', result.window.DOMException, () => { throw result.exception; }, 'Must throw an InvalidStateError'); +}, 'document.close() must throw an InvalidStateError when synchronously constructing a custom element'); + +promise_test(async function () { + const result = await construct_custom_element_in_parser(this, `document.write('some text')`); + assert_throws_dom('InvalidStateError', result.window.DOMException, () => { throw result.exception; }, 'Must throw an InvalidStateError'); + assert_equals(result.document.querySelector('b'), null, 'Must not insert new content'); + assert_false(result.document.body.innerHTML.includes('some text'), 'Must not insert new content'); +}, 'document.write must throw an InvalidStateError when synchronously constructing a custom element'); + +promise_test(async function () { + const result = await construct_custom_element_in_parser(this, `document.writeln('some text')`); + assert_throws_dom('InvalidStateError', result.window.DOMException, () => { throw result.exception; }, 'Must throw an InvalidStateError'); + assert_equals(result.document.querySelector('b'), null, 'Must not insert new content'); + assert_false(result.document.body.innerHTML.includes('some text'), 'Must not insert new content'); +}, 'document.writeln must throw an InvalidStateError when synchronously constructing a custom element'); + +promise_test(async function () { + window.another_window = await create_window_in_test_async(this, 'text/html', ''); + const result = await construct_custom_element_in_parser(this, `top.another_window.document.open()`); + assert_equals(result.exception, null); +}, 'document.open() of another document must not throw an InvalidStateError when synchronously constructing a custom element'); + +promise_test(async function () { + window.another_window = await create_window_in_test_async(this, 'text/html', ''); + const result = await construct_custom_element_in_parser(this, `top.another_window.document.open('text/html')`); + assert_equals(result.exception, null); +}, 'document.open("text/html") of another document must not throw an InvalidStateError when synchronously constructing a custom element'); + +promise_test(async function () { + window.another_window = await create_window_in_test_async(this, 'text/html', ''); + const result = await construct_custom_element_in_parser(this, `top.another_window.document.close()`); + assert_equals(result.exception, null); +}, 'document.close() of another document must not throw an InvalidStateError when synchronously constructing a custom element'); + +promise_test(async function () { + window.another_window = await create_window_in_test_async(this, 'text/html', ''); + const result = await construct_custom_element_in_parser(this, `top.another_window.document.write('some text')`); + assert_equals(result.exception, null); + assert_equals(another_window.document.querySelector('b').outerHTML, 'some text'); +}, 'document.write of another document must not throw an InvalidStateError when synchronously constructing a custom element'); + +promise_test(async function () { + window.another_window = await create_window_in_test_async(this, 'text/html', ''); + const result = await construct_custom_element_in_parser(this, `top.another_window.document.writeln('some text')`); + assert_equals(result.exception, null); + assert_equals(another_window.document.querySelector('b').outerHTML, 'some text'); +}, 'document.writeln of another document must not throw an InvalidStateError when synchronously constructing a custom element'); + +]]> + + + -- cgit v1.2.3