mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-05 06:32:30 +02:00
LibWeb/HTML: Move connectedness check for script post_connection()
Corresponds to:
905384d140
Also import the test added along with that change.
This commit is contained in:
Notes:
github-actions[bot]
2025-12-01 11:09:06 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/c0b8f47a76e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6960
@@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>A later-inserted script removed by an earlier-inserted script does not run</title>
|
||||
<script src=../../../resources/testharness.js></script>
|
||||
<script src=../../../resources/testharnessreport.js></script>
|
||||
<body>
|
||||
<script>
|
||||
|
||||
test(t => {
|
||||
const fragment = document.createDocumentFragment();
|
||||
// Global so they can be more easily accessed by the inner script blocks.
|
||||
window.script1 = fragment.appendChild(document.createElement("script"));
|
||||
window.script2 = fragment.appendChild(document.createElement("script"));
|
||||
|
||||
window.script2Run = false;
|
||||
t.add_cleanup(() => { window.script2Run = false; });
|
||||
script1.textContent = `
|
||||
assert_true(script2.isConnected, 'script2 is connected when script2 runs');
|
||||
script2.remove();
|
||||
`;
|
||||
script2.textContent = "window.script2Run = true;";
|
||||
|
||||
document.body.append(fragment);
|
||||
assert_false(window.script2Run, "script2 did not run");
|
||||
}, "A later-inserted script removed by an earlier-inserted script in the " +
|
||||
"same document fragment should not run");
|
||||
|
||||
test(t => {
|
||||
window.script1 = document.createElement("script");
|
||||
window.script2 = document.createElement("script");
|
||||
|
||||
window.script2Run = false;
|
||||
t.add_cleanup(() => { window.script2Run = false; });
|
||||
script1.textContent = `
|
||||
assert_true(script2.isConnected, 'script2 is connected when script2 runs');
|
||||
script2.remove();
|
||||
`;
|
||||
script2.textContent = "window.script2Run = true;";
|
||||
|
||||
document.body.append(script1, script2);
|
||||
assert_false(window.script2Run, "script2 did not run");
|
||||
}, "A later-inserted script removed by an earlier-inserted script in the " +
|
||||
"same append() call should not run");
|
||||
</script>
|
||||
</body>
|
||||
Reference in New Issue
Block a user