зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1134518 - Add test to ensure we don't lose shistory entries when switching a browser's remoteness r=Mossop
This commit is contained in:
Родитель
4b8dab2a11
Коммит
17a502b1e0
|
@ -97,6 +97,8 @@ skip-if = e10s
|
|||
[browser_sessionStorage.js]
|
||||
[browser_swapDocShells.js]
|
||||
skip-if = e10s # See bug 918634
|
||||
[browser_switch_remoteness.js]
|
||||
run-if = e10s
|
||||
[browser_telemetry.js]
|
||||
[browser_upgrade_backup.js]
|
||||
[browser_windowRestore_perwindowpb.js]
|
||||
|
|
|
@ -0,0 +1,47 @@
|
|||
"use strict";
|
||||
|
||||
const URL = "http://example.com/browser_switch_remoteness_";
|
||||
|
||||
function countHistoryEntries(browser) {
|
||||
return ContentTask.spawn(browser, null, function* () {
|
||||
let Ci = Components.interfaces;
|
||||
let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
let history = webNavigation.sessionHistory.QueryInterface(Ci.nsISHistoryInternal);
|
||||
return history && history.count;
|
||||
});
|
||||
}
|
||||
|
||||
add_task(function* () {
|
||||
// Add a new tab.
|
||||
let tab = gBrowser.addTab("about:blank");
|
||||
let browser = tab.linkedBrowser;
|
||||
yield promiseBrowserLoaded(browser);
|
||||
ok(browser.isRemoteBrowser, "browser is remote");
|
||||
|
||||
// Get the maximum number of preceding entries to save.
|
||||
const MAX_BACK = Services.prefs.getIntPref("browser.sessionstore.max_serialize_back");
|
||||
ok(MAX_BACK > -1, "check that the default has a value that caps data");
|
||||
|
||||
// Load more pages than we would save to disk on a clean shutdown.
|
||||
for (let i = 0; i < MAX_BACK + 2; i++) {
|
||||
browser.loadURI(URL + i);
|
||||
yield promiseBrowserLoaded(browser);
|
||||
ok(browser.isRemoteBrowser, "browser is still remote");
|
||||
}
|
||||
|
||||
// Check we have the right number of shistory entries.
|
||||
let count = yield countHistoryEntries(browser);
|
||||
is(count, MAX_BACK + 2, "correct number of shistory entries");
|
||||
|
||||
// Load a non-remote page.
|
||||
browser.loadURI("about:robots");
|
||||
yield promiseTabRestored(tab);
|
||||
ok(!browser.isRemoteBrowser, "browser is not remote anymore");
|
||||
|
||||
// Check that we didn't lose any shistory entries.
|
||||
count = yield countHistoryEntries(browser);
|
||||
is(count, MAX_BACK + 3, "correct number of shistory entries");
|
||||
|
||||
// Cleanup.
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
|
@ -13,10 +13,7 @@ this.EXPORTED_SYMBOLS = [
|
|||
const { classes: Cc, interfaces: Ci, utils: Cu } = Components;
|
||||
Cu.import("resource://gre/modules/Promise.jsm");
|
||||
|
||||
/**
|
||||
* Set of browsers which have loaded the content-task frame script.
|
||||
*/
|
||||
let gScriptLoadedSet = new WeakSet();
|
||||
const FRAME_SCRIPT = "chrome://mochikit/content/tests/BrowserTestUtils/content-task.js";
|
||||
|
||||
/**
|
||||
* Mapping from message id to associated promise.
|
||||
|
@ -50,12 +47,12 @@ this.ContentTask = {
|
|||
* @rejects An error message if execution fails.
|
||||
*/
|
||||
spawn: function ContentTask_spawn(browser, arg, task) {
|
||||
if(!gScriptLoadedSet.has(browser.permanentKey)) {
|
||||
let mm = browser.messageManager;
|
||||
mm.loadFrameScript(
|
||||
"chrome://mochikit/content/tests/BrowserTestUtils/content-task.js", true);
|
||||
let mm = browser.ownerDocument.defaultView.messageManager;
|
||||
let scripts = mm.getDelayedFrameScripts();
|
||||
|
||||
gScriptLoadedSet.add(browser.permanentKey);
|
||||
// Load the frame script if needed.
|
||||
if (!scripts.find(script => script[0] == FRAME_SCRIPT)) {
|
||||
mm.loadFrameScript(FRAME_SCRIPT, true);
|
||||
}
|
||||
|
||||
let deferred = {};
|
||||
|
|
Загрузка…
Ссылка в новой задаче