diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:33 +0000 |
commit | 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 (patch) | |
tree | a4f824bd33cb075dd5aa3eb5a0a94af221bbe83a /testing/web-platform/tests/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-style.tentative.html | |
parent | Adding debian version 124.0.1-1. (diff) | |
download | firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.tar.xz firefox-086c044dc34dfc0f74fbe41f4ecb402b2cd34884.zip |
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-style.tentative.html')
-rw-r--r-- | testing/web-platform/tests/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-style.tentative.html | 118 |
1 files changed, 118 insertions, 0 deletions
diff --git a/testing/web-platform/tests/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-style.tentative.html b/testing/web-platform/tests/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-style.tentative.html new file mode 100644 index 0000000000..d3365f8a5e --- /dev/null +++ b/testing/web-platform/tests/dom/nodes/insertion-removing-steps/Node-appendChild-script-and-style.tentative.html @@ -0,0 +1,118 @@ +<!doctype html> +<meta charset=utf-8> +<title>Node.appendChild: inserting a script and a style where the script modifies the style</title> +<script src=/resources/testharness.js></script> +<script src=/resources/testharnessreport.js></script> +<body> +<script> +// <script> & <style> element tests. +test(() => { + window.happened = []; + window.style = document.createElement("style"); + let styleSheet = null; + + style.appendChild(new Text("body {}")); + const script = document.createElement("script"); + script.textContent = ` + styleSheet = style.sheet; + happened.push(style.sheet ? "sheet" : null); + style.appendChild(new Text("body {}")); + happened.push(style.sheet?.cssRules.length); + `; + + const div = document.createElement("div"); + div.appendChild(script); + div.appendChild(style); + + assert_array_equals(happened, []); + document.body.appendChild(div); + assert_array_equals(happened, ["sheet", 2]); + assert_not_equals(style.sheet, styleSheet, "style sheet was created only once"); +}, "An earlier-inserted <script> synchronously observes a later-inserted " + + "<style> (via a div) being applied"); + +test(() => { + window.happened = []; + window.style = document.createElement("style"); + let styleSheet = null; + + style.appendChild(new Text("body {}")); + const script = document.createElement("script"); + script.textContent = ` + styleSheet = style.sheet; + happened.push(style.sheet ? "sheet" : null); + style.appendChild(new Text("body {}")); + happened.push(style.sheet?.cssRules.length); +`; + + const df = document.createDocumentFragment(); + df.appendChild(script); + df.appendChild(style); + + assert_array_equals(happened, []); + document.body.appendChild(df); + assert_array_equals(happened, ["sheet", 2]); + assert_not_equals(style.sheet, styleSheet, "style sheet was created only once"); +}, "An earlier-inserted <script> synchronously observes a later-inserted " + + "<style> (via a DocumentFragment) being applied"); + +// <script> & <link rel=stylesheet> element tests. +test(() => { + window.happened = []; + window.link = document.createElement("link"); + link.rel = "stylesheet"; + link.href = "data:text/css,"; + + const script = document.createElement("script"); + script.textContent = ` + happened.push(link.sheet ? "sheet" : null); + `; + + const df = document.createDocumentFragment(); + df.appendChild(script); + df.appendChild(link); + + assert_array_equals(happened, []); + document.body.appendChild(df); + assert_array_equals(happened, ["sheet"]); +}, "Earlier-inserted <script> (via a DocumentFragment) synchronously " + + "observes a later-inserted <link rel=stylesheet>'s CSSStyleSheet creation"); + +test(() => { + window.happened = []; + window.link = document.createElement("link"); + link.rel = "stylesheet"; + link.href = "data:text/css,"; + + const script = document.createElement("script"); + script.textContent = ` + happened.push(link.sheet ? "sheet" : null); +`; + + const div = document.createElement("div"); + div.appendChild(script); + div.appendChild(link); + + assert_array_equals(happened, []); + document.body.appendChild(div); + assert_array_equals(happened, ["sheet"]); +}, "Earlier-inserted <script> (via a div) synchronously observes a " + + "later-inserted <link rel=stylesheet>'s CSSStyleSheet creation"); + +test(() => { + window.happened = []; + window.link = document.createElement("link"); + link.rel = "stylesheet"; + link.href = "data:text/css,"; + + const script = document.createElement("script"); + script.textContent = ` + happened.push(link.sheet ? "sheet" : null); +`; + + assert_array_equals(happened, []); + document.body.append(script, link); + assert_array_equals(happened, ["sheet"]); +}, "Earlier-inserted <script> (via a append()) synchronously observes a " + + "later-inserted <link rel=stylesheet>'s CSSStyleSheet creation"); +</script> |