Bug 1559244 - Step 3: Add test for crashing an oop iframe. r=mconley
☠☠ backed out by fa80b89e0ce4 ☠ ☠
authorAbdoulaye O. Ly <ablayelyfondou@gmail.com>
Thu, 15 Aug 2019 17:18:47 +0000
changeset 488318 1ce7d9bbe7a1bb01a5f4fb57882b5291b5b7f7c2
parent 488317 dced8cea7b23c28a0e2b66b51a4b022fdec2c1d1
child 488319 d13f6714fc1360ca24b6f5daefa1fbeb314d0cc5
push id113906
push userncsoregi@mozilla.com
push dateFri, 16 Aug 2019 04:07:24 +0000
treeherdermozilla-inbound@d887276421d3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1559244
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1559244 - Step 3: Add test for crashing an oop iframe. r=mconley Differential Revision: https://phabricator.services.mozilla.com/D38896
dom/ipc/tests/browser.ini
dom/ipc/tests/browser_crash_oopiframe.js
--- a/dom/ipc/tests/browser.ini
+++ b/dom/ipc/tests/browser.ini
@@ -1,14 +1,16 @@
 [DEFAULT]
 support-files =
   file_disableScript.html
   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]
 skip-if = !e10 # This is an e10s only probe.
 [browser_cancel_content_js.js]
 fail-if = fission
 skip-if = !e10s # This is an e10s only probe.
 [browser_ElapsedTime.js]
new file mode 100644
--- /dev/null
+++ b/dom/ipc/tests/browser_crash_oopiframe.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);
+});