mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-27 18:17:22 +02:00
Tests: Add getElementById mutation and shadow-root routing tests
Add focused coverage for the ElementByIdMap that is easy to regress while optimizing lookup paths. The dynamic mutations test verifies duplicate id tree order semantics remain correct after reordering, id changes, removals, and reintroduction. The shadow root routing test verifies lookups stay routed to the correct scope when an element with an id is removed and moved across shadow roots and into the document.
This commit is contained in:
committed by
Andreas Kling
parent
7cc973fa77
commit
a0768e9bac
Notes:
github-actions[bot]
2026-02-21 12:56:57 +00:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/LadybirdBrowser/ladybird/commit/a0768e9bac6 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8055
@@ -0,0 +1,32 @@
|
||||
<!DOCTYPE html>
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
let host1 = document.createElement("div");
|
||||
let host2 = document.createElement("div");
|
||||
document.body.append(host1, host2);
|
||||
|
||||
let shadow1 = host1.attachShadow({ mode: "open" });
|
||||
let shadow2 = host2.attachShadow({ mode: "open" });
|
||||
|
||||
let node = document.createElement("span");
|
||||
node.id = "foo";
|
||||
shadow1.append(node);
|
||||
|
||||
shadow1.getElementById("foo");
|
||||
|
||||
println(`shadow1 has foo initially: ${shadow1.getElementById("foo") === node}`);
|
||||
|
||||
node.remove();
|
||||
println(`shadow1 has foo after remove: ${shadow1.getElementById("foo") === null}`);
|
||||
|
||||
shadow2.append(node);
|
||||
println(`shadow1 has foo after move: ${shadow1.getElementById("foo") === null}`);
|
||||
println(`shadow2 has foo after move: ${shadow2.getElementById("foo") === node}`);
|
||||
println(`document has foo while in shadow: ${document.getElementById("foo") === null}`);
|
||||
|
||||
document.body.append(node);
|
||||
println(`shadow2 has foo after moving to document: ${shadow2.getElementById("foo") === null}`);
|
||||
println(`document has foo after move: ${document.getElementById("foo") === node}`);
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user