Bug 1559244 - Step 3: Add test for crashing an oop iframe. r=mconley

Differential Revision: https://phabricator.services.mozilla.com/D38896

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Abdoulaye O. Ly 2019-08-15 17:18:47 +00:00
Родитель 8aec5ed540
Коммит 463d67ede1
2 изменённых файлов: 92 добавлений и 0 удалений

Просмотреть файл

@ -4,6 +4,8 @@ support-files =
file_domainPolicy_base.html
file_cancel_content_js.html
[browser_crash_oopiframe.js]
skip-if = true # Disabled until bug 1566196 is fixed
[browser_domainPolicy.js]
skip-if = fission
[browser_memory_distribution_telemetry.js]

Просмотреть файл

@ -0,0 +1,90 @@
"use strict";
/**
* In this test, we crash an out-of-process iframe and
* verify that :
* 1. the "oop-browser-crashed" event is dispatched with
* the browsing context of the crashed oop subframe.
* 2. the crashed subframe is now pointing at "about:framecrashed"
* page.
*/
add_task(async function() {
// Open a new window with fission enabled.
let win = await BrowserTestUtils.openNewBrowserWindow({
remote: true,
fission: true,
});
// Wait for the provided URL to load in our browser.
let url = "about:blank";
let browser = win.gBrowser.selectedBrowser;
BrowserTestUtils.loadURI(browser, url);
await BrowserTestUtils.browserLoaded(browser, false, url);
let rootBC = browser.browsingContext;
// Create an oop iframe.
let iframeID = await SpecialPowers.spawn(browser, [], async () => {
let iframe = content.document.createElement("iframe");
iframe.setAttribute("fission", "true");
iframe.setAttribute("src", "http://example.com");
const { ContentTaskUtils } = ChromeUtils.import(
"resource://testing-common/ContentTaskUtils.jsm"
);
content.document.body.appendChild(iframe);
await ContentTaskUtils.waitForEvent(iframe, "load");
let iframeBC = iframe.frameLoader.browsingContext;
return iframeBC.id;
});
let iframeBC = BrowsingContext.get(iframeID);
is(iframeBC.parent, rootBC, "oop frame has root as parent");
BrowserTestUtils.crashFrame(
browser,
true /* shouldShowTabCrashPage */,
true /* shouldClearMinidumps */,
iframeBC
);
let eventFiredPromise = BrowserTestUtils.waitForEvent(
browser,
"oop-browser-crashed"
);
await eventFiredPromise.then(event => {
isnot(
event.browsingContextId,
rootBC,
"top frame browsing context id not expected."
);
is(
event.browsingContextId,
iframeBC.id,
"oop frame browsing context id expected."
);
});
info("Wait for a new browsing context to get attached to our oop iframe.");
await BrowserTestUtils.waitForCondition(
() => rootBC.getChildren()[0] != iframeBC
);
let newIframeBC = rootBC.getChildren()[0];
let newIframeURI = await SpecialPowers.spawn(
newIframeBC,
[],
() => content.document.documentURI
);
ok(
newIframeURI.startsWith("about:framecrashed"),
"The iframe is now pointing at about:framecrashed"
);
await BrowserTestUtils.closeWindow(win);
});