fune/browser/base/content/test/general/browser_bug724239.js
Mike Conley 90e282026f Bug 1497901 - Make some tests work if Activity Stream runs in its own content process. r=Felipe
The separate Activity Stream content process is currently pref-able, and I'd like to make sure
that the tree is green with it enabled and disabled. This patch makes it so that tests that
browse from about:home/about:newtab to some other page or back work properly even if there
are process flips.

Based on work originally by Jay Lim (:imjching) <jay@imjching.com>.

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

--HG--
extra : moz-landing-system : lando
2018-10-11 21:13:31 +00:00

41 lines
1.6 KiB
JavaScript

/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
add_task(async function test_blank() {
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" },
async function(browser) {
BrowserTestUtils.loadURI(browser, "http://example.com");
await BrowserTestUtils.browserLoaded(browser);
ok(!gBrowser.canGoBack, "about:blank wasn't added to session history");
});
});
add_task(async function test_newtab() {
await BrowserTestUtils.withNewTab({ gBrowser, url: "about:blank" },
async function(browser) {
let tab = gBrowser.getTabForBrowser(browser);
// Can't load it directly because that'll use a preloaded tab if present.
BrowserTestUtils.loadURI(browser, "about:newtab");
// We will need to wait for about:newtab to be loaded so that it goes into
// the session history.
await BrowserTestUtils.browserStopped(browser, "about:newtab");
let { mustChangeProcess } =
E10SUtils.shouldLoadURIInBrowser(browser, "http://example.com");
BrowserTestUtils.loadURI(browser, "http://example.com");
let stopped = BrowserTestUtils.browserStopped(browser);
if (mustChangeProcess) {
// If we did a process flip, we will need to ensure that the restoration has
// completed before we check gBrowser.canGoBack.
await BrowserTestUtils.waitForEvent(tab, "SSTabRestored");
}
await stopped;
is(gBrowser.canGoBack, true, "about:newtab was added to the session history when AS was enabled.");
});
});