Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /dom/traversal/TreeWalker-realm.html - WPT Dashboard Interop Dashboard
<!doctype html>
<title>TreeWalker tests</title>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<body>
<script>
test(t => {
const i = document.createElement("iframe");
i.srcdoc = "<!DOCTYPE html>";
document.body.appendChild(i);
t.add_cleanup(() => i.remove());
const walker = document.createTreeWalker(i.contentDocument,
NodeFilter.SHOW_ELEMENT);
walker.nextNode();
assert_true(walker.currentNode instanceof i.contentWindow.Node);
}, "Node returned by TreeWalker from different realm");
test(t => {
const i = document.createElement("iframe");
i.srcdoc = "<!DOCTYPE html>";
document.body.appendChild(i);
t.add_cleanup(() => i.remove());
let acceptNode_node;
const walker = document.createTreeWalker(
i.contentDocument, NodeFilter.SHOW_ELEMENT,
{
acceptNode(node) {
acceptNode_node = node;
return NodeFilter.FILTER_ACCEPT;
}
});
walker.nextNode();
assert_true(acceptNode_node instanceof i.contentWindow.Node);
assert_true(walker.currentNode instanceof i.contentWindow.Node);
}, "Node returned by TreeWalker from different realm with acceptNode");
</script>
</body>