fune/browser/components/sessionstore/test/browser_multiple_navigateAndRestore.js
Mark Banner 92c422a2d6 Bug 1342459 - Add a rule to automatically detect ContentTask.spawn and inject the relevant globals. r=mossop
This reduces the amount of places where we need to specify the mozilla/frame-script environment. It does have
the side effect of allowing those globals in the whole file, but that is what specifying the environment would
do, and this is also for mochitest test files only.

MozReview-Commit-ID: 1LLFbn6fFJR

--HG--
extra : rebase_source : 82a6934d90bbbbd25f91b7b06bf4f9354e38865a
2017-04-05 10:00:25 +01:00

36 lines
1.4 KiB
JavaScript

"use strict";
const PAGE_1 = "data:text/html,<html><body>A%20regular,%20everyday,%20normal%20page.";
const PAGE_2 = "data:text/html,<html><body>Another%20regular,%20everyday,%20normal%20page.";
add_task(function*() {
// Load an empty, non-remote tab at about:blank...
let tab = gBrowser.addTab("about:blank", {
forceNotRemote: true,
});
gBrowser.selectedTab = tab;
let browser = gBrowser.selectedBrowser;
ok(!browser.isRemoteBrowser, "Ensure browser is not remote");
// Load a remote page, and then another remote page immediately
// after.
browser.loadURI(PAGE_1);
browser.stop();
browser.loadURI(PAGE_2);
yield BrowserTestUtils.browserLoaded(browser);
ok(browser.isRemoteBrowser, "Should have switched remoteness");
yield TabStateFlusher.flush(browser);
let state = JSON.parse(ss.getTabState(tab));
let entries = state.entries;
is(entries.length, 1, "There should only be one entry");
is(entries[0].url, PAGE_2, "Should have PAGE_2 as the sole history entry");
is(browser.currentURI.spec, PAGE_2, "Should have PAGE_2 as the browser currentURI");
yield ContentTask.spawn(browser, PAGE_2, function*(expectedURL) {
docShell.QueryInterface(Ci.nsIWebNavigation);
Assert.equal(docShell.currentURI.spec, expectedURL,
"Content should have PAGE_2 as the browser currentURI");
});
yield BrowserTestUtils.removeTab(tab);
});