-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HTML: document.open() event listener removal #10686
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
test(t => { | ||
const frame = document.body.appendChild(document.createElement("iframe")), | ||
body = frame.contentDocument.body; | ||
t.add_cleanup(() => frame.remove()); | ||
frame.contentDocument.addEventListener("x", t.unreached_func()); | ||
body.addEventListener("x", t.unreached_func()); | ||
frame.contentDocument.open(); | ||
frame.contentDocument.close(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The "close()" here seems not great since if someone implemented close() as removing the event listeners the test would still pass. |
||
frame.contentDocument.dispatchEvent(new Event("x")); | ||
body.dispatchEvent(new Event("x")); | ||
}, "Event listeners are to be removed"); | ||
|
||
test(t => { | ||
const frame = document.body.appendChild(document.createElement("iframe")); | ||
t.add_cleanup(() => frame.remove()); | ||
let once = false; | ||
frame.contentDocument.addEventListener("x", () => { | ||
frame.contentDocument.open(); | ||
frame.contentDocument.close(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same concern about |
||
once = true; | ||
}); | ||
frame.contentDocument.addEventListener("x", t.unreached_func()); | ||
frame.contentDocument.dispatchEvent(new Event("x")); | ||
assert_true(once); | ||
}, "Event listeners are to be removed with immediate effect"); | ||
|
||
test(t => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might be worth gating this behind an There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's bad practice. It makes it less clear what's going on. And have a varying number of tests between browsers, if that's what you're suggesting, seems even worse for tooling. |
||
const frame = document.body.appendChild(document.createElement("iframe")), | ||
shadow = frame.contentDocument.body.attachShadow({ mode: "closed" }), | ||
shadowChild = shadow.appendChild(document.createElement("div")), | ||
shadowShadow = shadowChild.attachShadow({ mode: "open" }), | ||
nodes = [shadow, shadowChild, shadowShadow]; | ||
t.add_cleanup(() => frame.remove()); | ||
nodes.forEach(node => { | ||
node.addEventListener("x", t.unreached_func()); | ||
}); | ||
frame.contentDocument.open(); | ||
frame.contentDocument.close(); | ||
nodes.forEach(node => { | ||
node.dispatchEvent(new Event("x")); | ||
}); | ||
}, "Event listeners are to be removed from shadow trees as well"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding descriptions to unreached_funcs makes test failures much easier to diagnose.