<!DOCTYPE html>
<meta charset="utf-8">
<title>TreeWalker: NodeFilter from detached iframe doesn't get called</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>

<body>
<div></div>

<script>
const t = async_test();

const iframe = document.createElement("iframe");
iframe.src = "support/TreeWalker-acceptNode-filter-cross-realm-null-browsing-context-subframe.html";
iframe.onload = t.step_func_done(() => {
    const nodeIterator = iframe.contentWindow.createNodeIterator();
    iframe.remove();

    assert_equals(iframe.contentWindow, null);

    let errorWasThrown = false;
    try { nodeIterator.nextNode(); }
    catch { errorWasThrown = true; }

    assert_true(errorWasThrown);
    assert_false(nodeIterator.dummyFilterCalled);
});

document.body.append(iframe);
</script>
