mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
1722817403
There are all sorts of lifecycle issues which arise from making DocShell responsible for discarding BrowsingContexts. In this particular bug, we tend to run into them in cases where we create a BrowsingContext for a FrameLoader, and then never create a DocShell for it, leading to it never being destroyed. But there are myriad other issues as well. This patch moves the responsibility for BrowsingContext lifecycle management to the FrameLoader/FrameLoaderOwner, rather than the DocShell, which makes things more consistent, and more closely aligns with spec-defined behavior. Differential Revision: https://phabricator.services.mozilla.com/D59008 --HG-- extra : moz-landing-system : lando
44 lines
1.3 KiB
HTML
44 lines
1.3 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<title>Discard a new BrowsingContext during window.open nested event loop</title>
|
|
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
|
|
</head>
|
|
<body>
|
|
<script>
|
|
add_task(async function() {
|
|
const TOPIC = "dangerous:test-only:new-browser-child-ready";
|
|
|
|
let found = false;
|
|
function observer(subject, topic, data) {
|
|
let win = SpecialPowers.wrap(subject);
|
|
if (SpecialPowers.compare(win.opener, window)) {
|
|
found = true;
|
|
SpecialPowers.removeObserver(observer, TOPIC);
|
|
|
|
win.close();
|
|
// window.close() is not synchronous, so we need to wait for the
|
|
// BrowsingContext to actually become discarded after we call it, to
|
|
// make sure that the window provider actually has a discarded BC at the
|
|
// end of its own nested event loop.
|
|
SpecialPowers.Services.tm.spinEventLoopUntil(() => {
|
|
try {
|
|
return !win.opener;
|
|
} catch (e) {
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
SpecialPowers.addObserver(observer, TOPIC);
|
|
|
|
let win = window.open();
|
|
|
|
is(found, true, "Our observer should have fired for the new window");
|
|
is(win, null, "window.open() should return null when new window is already closed");
|
|
});
|
|
</script>
|
|
</body>
|
|
</html>
|