Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

/* Any copyright is dedicated to the Public Domain.
"use strict";
const EXAMPLE_COM_URI =
const EXAMPLE_ORG_URI =
/**
* Test that watchedByDevTools is properly propagated during cross
* site navigations, and properly restored when navigating with bfcache.
*/
add_task(async function () {
const tab = await addTab(EXAMPLE_COM_URI);
const browser = tab.linkedBrowser;
const bcCom = browser.browsingContext;
const toolbox = await openToolboxForTab(tab, "webconsole");
ok(bcCom.watchedByDevTools, "example.com browsing context is watched");
await navigateTo(EXAMPLE_ORG_URI);
const bcOrg = browser.browsingContext;
isnot(bcCom, bcOrg, "Cross-group navigation replaced the BrowsingContext");
ok(bcOrg.watchedByDevTools, "example.org browsing context is watched");
info("Close devtools before navigating using bfcache");
await toolbox.destroy();
info("Wait for watchByDevTools to be updated");
await waitFor(() => !bcOrg.watchedByDevTools);
ok(!bcOrg.watchedByDevTools, "example.org browsing context is not watched");
ok(!ChromeUtils.isDevToolsOpened(), "DevTools are closed");
info("Go back from example.org to example.com");
let onLocationChange = BrowserTestUtils.waitForLocationChange(
gBrowser,
EXAMPLE_COM_URI
);
browser.goBack();
await onLocationChange;
is(browser.browsingContext, bcCom, "Back restored example.com from bfcache");
ok(!bcCom.watchedByDevTools, "example.com browsing context is not watched");
// This step used to lead to a crash (Bug 2073442).
info("Go forward from example.com to example.org");
onLocationChange = BrowserTestUtils.waitForLocationChange(
gBrowser,
EXAMPLE_ORG_URI
);
browser.goForward();
await onLocationChange;
is(
browser.browsingContext,
bcOrg,
"Forward restored example.org from bfcache"
);
ok(!bcOrg.watchedByDevTools, "example.org browsing context is not watched");
gBrowser.removeTab(tab);
});