зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1676181 - Fix docshell/test/browser/browser_browsingContext-01.js for Fission, r=farre
Differential Revision: https://phabricator.services.mozilla.com/D111442
This commit is contained in:
Родитель
2e1f01547a
Коммит
7decb1d196
|
@ -169,7 +169,6 @@ skip-if = true # Bug 1220415
|
|||
[browser_history_triggeringprincipal_viewsource.js]
|
||||
[browser_click_link_within_view_source.js]
|
||||
[browser_browsingContext-01.js]
|
||||
skip-if = sessionHistoryInParent
|
||||
[browser_browsingContext-02.js]
|
||||
[browser_browsingContext-getAllBrowsingContextsInSubtree.js]
|
||||
[browser_browsingContext-getWindowByName.js]
|
||||
|
|
|
@ -112,6 +112,9 @@ add_task(async function() {
|
|||
});
|
||||
|
||||
add_task(async function() {
|
||||
// If Fission is disabled, the pref is no-op.
|
||||
await SpecialPowers.pushPrefEnv({ set: [["fission.bfcacheInParent", true]] });
|
||||
|
||||
await BrowserTestUtils.withNewTab(
|
||||
{
|
||||
gBrowser,
|
||||
|
@ -127,78 +130,46 @@ add_task(async function() {
|
|||
"http://example.com"
|
||||
);
|
||||
await SpecialPowers.spawn(browser, [path], async function(path) {
|
||||
var bc = new content.BroadcastChannel("browser_browsingContext");
|
||||
function waitForMessage(command) {
|
||||
let r;
|
||||
let p = new Promise(resolve => {
|
||||
content.window.addEventListener(
|
||||
"message",
|
||||
e => resolve({ result: r, event: e }),
|
||||
{ once: true }
|
||||
);
|
||||
bc.addEventListener("message", e => resolve(e), { once: true });
|
||||
});
|
||||
r = command();
|
||||
command();
|
||||
return p;
|
||||
}
|
||||
|
||||
// Open a new window and wait for the message.
|
||||
let { result: win, event: e1 } = await waitForMessage(_ =>
|
||||
content.window.open(path + "onpageshow_message.html")
|
||||
let e1 = await waitForMessage(_ =>
|
||||
content.window.open(path + "onpageshow_message.html", "", "noopener")
|
||||
);
|
||||
|
||||
is(e1.data, "pageshow");
|
||||
is(e1.data, "pageshow", "Got page show");
|
||||
|
||||
{
|
||||
// Create, attach and load an iframe into the window's document.
|
||||
let frame = win.document.createElement("iframe");
|
||||
win.document.body.appendChild(frame);
|
||||
frame.src = "dummy_page.html";
|
||||
await ContentTaskUtils.waitForEvent(frame, "load");
|
||||
}
|
||||
let e2 = await waitForMessage(_ => bc.postMessage("createiframe"));
|
||||
is(e2.data.framesLength, 1, "Here we should have an iframe");
|
||||
|
||||
is(win.frames.length, 1, "Here we should have an iframe");
|
||||
let e3 = await waitForMessage(_ => bc.postMessage("nextpage"));
|
||||
|
||||
// The frame should have expected browsing context and docshell.
|
||||
let frameBC = win.frames[0].docShell.browsingContext;
|
||||
let winDocShell = win.frames[0].docShell;
|
||||
|
||||
// Navigate the window and wait for the message.
|
||||
let { event: e2 } = await waitForMessage(
|
||||
_ => (win.location = path + "onload_message.html")
|
||||
);
|
||||
|
||||
is(e2.data, "load");
|
||||
is(win.frames.length, 0, "Here there shouldn't be an iframe");
|
||||
is(e3.data.event, "load");
|
||||
is(e3.data.framesLength, 0, "Here there shouldn't be an iframe");
|
||||
|
||||
// Return to the previous document. N.B. we expect to trigger
|
||||
// BFCache here, hence we wait for pageshow.
|
||||
let { event: e3 } = await waitForMessage(_ => win.history.back());
|
||||
let e4 = await waitForMessage(_ => bc.postMessage("back"));
|
||||
|
||||
is(e3.data, "pageshow");
|
||||
is(win.frames.length, 1, "And again there should be an iframe");
|
||||
is(e4.data, "pageshow");
|
||||
|
||||
is(winDocShell, win.frames[0].docShell, "BF cache cached docshell");
|
||||
is(
|
||||
frameBC,
|
||||
win.frames[0].docShell.browsingContext,
|
||||
"BF cache cached BC"
|
||||
);
|
||||
is(
|
||||
frameBC.id,
|
||||
win.frames[0].docShell.browsingContext.id,
|
||||
"BF cached BC's have same id"
|
||||
);
|
||||
is(
|
||||
win.docShell.browsingContext.children[0],
|
||||
frameBC,
|
||||
"BF cached BC's should still be a child of its parent"
|
||||
);
|
||||
is(
|
||||
win.docShell.browsingContext,
|
||||
frameBC.parent,
|
||||
"BF cached BC's should still be a connected to its parent"
|
||||
);
|
||||
let e5 = await waitForMessage(_ => bc.postMessage("queryframes"));
|
||||
is(e5.data.framesLength, 1, "And again there should be an iframe");
|
||||
|
||||
win.close();
|
||||
is(e5.outerWindowId, e2.outerWindowId, "BF cache cached outer window");
|
||||
is(e5.browsingContextId, e2.browsingContextId, "BF cache cached BC");
|
||||
|
||||
let e6 = await waitForMessage(_ => bc.postMessage("close"));
|
||||
is(e6.data, "closed");
|
||||
|
||||
bc.close();
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -2,14 +2,24 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<script>
|
||||
if (opener) {
|
||||
addEventListener("load", function() {
|
||||
opener.postMessage("load", "*");
|
||||
// This file is used in couple of different tests.
|
||||
if (opener) {
|
||||
opener.postMessage("load", "*");
|
||||
} else {
|
||||
var bc = new BroadcastChannel("browser_browsingContext");
|
||||
bc.onmessage = function(event) {
|
||||
if (event.data == "back") {
|
||||
bc.close();
|
||||
history.back();
|
||||
}
|
||||
};
|
||||
bc.postMessage({event: "load", framesLength: frames.length });
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
This file posts a message containing "load" to opener on load completion.
|
||||
This file posts a message containing "load" to opener or BroadcastChannel on load completion.
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -3,11 +3,39 @@
|
|||
<meta charset="utf-8">
|
||||
<script>
|
||||
addEventListener("pageshow", function() {
|
||||
opener.postMessage("pageshow", "*");
|
||||
var bc = new BroadcastChannel("browser_browsingContext");
|
||||
function frameData() {
|
||||
var win = SpecialPowers.wrap(frames[0]);
|
||||
bc.postMessage(
|
||||
{ framesLength: frames.length,
|
||||
browsingContextId: win.docShell.browsingContext.id,
|
||||
outerWindowId: win.docShell.outerWindowID
|
||||
});
|
||||
}
|
||||
|
||||
bc.onmessage = function(event) {
|
||||
if (event.data == "createiframe") {
|
||||
let frame = document.createElement("iframe");
|
||||
frame.src = "dummy_page.html";
|
||||
document.body.appendChild(frame);
|
||||
frame.onload = frameData;
|
||||
} else if (event.data == "nextpage") {
|
||||
bc.close();
|
||||
location.href = "onload_message.html";
|
||||
} else if (event.data == "queryframes") {
|
||||
frameData();
|
||||
} else if (event.data == "close") {
|
||||
bc.postMessage("closed");
|
||||
bc.close();
|
||||
window.close();
|
||||
}
|
||||
}
|
||||
bc.postMessage("pageshow");
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
This file posts a message containing "pageshow" to opener on pageshow.
|
||||
This file posts a message containing "pageshow" to a BroadcastChannel and
|
||||
keep the channel open for commands.
|
||||
</body>
|
||||
</html>
|
||||
|
|
Загрузка…
Ссылка в новой задаче