--- a/browser/components/sessionstore/ContentRestore.jsm
+++ b/browser/components/sessionstore/ContentRestore.jsm
@@ -283,17 +283,17 @@ ContentRestoreInternal.prototype = {
* Finish restoring the tab by filling in form data and setting the scroll
* position. The restore is complete when this function exits. It should be
* called when the "load" event fires for the restoring tab.
*/
restoreDocument() {
if (!this._restoringDocument) {
return;
}
- let {entry, pageStyle, formdata, scrollPositions} = this._restoringDocument;
+ let {pageStyle, formdata, scrollPositions} = this._restoringDocument;
this._restoringDocument = null;
let window = this.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
PageStyle.restoreTree(this.docShell, pageStyle);
FormData.restoreTree(window, formdata);
ScrollPosition.restoreTree(window, scrollPositions);
--- a/browser/components/sessionstore/PageStyle.jsm
+++ b/browser/components/sessionstore/PageStyle.jsm
@@ -72,27 +72,27 @@ var PageStyleInternal = {
* }
*/
restoreTree(docShell, data) {
let disabled = data.disabled || false;
let markupDocumentViewer =
docShell.contentViewer;
markupDocumentViewer.authorStyleDisabled = disabled;
- function restoreFrame(root, data) {
- if (data.hasOwnProperty("pageStyle")) {
- root.document.selectedStyleSheetSet = data.pageStyle;
+ function restoreFrame(root, frameData) {
+ if (frameData.hasOwnProperty("pageStyle")) {
+ root.document.selectedStyleSheetSet = frameData.pageStyle;
}
- if (!data.hasOwnProperty("children")) {
+ if (!frameData.hasOwnProperty("children")) {
return;
}
let frames = root.frames;
- data.children.forEach((child, index) => {
+ frameData.children.forEach((child, index) => {
if (child && index < frames.length) {
restoreFrame(frames[index], child);
}
});
}
let ifreq = docShell.QueryInterface(Ci.nsIInterfaceRequestor);
restoreFrame(ifreq.getInterface(Ci.nsIDOMWindow), data);
--- a/browser/components/sessionstore/SessionCookies.jsm
+++ b/browser/components/sessionstore/SessionCookies.jsm
@@ -351,20 +351,20 @@ var CookieStore = {
* }
* };
*/
_hosts: new Map(),
/**
* Returns the list of stored session cookies for a given host.
*
- * @param host
+ * @param mainHost
* A string containing the host name we want to get cookies for.
*/
- getCookiesForHost(host) {
+ getCookiesForHost(mainHost) {
let cookies = [];
let appendCookiesForHost = host => {
if (!this._hosts.has(host)) {
return;
}
for (let pathToNamesMap of this._hosts.get(host).values()) {
@@ -376,17 +376,17 @@ var CookieStore = {
// Try to find cookies for the given host, e.g. <www.example.com>.
// The full hostname will be in the map if the Set-Cookie header did not
// have a domain= attribute, i.e. the cookie will only be stored for the
// request domain. Also, try to find cookies for subdomains, e.g.
// <.example.com>. We will find those variants with a leading dot in the
// map if the Set-Cookie header had a domain= attribute, i.e. the cookie
// will be stored for a parent domain and we send it for any subdomain.
- for (let variant of [host, ...getPossibleSubdomainVariants(host)]) {
+ for (let variant of [mainHost, ...getPossibleSubdomainVariants(mainHost)]) {
appendCookiesForHost(variant);
}
return cookies;
},
/**
* Stores a given cookie.
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -851,17 +851,17 @@ var SessionStoreInternal = {
// Remove from the list of closed tabs. The update messages sent
// after the tab was closed changed enough state so that we no
// longer consider its data interesting enough to keep around.
this.removeClosedTabData(closedTabs, index);
}
}
}
break;
- case "SessionStore:restoreHistoryComplete":
+ case "SessionStore:restoreHistoryComplete": {
// Notify the tabbrowser that the tab chrome has been restored.
let tabData = TabState.collect(tab);
// wall-paper fix for bug 439675: make sure that the URL to be loaded
// is always visible in the address bar if no other value is present
let activePageData = tabData.entries[tabData.index - 1] || null;
let uri = activePageData ? activePageData.url || null : null;
// NB: we won't set initial URIs (about:home, about:newtab, etc.) here
@@ -895,16 +895,17 @@ var SessionStoreInternal = {
win.gBrowser.setIcon(tab, tabData.image, loadingPrincipal);
TabStateCache.update(browser, { image: null, iconLoadingPrincipal: null });
}
let event = win.document.createEvent("Events");
event.initEvent("SSTabRestoring", true, false);
tab.dispatchEvent(event);
break;
+ }
case "SessionStore:restoreTabContentStarted":
if (browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE) {
// If a load not initiated by sessionstore was started in a
// previously pending tab. Mark the tab as no longer pending.
this.markTabAsRestoring(tab);
} else if (!data.isRemotenessUpdate) {
// If the user was typing into the URL bar when we crashed, but hadn't hit
// enter yet, then we just need to write that value to the URL bar without
@@ -940,17 +941,16 @@ var SessionStoreInternal = {
this._crashedBrowsers.delete(browser.permanentKey);
break;
case "SessionStore:error":
this.reportInternalError(data);
TabStateFlusher.resolveAll(browser, false, "Received error from the content process");
break;
default:
throw new Error(`received unknown message '${aMessage.name}'`);
- break;
}
},
/**
* Record telemetry measurements stored in an object.
* @param telemetry
* {histogramID: value, ...} An object mapping histogramIDs to the
* value to be recorded for that ID,
@@ -1136,27 +1136,25 @@ var SessionStoreInternal = {
let overwrite = this._isCmdLineEmpty(aWindow, aInitialState);
let options = {firstWindow: true, overwriteTabs: overwrite};
this.restoreWindows(aWindow, aInitialState, options);
}
} else {
// Nothing to restore, notify observers things are complete.
Services.obs.notifyObservers(null, NOTIFY_WINDOWS_RESTORED, "");
}
- }
// this window was opened by _openWindowWithState
- else if (!this._isWindowLoaded(aWindow)) {
+ } else if (!this._isWindowLoaded(aWindow)) {
let state = this._statesToRestore[aWindow.__SS_restoreID];
let options = {overwriteTabs: true, isFollowUp: state.windows.length == 1};
this.restoreWindow(aWindow, state.windows[0], options);
- }
// The user opened another, non-private window after starting up with
// a single private one. Let's restore the session we actually wanted to
// restore at startup.
- else if (this._deferredInitialState && !isPrivateWindow &&
+ } else if (this._deferredInitialState && !isPrivateWindow &&
aWindow.toolbar.visible) {
// global data must be restored before restoreWindow is called so that
// it happens before observers are notified
this._globalState.setFromState(this._deferredInitialState);
this._restoreCount = this._deferredInitialState.windows ?
this._deferredInitialState.windows.length : 0;
@@ -1193,19 +1191,18 @@ var SessionStoreInternal = {
if (appTabsState.windows.length) {
newWindowState = appTabsState.windows[0];
delete newWindowState.__lastSessionWindowID;
}
// In case there were no unpinned tabs, remove the window from _closedWindows
if (!normalTabsState.windows.length) {
this._removeClosedWindow(closedWindowIndex);
- }
// Or update _closedWindows with the modified state
- else {
+ } else {
delete normalTabsState.windows[0].__lastSessionWindowID;
this._closedWindows[closedWindowIndex] = normalTabsState.windows[0];
}
} else {
// If we're just restoring the window, make sure it gets removed from
// _closedWindows.
this._removeClosedWindow(closedWindowIndex);
newWindowState = closedWindowState;
@@ -2450,17 +2447,17 @@ var SessionStoreInternal = {
this._saveableClosedWindowData.delete(winData);
// Notify of changes to closed objects.
this._notifyOfClosedObjectsChange();
},
getWindowValue: function ssi_getWindowValue(aWindow, aKey) {
if ("__SSi" in aWindow) {
- var data = this._windows[aWindow.__SSi].extData || {};
+ let data = this._windows[aWindow.__SSi].extData || {};
return data[aKey] || "";
}
if (DyingWindowCache.has(aWindow)) {
let data = DyingWindowCache.get(aWindow).extData || {};
return data[aKey] || "";
}
@@ -2781,20 +2778,20 @@ var SessionStoreInternal = {
this._remotenessChangingBrowsers.get(browser.permanentKey);
this._remotenessChangingBrowsers.delete(browser.permanentKey);
// The tab might have been closed/gone in the meantime.
if (tab.closing || !tab.linkedBrowser) {
return;
}
- let window = tab.ownerGlobal;
+ let refreshedWindow = tab.ownerGlobal;
// The tab or its window might be gone.
- if (!window || !window.__SSi || window.closed) {
+ if (!refreshedWindow || !refreshedWindow.__SSi || refreshedWindow.closed) {
return;
}
let tabState = TabState.clone(tab);
let options = {
restoreImmediately: true,
// We want to make sure that this information is passed to restoreTab
// whether or not a historyIndex is passed in. Thus, we extract it from
@@ -2874,17 +2871,16 @@ var SessionStoreInternal = {
// Look at the open tabs in comparison to home pages. If all the tabs are
// home pages then we'll end up overwriting all of them. Otherwise we'll
// just close the tabs that match home pages. Tabs with the about:blank
// URI will always be overwritten.
let homePages = ["about:blank"];
let removableTabs = [];
let tabbrowser = aWindow.gBrowser;
- let normalTabsLen = tabbrowser.tabs.length - tabbrowser._numPinnedTabs;
let startupPref = this._prefBranch.getIntPref("startup.page");
if (startupPref == 1)
homePages = homePages.concat(aWindow.gHomeButton.getHomePage().split("|"));
for (let i = tabbrowser._numPinnedTabs; i < tabbrowser.tabs.length; i++) {
let tab = tabbrowser.tabs[i];
if (homePages.indexOf(tab.linkedBrowser.currentURI.spec) != -1) {
removableTabs.push(tab);
@@ -3149,21 +3145,19 @@ var SessionStoreInternal = {
TelemetryStopwatch.start("FX_SESSION_RESTORE_RESTORE_WINDOW_MS");
// We're not returning from this before we end up calling restoreTabs
// for this window, so make sure we send the SSWindowStateBusy event.
this._setWindowStateBusy(aWindow);
if (!winData.tabs) {
winData.tabs = [];
- }
-
// don't restore a single blank tab when we've had an external
// URL passed in for loading at startup (cf. bug 357419)
- else if (firstWindow && !overwriteTabs && winData.tabs.length == 1 &&
+ } else if (firstWindow && !overwriteTabs && winData.tabs.length == 1 &&
(!winData.tabs[0].entries || winData.tabs[0].entries.length == 0)) {
winData.tabs = [];
}
var tabbrowser = aWindow.gBrowser;
var openTabCount = overwriteTabs ? tabbrowser.browsers.length : -1;
var newTabCount = winData.tabs.length;
var tabs = [];
@@ -3737,24 +3731,23 @@ var SessionStoreInternal = {
} else {
delete this._windows[aWindow.__SSi].isPopup;
if (aWindow.gURLBar) {
aWindow.gURLBar.readOnly = false;
aWindow.gURLBar.setAttribute("enablehistory", "true");
}
}
- var _this = this;
- aWindow.setTimeout(function() {
- _this.restoreDimensions.apply(_this, [aWindow,
+ aWindow.setTimeout(() => {
+ this.restoreDimensions(aWindow,
+(aWinData.width || 0),
+(aWinData.height || 0),
"screenX" in aWinData ? +aWinData.screenX : NaN,
"screenY" in aWinData ? +aWinData.screenY : NaN,
- aWinData.sizemode || "", aWinData.sidebar || ""]);
+ aWinData.sizemode || "", aWinData.sidebar || "");
}, 0);
},
/**
* Restore a window's dimensions
* @param aWidth
* Window width
* @param aHeight
--- a/browser/components/sessionstore/SessionWorker.js
+++ b/browser/components/sessionstore/SessionWorker.js
@@ -1,12 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
+/* eslint-env worker */
+
/**
* A worker dedicated to handle I/O for Session Store.
*/
"use strict";
importScripts("resource://gre/modules/osfile.jsm");
--- a/browser/components/sessionstore/TabState.jsm
+++ b/browser/components/sessionstore/TabState.jsm
@@ -159,17 +159,16 @@ var TabStateInternal = {
copyFromCache(browser, tabData, options = {}) {
let data = TabStateCache.get(browser);
if (!data) {
return;
}
// The caller may explicitly request to omit privacy checks.
let includePrivateData = options && options.includePrivateData;
- let isPinned = !!tabData.pinned;
for (let key of Object.keys(data)) {
let value = data[key];
// Filter sensitive data according to the current privacy level.
if (!includePrivateData) {
if (key === "storage") {
value = PrivacyFilter.filterSessionStorageData(value);
--- a/browser/components/sessionstore/content/content-sessionStore.js
+++ b/browser/components/sessionstore/content/content-sessionStore.js
@@ -1,25 +1,28 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
-"use strict";
+/* eslint-env mozilla/frame-script */
-function debug(msg) {
- Services.console.logStringMessage("SessionStoreContent: " + msg);
-}
+"use strict";
var Cu = Components.utils;
var Cc = Components.classes;
var Ci = Components.interfaces;
var Cr = Components.results;
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
Cu.import("resource://gre/modules/Timer.jsm", this);
+Cu.import("resource://gre/modules/Services.jsm", this);
+
+function debug(msg) {
+ Services.console.logStringMessage("SessionStoreContent: " + msg);
+}
XPCOMUtils.defineLazyModuleGetter(this, "FormData",
"resource://gre/modules/FormData.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
"resource://gre/modules/Preferences.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "DocShellCapabilities",
"resource:///modules/sessionstore/DocShellCapabilities.jsm");
@@ -829,21 +832,20 @@ var MessageQueue = {
// Send all data to the parent process.
sendAsyncMessage("SessionStore:update", {
data, telemetry, flushID,
isFinal: options.isFinal || false,
epoch: gCurrentEpoch
});
} catch (ex) {
if (ex && ex.result == Cr.NS_ERROR_OUT_OF_MEMORY) {
- let telemetry = {
- FX_SESSION_RESTORE_SEND_UPDATE_CAUSED_OOM: 1
- };
sendAsyncMessage("SessionStore:error", {
- telemetry
+ telemetry: {
+ FX_SESSION_RESTORE_SEND_UPDATE_CAUSED_OOM: 1
+ }
});
}
}
},
};
EventListener.init();
MessageListener.init();
--- a/browser/components/sessionstore/test/browser_248970_b_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_248970_b_perwindowpb.js
@@ -27,17 +27,17 @@ function test() {
};
registerCleanupFunction(function* () {
for (let win of windowsToClose) {
yield BrowserTestUtils.closeWindow(win);
}
});
- function test(aLambda) {
+ function checkNoThrow(aLambda) {
try {
return aLambda() || true;
} catch (ex) { }
return false;
}
function getElementByXPath(aTab, aQuery) {
let doc = aTab.linkedBrowser.contentDocument;
@@ -68,19 +68,19 @@ function test() {
if (node instanceof Ci.nsIDOMHTMLTextAreaElement)
return aValue == node.value;
if (!node.multiple)
return aValue == node.selectedIndex;
return Array.every(node.options, (aOpt, aIx) =>
(aValue.indexOf(aIx) > -1) == aOpt.selected);
}
- //////////////////////////////////////////////////////////////////
- // Test (B) : Session data restoration between windows //
- //////////////////////////////////////////////////////////////////
+ /**
+ * Test (B) : Session data restoration between windows
+ */
let rootDir = getRootDirectory(gTestPath);
const testURL = rootDir + "browser_248970_b_sample.html";
const testURL2 = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_248970_b_sample.html";
whenNewWindowLoaded({ private: false }, function(aWin) {
windowsToClose.push(aWin);
@@ -88,17 +88,16 @@ function test() {
// get closed tab count
let count = ss.getClosedTabCount(aWin);
let max_tabs_undo =
Services.prefs.getIntPref("browser.sessionstore.max_tabs_undo");
ok(0 <= count && count <= max_tabs_undo,
"getClosedTabCount should return zero or at most max_tabs_undo");
// setup a state for tab (A) so we can check later that is restored
- let key = "key";
let value = "Value " + Math.random();
let state = { entries: [{ url: testURL }], extData: { key: value } };
// public session, add new tab: (A)
let tab_A = aWin.gBrowser.addTab(testURL);
ss.setTabState(tab_A, JSON.stringify(state));
promiseBrowserLoaded(tab_A.linkedBrowser).then(() => {
// make sure that the next closed tab will increase getClosedTabCount
@@ -112,54 +111,54 @@ function test() {
// public session, close tab: (A)
aWin.gBrowser.removeTab(tab_A);
// verify that closedTabCount increased
ok(ss.getClosedTabCount(aWin) > count,
"getClosedTabCount has increased after closing a tab");
// verify tab: (A), in undo list
- let tab_A_restored = test(() => ss.undoCloseTab(aWin, 0));
+ let tab_A_restored = checkNoThrow(() => ss.undoCloseTab(aWin, 0));
ok(tab_A_restored, "a tab is in undo list");
promiseTabRestored(tab_A_restored).then(() => {
is(testURL, tab_A_restored.linkedBrowser.currentURI.spec,
"it's the same tab that we expect");
aWin.gBrowser.removeTab(tab_A_restored);
- whenNewWindowLoaded({ private: true }, function(aWin) {
- windowsToClose.push(aWin);
+ whenNewWindowLoaded({ private: true }, function(win) {
+ windowsToClose.push(win);
// setup a state for tab (B) so we can check that its duplicated
// properly
let key1 = "key1";
let value1 = "Value " + Math.random();
let state1 = {
entries: [{ url: testURL2 }], extData: { key1: value1 }
};
- let tab_B = aWin.gBrowser.addTab(testURL2);
+ let tab_B = win.gBrowser.addTab(testURL2);
promiseTabState(tab_B, state1).then(() => {
// populate tab: (B) with different form data
for (let item in fieldList)
setFormValue(tab_B, item, fieldList[item]);
// duplicate tab: (B)
- let tab_C = aWin.gBrowser.duplicateTab(tab_B);
+ let tab_C = win.gBrowser.duplicateTab(tab_B);
promiseTabRestored(tab_C).then(() => {
// verify the correctness of the duplicated tab
is(ss.getTabValue(tab_C, key1), value1,
"tab successfully duplicated - correct state");
for (let item in fieldList)
ok(compareFormValue(tab_C, item, fieldList[item]),
"The value for \"" + item + "\" was correctly duplicated");
// private browsing session, close tab: (C) and (B)
- aWin.gBrowser.removeTab(tab_C);
- aWin.gBrowser.removeTab(tab_B);
+ win.gBrowser.removeTab(tab_C);
+ win.gBrowser.removeTab(tab_B);
finish();
});
});
});
});
});
});
--- a/browser/components/sessionstore/test/browser_345898.js
+++ b/browser/components/sessionstore/test/browser_345898.js
@@ -1,43 +1,45 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function test() {
/** Test for Bug 345898 **/
- function test(aLambda) {
- try {
- aLambda();
- return false;
- } catch (ex) {
- return ex.name == "NS_ERROR_ILLEGAL_VALUE" ||
- ex.name == "NS_ERROR_FAILURE";
- }
- }
-
// all of the following calls with illegal arguments should throw NS_ERROR_ILLEGAL_VALUE
- ok(test(() => ss.getWindowState({})),
- "Invalid window for getWindowState throws");
- ok(test(() => ss.setWindowState({}, "", false)),
- "Invalid window for setWindowState throws");
- ok(test(() => ss.getTabState({})),
- "Invalid tab for getTabState throws");
- ok(test(() => ss.setTabState({}, "{}")),
- "Invalid tab state for setTabState throws");
- ok(test(() => ss.setTabState({}, JSON.stringify({ entries: [] }))),
- "Invalid tab for setTabState throws");
- ok(test(() => ss.duplicateTab({}, {})),
- "Invalid tab for duplicateTab throws");
- ok(test(() => ss.duplicateTab({}, gBrowser.selectedTab)),
- "Invalid window for duplicateTab throws");
- ok(test(() => ss.getClosedTabData({})),
- "Invalid window for getClosedTabData throws");
- ok(test(() => ss.undoCloseTab({}, 0)),
- "Invalid window for undoCloseTab throws");
- ok(test(() => ss.undoCloseTab(window, -1)),
- "Invalid index for undoCloseTab throws");
- ok(test(() => ss.getWindowValue({}, "")),
- "Invalid window for getWindowValue throws");
- ok(test(() => ss.setWindowValue({}, "", "")),
- "Invalid window for setWindowValue throws");
+ Assert.throws(() => ss.getWindowState({}),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Invalid window for getWindowState throws");
+ Assert.throws(() => ss.setWindowState({}, "", false),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Invalid window for setWindowState throws");
+ Assert.throws(() => ss.getTabState({}),
+ /NS_ERROR_FAILURE/,
+ "Invalid tab for getTabState throws");
+ Assert.throws(() => ss.setTabState({}, "{}"),
+ /NS_ERROR_FAILURE/,
+ "Invalid tab state for setTabState throws");
+ Assert.throws(() => ss.setTabState({}, JSON.stringify({ entries: [] })),
+ /NS_ERROR_FAILURE/,
+ "Invalid tab for setTabState throws");
+ Assert.throws(() => ss.duplicateTab({}, {}),
+ /NS_ERROR_FAILURE/,
+ "Invalid tab for duplicateTab throws");
+ Assert.throws(() => ss.duplicateTab({}, gBrowser.selectedTab),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Invalid window for duplicateTab throws");
+ Assert.throws(() => ss.getClosedTabData({}),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Invalid window for getClosedTabData throws");
+ Assert.throws(() => ss.undoCloseTab({}, 0),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Invalid window for undoCloseTab throws");
+ Assert.throws(() => ss.undoCloseTab(window, -1),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Invalid index for undoCloseTab throws");
+ Assert.throws(() => ss.getWindowValue({}, ""),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Invalid window for getWindowValue throws");
+ Assert.throws(() => ss.setWindowValue({}, "", ""),
+ /NS_ERROR_ILLEGAL_VALUE/,
+ "Invalid window for setWindowValue throws");
}
--- a/browser/components/sessionstore/test/browser_350525.js
+++ b/browser/components/sessionstore/test/browser_350525.js
@@ -11,19 +11,19 @@ add_task(function* () {
function test(aLambda) {
try {
return aLambda() || true;
} catch (ex) { }
return false;
}
- ////////////////////////////
- // setWindowValue, et al. //
- ////////////////////////////
+ /**
+ * setWindowValue, et al.
+ */
let key = "Unique name: " + Date.now();
let value = "Unique value: " + Math.random();
// test adding
ok(test(() => ss.setWindowValue(window, key, value)), "set a window value");
// test retrieving
is(ss.getWindowValue(window, key), value, "stored window value matches original");
@@ -32,19 +32,19 @@ add_task(function* () {
ok(test(() => ss.deleteWindowValue(window, key)), "delete the window value");
// value should not exist post-delete
is(ss.getWindowValue(window, key), "", "window value was deleted");
// test deleting a non-existent value
ok(test(() => ss.deleteWindowValue(window, key)), "delete non-existent window value");
- /////////////////////////
- // setTabValue, et al. //
- /////////////////////////
+ /**
+ * setTabValue, et al.
+ */
key = "Unique name: " + Math.random();
value = "Unique value: " + Date.now();
let tab = gBrowser.addTab();
tab.linkedBrowser.stop();
// test adding
ok(test(() => ss.setTabValue(tab, key, value)), "store a tab value");
@@ -58,19 +58,19 @@ add_task(function* () {
is(ss.getTabValue(tab, key), "", "tab value was deleted");
// test deleting a non-existent value
ok(test(() => ss.deleteTabValue(tab, key)), "delete non-existent tab value");
// clean up
yield promiseRemoveTab(tab);
- /////////////////////////////////////
- // getClosedTabCount, undoCloseTab //
- /////////////////////////////////////
+ /**
+ * getClosedTabCount, undoCloseTab
+ */
// get closed tab count
let count = ss.getClosedTabCount(window);
let max_tabs_undo = gPrefService.getIntPref("browser.sessionstore.max_tabs_undo");
ok(0 <= count && count <= max_tabs_undo,
"getClosedTabCount returns zero or at most max_tabs_undo");
// create a new tab
--- a/browser/components/sessionstore/test/browser_354894_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_354894_perwindowpb.js
@@ -71,17 +71,17 @@ add_task(function* setup() {
// So we require a longer timeout. See bug 528219.
requestLongerTimeout(3);
// Make the main test window not count as a browser window any longer
let oldWinType = document.documentElement.getAttribute("windowtype");
document.documentElement.setAttribute("windowtype", "navigator:testrunner");
registerCleanupFunction(() => {
- document.documentElement.setAttribute("windowtype", "navigator:browser");
+ document.documentElement.setAttribute("windowtype", oldWinType);
});
});
/**
* Sets up one of our tests by setting the right preferences, and
* then opening up a browser window preloaded with some tabs.
*
* @param options (Object)
@@ -466,9 +466,8 @@ add_task(function* test_mac_notification
// We tried closing once, and got denied. Then we tried again and
// succeeded. That means 2 close requests, and 1 close granted.
is(obs["browser-lastwindow-close-requested"], 2,
"Got expected browser-lastwindow-close-requested notifications");
is(obs["browser-lastwindow-close-granted"], 1,
"Got expected browser-lastwindow-close-granted notifications");
});
});
-
--- a/browser/components/sessionstore/test/browser_367052.js
+++ b/browser/components/sessionstore/test/browser_367052.js
@@ -30,12 +30,13 @@ add_task(function* () {
is(count, 0, "the tab was restored without any history whatsoever");
yield promiseRemoveTab(tab);
is(ss.getClosedTabCount(window), 0,
"The closed blank tab wasn't added to Recently Closed Tabs");
});
function promiseSHistoryCount(browser) {
+ /* eslint-env mozilla/frame-script */
return ContentTask.spawn(browser, null, function* () {
return docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory.count;
});
}
--- a/browser/components/sessionstore/test/browser_394759_basic.js
+++ b/browser/components/sessionstore/test/browser_394759_basic.js
@@ -24,17 +24,17 @@ function test() {
// Clear the list of closed windows.
forgetClosedWindows();
provideWindow(function onTestURLLoaded(newWin) {
newWin.gBrowser.addTab().linkedBrowser.stop();
// Mark the window with some unique data to be restored later on.
ss.setWindowValue(newWin, uniqueKey, uniqueValue);
- let [txt, chk] = newWin.content.document.querySelectorAll("#txt, #chk");
+ let [txt] = newWin.content.document.querySelectorAll("#txt");
txt.value = uniqueText;
let browser = newWin.gBrowser.selectedBrowser;
setInputChecked(browser, {id: "chk", checked: true}).then(() => {
BrowserTestUtils.closeWindow(newWin).then(() => {
is(ss.getClosedWindowCount(), 1,
"The closed window was added to Recently Closed Windows");
@@ -68,17 +68,18 @@ function test() {
is(restoredTabs, expectedTabs, "Correct number of tabs restored");
newWin2.removeEventListener("SSTabRestored", sstabrestoredListener, true);
is(newWin2.gBrowser.tabs.length, 2,
"The window correctly restored 2 tabs");
is(newWin2.gBrowser.currentURI.spec, TEST_URL,
"The window correctly restored the URL");
- let [txt, chk] = newWin2.content.document.querySelectorAll("#txt, #chk");
+ let chk;
+ [txt, chk] = newWin2.content.document.querySelectorAll("#txt, #chk");
ok(txt.value == uniqueText && chk.checked,
"The window correctly restored the form");
is(ss.getWindowValue(newWin2, uniqueKey), uniqueValue,
"The window correctly restored the data associated with it");
// Clean up.
BrowserTestUtils.closeWindow(newWin2).then(finish);
}, true);
--- a/browser/components/sessionstore/test/browser_459906.js
+++ b/browser/components/sessionstore/test/browser_459906.js
@@ -19,39 +19,39 @@ function test() {
return;
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
let iframes = tab.linkedBrowser.contentWindow.frames;
iframes[1].document.body.innerHTML = uniqueValue;
frameCount = 0;
let tab2 = gBrowser.duplicateTab(tab);
- tab2.linkedBrowser.addEventListener("load", function(aEvent) {
+ tab2.linkedBrowser.addEventListener("load", function(eventTab2) {
// wait for all frames to load (and reload!) completely
if (frameCount++ < 2)
return;
tab2.linkedBrowser.removeEventListener("load", arguments.callee, true);
executeSoon(function() {
- let iframes = tab2.linkedBrowser.contentWindow.frames;
- if (iframes[1].document.body.innerHTML !== uniqueValue) {
+ let iframesTab2 = tab2.linkedBrowser.contentWindow.frames;
+ if (iframesTab2[1].document.body.innerHTML !== uniqueValue) {
// Poll again the value, since we can't ensure to run
// after SessionStore has injected innerHTML value.
// See bug 521802.
info("Polling for innerHTML value");
setTimeout(arguments.callee, 100);
return;
}
- is(iframes[1].document.body.innerHTML, uniqueValue,
+ is(iframesTab2[1].document.body.innerHTML, uniqueValue,
"rich textarea's content correctly duplicated");
let innerDomain = null;
try {
- innerDomain = iframes[0].document.domain;
+ innerDomain = iframesTab2[0].document.domain;
} catch (ex) { /* throws for chrome: documents */ }
is(innerDomain, "mochi.test", "XSS exploit prevented!");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
finish();
--- a/browser/components/sessionstore/test/browser_461743.js
+++ b/browser/components/sessionstore/test/browser_461743.js
@@ -13,17 +13,17 @@ function test() {
let frameCount = 0;
let tab = gBrowser.addTab(testURL);
tab.linkedBrowser.addEventListener("load", function(aEvent) {
// Wait for all frames to load completely.
if (frameCount++ < 2)
return;
tab.linkedBrowser.removeEventListener("load", arguments.callee, true);
let tab2 = gBrowser.duplicateTab(tab);
- tab2.linkedBrowser.addEventListener("461743", function(aEvent) {
+ tab2.linkedBrowser.addEventListener("461743", function(eventTab2) {
tab2.linkedBrowser.removeEventListener("461743", arguments.callee, true);
is(aEvent.data, "done", "XSS injection was attempted");
executeSoon(function() {
let iframes = tab2.linkedBrowser.contentWindow.frames;
let innerHTML = iframes[1].document.body.innerHTML;
isnot(innerHTML, Components.utils.reportError.toString(),
"chrome access denied!");
--- a/browser/components/sessionstore/test/browser_461743_sample.html
+++ b/browser/components/sessionstore/test/browser_461743_sample.html
@@ -30,17 +30,17 @@
var loadExploit = { handleEvent: href };
function delay() {
var xhr = new XMLHttpRequest();
xhr.open("GET", location.href, false);
xhr.send(null);
}
function done() {
- var event = new MessageEvent('461743', { bubbles: true, cancelable: false,
+ var event = new MessageEvent("461743", { bubbles: true, cancelable: false,
data: "done", origin: location.href,
source: window });
document.dispatchEvent(event);
frames[0].document.removeEventListener("DOMNodeInserted", loadChrome, true);
frames[0].document.removeEventListener("DOMNodeInserted", delay, true);
frames[0].document.removeEventListener("DOMNodeInserted", loadExploit, true);
frames[0].document.removeEventListener("DOMNodeInserted", done, true);
}
--- a/browser/components/sessionstore/test/browser_463206.js
+++ b/browser/components/sessionstore/test/browser_463206.js
@@ -36,17 +36,17 @@ add_task(function* () {
Assert.notEqual(content.document.getElementById("out1").value,
content.frames[1].document.getElementById("out1").value,
"text isn't reused for frames");
Assert.notEqual(content.document.getElementsByName("1|#out2")[0].value,
"", "text containing | and # is correctly restored");
Assert.equal(content.frames[1].document.getElementById("out2").value,
"", "id prefixes can't be faked");
// Disabled for now, Bug 588077
- //Assert.equal(content.frames[0].frames[1].document.getElementById("in1").value,
+ // Assert.equal(content.frames[0].frames[1].document.getElementById("in1").value,
// "", "id prefixes aren't mixed up");
Assert.equal(content.frames[1].frames[0].document.getElementById("in1").value,
"", "id prefixes aren't mixed up");
});
// Cleanup.
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
--- a/browser/components/sessionstore/test/browser_464620_a.html
+++ b/browser/components/sessionstore/test/browser_464620_a.html
@@ -39,16 +39,16 @@
for (var c = 0; !documentInjected && c < 20; c++) {
var r = new XMLHttpRequest();
r.open("GET", location.href, false);
r.overrideMimeType("text/plain");
r.send(null);
}
document.getElementById("state").textContent = "done";
- var event = new MessageEvent('464620_a', { bubbles: true, cancelable: false,
+ var event = new MessageEvent("464620_a", { bubbles: true, cancelable: false,
data: "done", origin: location.href,
source: window });
document.dispatchEvent(event);
}
</script>
<p id="state">pending</p>
--- a/browser/components/sessionstore/test/browser_464620_a.js
+++ b/browser/components/sessionstore/test/browser_464620_a.js
@@ -16,17 +16,17 @@ function test() {
// wait for all frames to load completely
if (frameCount++ < 4)
return;
this.removeEventListener("load", arguments.callee, true);
executeSoon(function() {
frameCount = 0;
let tab2 = gBrowser.duplicateTab(tab);
- tab2.linkedBrowser.addEventListener("464620_a", function(aEvent) {
+ tab2.linkedBrowser.addEventListener("464620_a", function(eventTab2) {
tab2.linkedBrowser.removeEventListener("464620_a", arguments.callee, true);
is(aEvent.data, "done", "XSS injection was attempted");
// let form restoration complete and take into account the
// setTimeout(..., 0) in sss_restoreDocument_proxy
executeSoon(function() {
setTimeout(function() {
let win = tab2.linkedBrowser.contentWindow;
--- a/browser/components/sessionstore/test/browser_464620_b.html
+++ b/browser/components/sessionstore/test/browser_464620_b.html
@@ -42,16 +42,16 @@
for (var c = 0; !documentInjected && c < 20; c++) {
var r = new XMLHttpRequest();
r.open("GET", location.href, false);
r.overrideMimeType("text/plain");
r.send(null);
}
document.getElementById("state").textContent = "done";
- var event = new MessageEvent('464620_b', { bubbles: true, cancelable: false,
+ var event = new MessageEvent("464620_b", { bubbles: true, cancelable: false,
data: "done", origin: location.href,
source: window });
document.dispatchEvent(event);
}
</script>
<p id="state">pending</p>
--- a/browser/components/sessionstore/test/browser_464620_b.js
+++ b/browser/components/sessionstore/test/browser_464620_b.js
@@ -16,17 +16,17 @@ function test() {
// wait for all frames to load completely
if (frameCount++ < 6)
return;
this.removeEventListener("load", arguments.callee, true);
executeSoon(function() {
frameCount = 0;
let tab2 = gBrowser.duplicateTab(tab);
- tab2.linkedBrowser.addEventListener("464620_b", function(aEvent) {
+ tab2.linkedBrowser.addEventListener("464620_b", function(eventTab2) {
tab2.linkedBrowser.removeEventListener("464620_b", arguments.callee, true);
is(aEvent.data, "done", "XSS injection was attempted");
// let form restoration complete and take into account the
// setTimeout(..., 0) in sss_restoreDocument_proxy
executeSoon(function() {
setTimeout(function() {
let win = tab2.linkedBrowser.contentWindow;
--- a/browser/components/sessionstore/test/browser_466937_sample.html
+++ b/browser/components/sessionstore/test/browser_466937_sample.html
@@ -7,15 +7,14 @@
<input id="thief" value="/home/user/secret">
<input type="file" id="reverse_thief">
<input type="file" id="bystander">
<script>
window.addEventListener("DOMContentLoaded", function() {
if (!document.location.hash) {
document.location.hash = "#ready";
- }
- else {
+ } else {
document.getElementById("thief").type = "file";
document.getElementById("reverse_thief").type = "text";
}
}, {once: true});
</script>
--- a/browser/components/sessionstore/test/browser_506482.js
+++ b/browser/components/sessionstore/test/browser_506482.js
@@ -44,25 +44,25 @@ function test() {
// get the initial sessionstore.js mtime (-1 if it doesn't exist yet)
let mtime0 = getSessionstorejsModificationTime();
// create and select a first tab
let tab = gBrowser.addTab(TEST_URL);
promiseBrowserLoaded(tab.linkedBrowser).then(() => {
// step1: the above has triggered some saveStateDelayed(), sleep until
// it's done, and get the initial sessionstore.js mtime
- setTimeout(function step1(e) {
+ setTimeout(function step1() {
let mtime1 = getSessionstorejsModificationTime();
isnot(mtime1, mtime0, "initial sessionstore.js update");
// step2: test sessionstore.js is not updated on tab selection
// or content scrolling
gBrowser.selectedTab = tab;
tab.linkedBrowser.contentWindow.scrollTo(1100, 1200);
- setTimeout(function step2(e) {
+ setTimeout(function step2() {
let mtime2 = getSessionstorejsModificationTime();
is(mtime2, mtime1,
"tab selection and scrolling: sessionstore.js not updated");
// ok, done, cleanup and finish
if (gPrefService.prefHasUserValue(PREF_INTERVAL))
gPrefService.clearUserPref(PREF_INTERVAL);
gBrowser.removeTab(tab);
--- a/browser/components/sessionstore/test/browser_526613.js
+++ b/browser/components/sessionstore/test/browser_526613.js
@@ -48,17 +48,17 @@ function test() {
// let the first window be focused (see above)
function pollMostRecentWindow() {
if (Services.wm.getMostRecentWindow("navigator:browser") == window) {
ss.setBrowserState(oldState);
} else {
info("waiting for the current window to become active");
setTimeout(pollMostRecentWindow, 0);
- window.focus(); //XXX Why is this needed?
+ window.focus(); // XXX Why is this needed?
}
}
pollMostRecentWindow();
} else {
browserWindowsCount(1);
ok(!window.closed, "Restoring the old state should have left this window open");
Services.obs.removeObserver(observer, "sessionstore-browser-state-restored");
finish();
--- a/browser/components/sessionstore/test/browser_586147.js
+++ b/browser/components/sessionstore/test/browser_586147.js
@@ -32,20 +32,20 @@ function test() {
ok(!tabs[2].hidden, "third is visible");
// Make the third tab hidden and then restore the modified state object
tabs[2].hidden = true;
observeOneRestore(function() {
let testWindow = Services.wm.getEnumerator("navigator:browser").getNext();
is(testWindow.gBrowser.visibleTabs.length, 1, "only restored 1 visible tab");
- let tabs = testWindow.gBrowser.tabs;
- ok(!tabs[0].hidden, "first is still visible");
- ok(tabs[1].hidden, "second tab is still hidden");
- ok(tabs[2].hidden, "third tab is now hidden");
+ let restoredTabs = testWindow.gBrowser.tabs;
+ ok(!restoredTabs[0].hidden, "first is still visible");
+ ok(restoredTabs[1].hidden, "second tab is still hidden");
+ ok(restoredTabs[2].hidden, "third tab is now hidden");
// Restore the original state and clean up now that we're done
gBrowser.removeTab(hiddenTab);
gBrowser.removeTab(extraTab);
finish();
});
ss.setBrowserState(JSON.stringify(stateObj));
--- a/browser/components/sessionstore/test/browser_590268.js
+++ b/browser/components/sessionstore/test/browser_590268.js
@@ -6,18 +6,16 @@ const NUM_TABS = 12;
var stateBackup = ss.getBrowserState();
function test() {
/** Test for Bug 590268 - Provide access to sessionstore tab data sooner **/
waitForExplicitFinish();
requestLongerTimeout(2);
- let startedTest = false;
-
// wasLoaded will be used to keep track of tabs that have already had SSTabRestoring
// fired for them.
let wasLoaded = { };
let restoringTabsCount = 0;
let restoredTabsCount = 0;
let uniq2 = { };
let uniq2Count = 0;
let state = { windows: [{ tabs: [] }] };
--- a/browser/components/sessionstore/test/browser_595601-restore_hidden.js
+++ b/browser/components/sessionstore/test/browser_595601-restore_hidden.js
@@ -1,12 +1,12 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
-var state = {windows:[{tabs:[
+var windowState = {windows:[{tabs:[
{entries:[{url:"http://example.com#1", triggeringPrincipal_base64}]},
{entries:[{url:"http://example.com#2", triggeringPrincipal_base64}]},
{entries:[{url:"http://example.com#3", triggeringPrincipal_base64}]},
{entries:[{url:"http://example.com#4", triggeringPrincipal_base64}]},
{entries:[{url:"http://example.com#5", triggeringPrincipal_base64}], hidden: true},
{entries:[{url:"http://example.com#6", triggeringPrincipal_base64}], hidden: true},
{entries:[{url:"http://example.com#7", triggeringPrincipal_base64}], hidden: true},
{entries:[{url:"http://example.com#8", triggeringPrincipal_base64}], hidden: true}
@@ -28,17 +28,17 @@ function test() {
}
function test_loadTabs(restoreHiddenTabs, callback) {
Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", restoreHiddenTabs);
let expectedTabs = restoreHiddenTabs ? 8 : 4;
let firstProgress = true;
- newWindowWithState(state, function(win, needsRestore, isRestoring) {
+ newWindowWithState(windowState, function(win, needsRestore, isRestoring) {
if (firstProgress) {
firstProgress = false;
is(isRestoring, 3, "restoring 3 tabs concurrently");
} else {
ok(isRestoring < 4, "restoring max. 3 tabs concurrently");
}
// We're explicity checking for (isRestoring == 1) here because the test
--- a/browser/components/sessionstore/test/browser_615394-SSWindowState_events.js
+++ b/browser/components/sessionstore/test/browser_615394-SSWindowState_events.js
@@ -195,17 +195,17 @@ function test_undoCloseTab() {
gBrowser.tabContainer.addEventListener("SSTabRestored", onSSTabRestored);
gBrowser.removeTab(tab);
reopenedTab = ss.undoCloseTab(window, 0);
}
function test_setWindowState() {
- let testState = {
+ let newState = {
windows: [{
tabs: [
{ entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }], extData: { "foo": "bar" } },
{ entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "baz": "qux" } }
]
}]
};
@@ -238,17 +238,17 @@ function test_setWindowState() {
runNextTest();
}
window.addEventListener("SSWindowStateBusy", onSSWindowStateBusy);
window.addEventListener("SSWindowStateReady", onSSWindowStateReady);
gBrowser.tabContainer.addEventListener("SSTabRestored", onSSTabRestored);
- ss.setWindowState(window, JSON.stringify(testState), true);
+ ss.setWindowState(window, JSON.stringify(newState), true);
}
function test_setBrowserState() {
// We'll track events per window so we are sure that they are each happening once
// pre window.
let windowEvents = {};
windowEvents[getOuterWindowID(window)] = { busyEventCount: 0, readyEventCount: 0 };
--- a/browser/components/sessionstore/test/browser_628270.js
+++ b/browser/components/sessionstore/test/browser_628270.js
@@ -5,20 +5,16 @@ function test() {
let assertNumberOfTabs = function(num, msg) {
is(gBrowser.tabs.length, num, msg);
}
let assertNumberOfVisibleTabs = function(num, msg) {
is(gBrowser.visibleTabs.length, num, msg);
}
- let assertNumberOfPinnedTabs = function(num, msg) {
- is(gBrowser._numPinnedTabs, num, msg);
- }
-
waitForExplicitFinish();
// check prerequisites
assertNumberOfTabs(1, "we start off with one tab");
// setup
let tab = gBrowser.addTab("about:mozilla");
--- a/browser/components/sessionstore/test/browser_644409-scratchpads.js
+++ b/browser/components/sessionstore/test/browser_644409-scratchpads.js
@@ -9,22 +9,22 @@ const testState = {
}],
scratchpads: [
{ text: "text1", executionContext: 1 },
{ text: "", executionContext: 2, filename: "test.js" }
]
};
// only finish() when correct number of windows opened
-var restored = [];
+var restoredStates = [];
function addState(state) {
- restored.push(state);
+ restoredStates.push(state);
- if (restored.length == testState.scratchpads.length) {
- ok(statesMatch(restored, testState.scratchpads),
+ if (restoredStates.length == testState.scratchpads.length) {
+ ok(statesMatch(restoredStates, testState.scratchpads),
"Two scratchpad windows restored");
Services.ww.unregisterNotification(windowObserver);
finish();
}
}
function test() {
--- a/browser/components/sessionstore/test/browser_662812.js
+++ b/browser/components/sessionstore/test/browser_662812.js
@@ -4,18 +4,18 @@
function test() {
waitForExplicitFinish();
window.addEventListener("SSWindowStateBusy", function() {
let state = JSON.parse(ss.getWindowState(window));
ok(state.windows[0].busy, "window is busy");
window.addEventListener("SSWindowStateReady", function() {
- let state = JSON.parse(ss.getWindowState(window));
- ok(!state.windows[0].busy, "window is not busy");
+ let state2 = JSON.parse(ss.getWindowState(window));
+ ok(!state2.windows[0].busy, "window is not busy");
executeSoon(() => {
gBrowser.removeTab(gBrowser.tabs[1]);
finish();
});
}, {once: true});
}, {once: true});
--- a/browser/components/sessionstore/test/browser_707862.js
+++ b/browser/components/sessionstore/test/browser_707862.js
@@ -24,20 +24,20 @@ function test() {
promiseTabState(tab, tabState).then(() => {
let sessionHistory = browser.sessionHistory;
let entry = sessionHistory.getEntryAtIndex(0, false);
entry.QueryInterface(Ci.nsISHContainer);
whenChildCount(entry, 1, function() {
whenChildCount(entry, 2, function() {
promiseBrowserLoaded(browser).then(() => {
- let sessionHistory = browser.sessionHistory;
- let entry = sessionHistory.getEntryAtIndex(0, false);
+ let newSessionHistory = browser.sessionHistory;
+ let newEntry = newSessionHistory.getEntryAtIndex(0, false);
- whenChildCount(entry, 0, function() {
+ whenChildCount(newEntry, 0, function() {
// Make sure that we reset the state.
let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank",
triggeringPrincipal_base64 }] }]}]};
waitForBrowserState(blankState, finish);
});
});
// reload the browser to deprecate the subframes
--- a/browser/components/sessionstore/test/browser_739531_sample.html
+++ b/browser/components/sessionstore/test/browser_739531_sample.html
@@ -1,25 +1,23 @@
<!-- originally a crash test for bug 713417
https://bug713417.bugzilla.mozilla.org/attachment.cgi?id=584240 -->
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script>
-function boom()
-{
+function boom() {
var w = document.getElementById("f").contentWindow;
var d = w.document;
- d.designMode = 'on';
+ d.designMode = "on";
var r = d.documentElement;
d.removeChild(r);
document.adoptNode(r);
}
</script>
</head>
<body onload="boom();">
<iframe src="data:text/html;charset=utf-8,1" id="f"></iframe>
</body>
</html>
-
--- a/browser/components/sessionstore/test/browser_819510_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_819510_perwindowpb.js
@@ -26,17 +26,17 @@ add_task(function* test_1() {
is(curState.selectedWindow, 5, "Last window opened is the one selected");
let state = JSON.parse(yield promiseRecoveryFileContents());
is(state.windows.length, 2,
"sessionstore state: 2 windows in data being written to disk");
is(state.selectedWindow, 2,
"Selected window is updated to match one of the saved windows");
- ok(state.windows.every(win => !win.isPrivate),
+ ok(state.windows.every(win2 => !win2.isPrivate),
"Saved windows are not private");
is(state._closedWindows.length, 0,
"sessionstore state: no closed windows in data being written to disk");
// Cleanup.
yield promiseAllButPrimaryWindowClosed();
forgetClosedWindows();
});
@@ -95,21 +95,21 @@ add_task(function* test_3() {
win.gBrowser.unpinTab(tab);
let state = JSON.parse(yield promiseRecoveryFileContents());
is(state.windows.length, 1,
"sessionstore state: 1 window in data being written to disk");
is(state.selectedWindow, 1,
"Selected window is updated to match one of the saved windows");
- ok(state.windows.every(win => !win.isPrivate),
+ ok(state.windows.every(win2 => !win2.isPrivate),
"Saved windows are not private");
is(state._closedWindows.length, 1,
"sessionstore state: 1 closed window in data being written to disk");
- ok(state._closedWindows.every(win => !win.isPrivate),
+ ok(state._closedWindows.every(win2 => !win2.isPrivate),
"Closed windows are not private");
// Cleanup.
yield promiseAllButPrimaryWindowClosed();
forgetClosedWindows();
});
function* promiseTabLoad(win, url) {
--- a/browser/components/sessionstore/test/browser_async_remove_tab.js
+++ b/browser/components/sessionstore/test/browser_async_remove_tab.js
@@ -28,22 +28,23 @@ function restoreClosedTabWithValue(rval)
if (index == -1) {
throw new Error("no closed tab found for given rval");
}
return ss.undoCloseTab(window, index);
}
function promiseNewLocationAndHistoryEntryReplaced(browser, snippet) {
- return ContentTask.spawn(browser, snippet, function* (snippet) {
+ /* eslint-env mozilla/frame-script */
+ return ContentTask.spawn(browser, snippet, function* (codeSnippet) {
let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
let shistory = webNavigation.sessionHistory;
// Evaluate the snippet that the changes the location.
- eval(snippet);
+ eval(codeSnippet);
return new Promise(resolve => {
let listener = {
OnHistoryReplaceEntry() {
shistory.removeSHistoryListener(this);
resolve();
},
--- a/browser/components/sessionstore/test/browser_async_window_flushing.js
+++ b/browser/components/sessionstore/test/browser_async_window_flushing.js
@@ -1,10 +1,13 @@
"use strict";
+// This file generates content tasks.
+/* eslint-env mozilla/frame-script */
+
const PAGE = "http://example.com/";
/**
* Tests that if we initially discard a window as not interesting
* to save in the closed windows array, that we revisit that decision
* after a window flush has completed.
*/
add_task(function* test_add_interesting_window() {
@@ -27,18 +30,18 @@ add_task(function* test_add_interesting_
// the closed windows array.
let newWin = yield BrowserTestUtils.openNewBrowserWindow();
let browser = newWin.gBrowser.selectedBrowser;
// Send a message that will cause the content to change its location
// to someplace more interesting. We've disabled auto updates from
// the browser, so the parent won't know about this
- yield ContentTask.spawn(browser, PAGE, function*(PAGE) {
- content.location = PAGE;
+ yield ContentTask.spawn(browser, PAGE, function*(newPage) {
+ content.location = newPage;
});
yield promiseContentMessage(browser, "ss-test:OnHistoryReplaceEntry");
// Clear out the userTypedValue so that the new window looks like
// it's really not worth restoring.
browser.userTypedValue = null;
--- a/browser/components/sessionstore/test/browser_background_tab_crash.js
+++ b/browser/components/sessionstore/test/browser_background_tab_crash.js
@@ -200,17 +200,17 @@ add_task(function* test_background_crash
yield crashBackgroundTabs([tab3, tab4]);
// Selecting the second tab should restore it.
let tabRestored = promiseTabRestored(tab2);
yield BrowserTestUtils.switchTab(gBrowser, tab2);
yield tabRestored;
// Selecting the fourth tab should now send it to the tab crashed page.
- let tabCrashedPagePromise =
+ tabCrashedPagePromise =
BrowserTestUtils.waitForContentEvent(tab4.linkedBrowser,
"AboutTabCrashedReady",
false, null, true);
yield BrowserTestUtils.switchTab(gBrowser, tab4);
yield tabCrashedPagePromise;
// Selecting the third tab should restore it.
tabRestored = promiseTabRestored(tab3);
--- a/browser/components/sessionstore/test/browser_broadcast.js
+++ b/browser/components/sessionstore/test/browser_broadcast.js
@@ -48,17 +48,17 @@ add_task(function* flush_on_duplicate()
add_task(function* flush_on_windowclose() {
let win = yield promiseNewWindow();
let tab = yield createTabWithStorageData(["http://example.com"], win);
let browser = tab.linkedBrowser;
yield modifySessionStorage(browser, {test: "on-window-close"});
yield BrowserTestUtils.closeWindow(win);
- let [{tabs: [_, {storage}]}] = JSON.parse(ss.getClosedWindowData());
+ let [{tabs: [, {storage}]}] = JSON.parse(ss.getClosedWindowData());
is(storage["http://example.com"].test, "on-window-close",
"sessionStorage data has been flushed when closing a window");
});
/**
* This test ensures that stale tab data is ignored when reusing a tab
* (via e.g. setTabState) and does not overwrite the new data.
*/
--- a/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_tabs.js
+++ b/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_tabs.js
@@ -41,19 +41,19 @@ function countingObserver() {
notificationsCount++;
}
function assertNotificationCount(count) {
is(notificationsCount, count, "The expected number of notifications was received.");
}
function* awaitNotification(callback) {
- let awaitNotification = TestUtils.topicObserved(TOPIC);
+ let notification = TestUtils.topicObserved(TOPIC);
executeSoon(callback);
- yield awaitNotification;
+ yield notification;
}
add_task(function* test_closedObjectsChangedNotifications() {
// Create a closed window so that when we do the purge we can expect a notification.
yield openAndCloseWindow("about:robots");
// Forget any previous closed windows or tabs from other tests that may have
// run in the same session.
--- a/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_windows.js
+++ b/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_windows.js
@@ -32,19 +32,19 @@ function countingObserver() {
notificationsCount++;
}
function assertNotificationCount(count) {
is(notificationsCount, count, "The expected number of notifications was received.");
}
function* awaitNotification(callback) {
- let awaitNotification = TestUtils.topicObserved(TOPIC);
+ let notification = TestUtils.topicObserved(TOPIC);
executeSoon(callback);
- yield awaitNotification;
+ yield notification;
}
add_task(function* test_closedObjectsChangedNotifications() {
// Create a closed window so that when we do the purge we know to expect a notification
yield openAndCloseWindow("about:robots");
// Forget any previous closed windows or tabs from other tests that may have
// run in the same session.
--- a/browser/components/sessionstore/test/browser_cookies.js
+++ b/browser/components/sessionstore/test/browser_cookies.js
@@ -92,24 +92,24 @@ var testCookieCollection = async functio
let value = Math.random();
urlParams.append("value", value);
if (params.domain) {
urlParams.append("domain", params.domain);
}
// Construct request URI.
- let uri = `${params.host}${PATH}browser_cookies.sjs?${urlParams}`;
+ let requestUri = `${params.host}${PATH}browser_cookies.sjs?${urlParams}`;
// Wait for the browser to load and the cookie to be set.
// These two events can probably happen in no particular order,
// so let's wait for them in parallel.
await Promise.all([
waitForNewCookie(),
- replaceCurrentURI(browser, uri)
+ replaceCurrentURI(browser, requestUri)
]);
// Check all URIs for which the cookie should be collected.
for (let uri of params.cookieURIs || []) {
await replaceCurrentURI(browser, uri);
// Check the cookie.
let cookie = getCookie();
--- a/browser/components/sessionstore/test/browser_crashedTabs.js
+++ b/browser/components/sessionstore/test/browser_crashedTabs.js
@@ -1,11 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
+// This file spawns content tasks.
+/* eslint-env mozilla/frame-script */
+
"use strict";
requestLongerTimeout(10);
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.";
// Turn off tab animations for testing and use a single content process
@@ -18,18 +21,18 @@ add_task(function* test_initialize() {
});
// Allow tabs to restore on demand so we can test pending states
Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
function clickButton(browser, id) {
info("Clicking " + id);
- let frame_script = (id) => {
- let button = content.document.getElementById(id);
+ let frame_script = (buttonId) => {
+ let button = content.document.getElementById(buttonId);
button.click();
};
let mm = browser.messageManager;
mm.loadFrameScript("data:,(" + frame_script.toString() + ")('" + id + "');", false);
}
/**
--- a/browser/components/sessionstore/test/browser_dying_cache.js
+++ b/browser/components/sessionstore/test/browser_dying_cache.js
@@ -22,19 +22,16 @@ add_task(function* test() {
yield promiseRemoveTab(win.gBrowser.tabs[0]);
// Make sure our window is still tracked by sessionstore
// and the window state is as expected.
ok("__SSi" in win, "window is being tracked by sessionstore");
ss.setWindowValue(win, "foo", "bar");
checkWindowState(win);
- let state = ss.getWindowState(win);
- let closedTabData = ss.getClosedTabData(win);
-
// Close our window.
yield BrowserTestUtils.closeWindow(win);
// SessionStore should no longer track our window
// but it should still report the same state.
ok(!("__SSi" in win), "sessionstore does no longer track our window");
checkWindowState(win);
--- a/browser/components/sessionstore/test/browser_formdata_cc.js
+++ b/browser/components/sessionstore/test/browser_formdata_cc.js
@@ -68,12 +68,12 @@ add_task(function* () {
yield createAndRemoveTab(number);
let [{state: {formdata}}] = JSON.parse(ss.getClosedTabData(window));
is(formdata.id.txt, number,
"numbers that are not valid CC numbers are still collected");
}
});
function setInputValue(browser, formValue) {
- return ContentTask.spawn(browser, formValue, function* (formValue) {
- content.document.getElementById("txt").setUserInput(formValue);
+ return ContentTask.spawn(browser, formValue, function* (newValue) {
+ content.document.getElementById("txt").setUserInput(newValue);
});
}
--- a/browser/components/sessionstore/test/browser_formdata_format.js
+++ b/browser/components/sessionstore/test/browser_formdata_format.js
@@ -60,17 +60,16 @@ function test() {
}
Promise.all(promises).then(() => finish(), ex => ok(false, ex));
}
async function testTabRestoreData(aFormData, aExpectedValue) {
let URL = ROOT + "browser_formdata_format_sample.html";
let tab = gBrowser.addTab("about:blank");
- let browser = tab.linkedBrowser;
aFormData.url = URL;
let tabState = { entries: [{ url: URL, triggeringPrincipal_base64 }], formdata: aFormData };
await promiseBrowserLoaded(tab.linkedBrowser);
await promiseTabState(tab, tabState);
await TabStateFlusher.flush(tab.linkedBrowser);
--- a/browser/components/sessionstore/test/browser_grouped_session_store.js
+++ b/browser/components/sessionstore/test/browser_grouped_session_store.js
@@ -18,23 +18,23 @@ add_task(function* () {
function* validate(browser, length, index) {
yield TabStateFlusher.flush(browser);
let {history} = TabStateCache.get(browser);
is(history.entries.length, length, "Lengths match");
for (let i = 0; i < length; ++i) {
is(history.entries[i].url, URIs[i], "URI at index " + i + " matches");
}
is(history.index, index, "Index matches");
- yield ContentTask.spawn(browser, [index, length], function* ([index, length]) {
+ yield ContentTask.spawn(browser, [index, length], function* ([expectedIndex, expectedLength]) {
let webNav = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation);
is(webNav.sessionHistory.globalIndexOffset + webNav.sessionHistory.index,
- index - 1, "In content index matches");
- is(webNav.canGoForward, index < length, "canGoForward is correct");
- is(webNav.canGoBack, index > 1, "canGoBack is correct");
+ expectedIndex - 1, "In content index matches");
+ is(webNav.canGoForward, expectedIndex < expectedLength, "canGoForward is correct");
+ is(webNav.canGoBack, expectedIndex > 1, "canGoBack is correct");
});
}
// Wait for a process change, followed by a locationchange event, and then
// fulfil the promise.
function awaitProcessChange(browser) {
return new Promise(resolve => {
let locChangeListener = {
--- a/browser/components/sessionstore/test/browser_multiple_navigateAndRestore.js
+++ b/browser/components/sessionstore/test/browser_multiple_navigateAndRestore.js
@@ -21,16 +21,17 @@ add_task(function*() {
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*(PAGE_2) {
+ /* eslint-env mozilla/frame-script */
+ yield ContentTask.spawn(browser, PAGE_2, function*(expectedURL) {
docShell.QueryInterface(Ci.nsIWebNavigation);
- Assert.equal(docShell.currentURI.spec, PAGE_2,
+ Assert.equal(docShell.currentURI.spec, expectedURL,
"Content should have PAGE_2 as the browser currentURI");
});
yield BrowserTestUtils.removeTab(tab);
});
--- a/browser/components/sessionstore/test/browser_pageStyle.js
+++ b/browser/components/sessionstore/test/browser_pageStyle.js
@@ -11,24 +11,24 @@ const URL_NESTED = getRootDirectory(gTes
*/
add_task(function* page_style() {
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
let sheets = yield getStyleSheets(browser);
// Enable all style sheets one by one.
- for (let [title, disabled] of sheets) {
+ for (let [title, /*disabled */] of sheets) {
yield enableStyleSheetsForSet(browser, title);
let tab2 = gBrowser.duplicateTab(tab);
yield promiseTabRestored(tab2);
- let sheets = yield getStyleSheets(tab2.linkedBrowser);
- let enabled = sheets.filter(([title, disabled]) => !disabled);
+ let tab2Sheets = yield getStyleSheets(tab2.linkedBrowser);
+ let enabled = tab2Sheets.filter(([, disabled]) => !disabled);
if (title.startsWith("fail_")) {
ok(!enabled.length, "didn't restore " + title);
} else {
is(enabled.length, 1, "restored one style sheet");
is(enabled[0][0], title, "restored correct sheet");
}
--- a/browser/components/sessionstore/test/browser_parentProcessRestoreHash.js
+++ b/browser/components/sessionstore/test/browser_parentProcessRestoreHash.js
@@ -56,17 +56,17 @@ let TestAboutPage = {
add_task(function* () {
TestAboutPage.register();
let tab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com/", true, true);
ok(tab.linkedBrowser.isRemoteBrowser, "Browser should be remote");
let resolveLocationChangePromise;
let locationChangePromise = new Promise(r => resolveLocationChangePromise = r);
let wpl = {
- onStateChange(wpl, request, state, status) {
+ onStateChange(listener, request, state, status) {
let location = request.QueryInterface(Ci.nsIChannel).originalURI;
// Ignore about:blank loads.
let docStop = Ci.nsIWebProgressListener.STATE_STOP |
Ci.nsIWebProgressListener.STATE_IS_NETWORK;
if (location.spec == "about:blank" || (state & docStop) != docStop) {
return;
}
is(location.spec, TESTURL, "Got the expected URL");
--- a/browser/components/sessionstore/test/browser_purge_shistory.js
+++ b/browser/components/sessionstore/test/browser_purge_shistory.js
@@ -1,8 +1,11 @@
+// This file spawns content tasks.
+/* eslint-env mozilla/frame-script */
+
"use strict";
/**
* This test checks that pending tabs are treated like fully loaded tabs when
* purging session history. Just like for fully loaded tabs we want to remove
* every but the current shistory entry.
*/
--- a/browser/components/sessionstore/test/browser_replace_load.js
+++ b/browser/components/sessionstore/test/browser_replace_load.js
@@ -1,8 +1,11 @@
+// This file spawns content tasks.
+/* eslint-env mozilla/frame-script */
+
"use strict";
const STATE = {
entries: [{url: "about:robots"}, {url: "about:mozilla"}],
selected: 2
};
/**
--- a/browser/components/sessionstore/test/browser_send_async_message_oom.js
+++ b/browser/components/sessionstore/test/browser_send_async_message_oom.js
@@ -1,11 +1,14 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
+// This file spawns content tasks.
+/* eslint-env mozilla/frame-script */
+
const {Services} = Cu.import("resource://gre/modules/Services.jsm", {});
const HISTOGRAM_NAME = "FX_SESSION_RESTORE_SEND_UPDATE_CAUSED_OOM";
/**
* Test that an OOM in sendAsyncMessage in a framescript will be reported
* to Telemetry.
*/
--- a/browser/components/sessionstore/test/browser_sessionStoreContainer.js
+++ b/browser/components/sessionstore/test/browser_sessionStoreContainer.js
@@ -1,12 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+// This file spawns content tasks.
+/* eslint-env mozilla/frame-script */
+
"use strict";
add_task(function* () {
for (let i = 0; i < 3; ++i) {
let tab = gBrowser.addTab("http://example.com/", { userContextId: i });
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
@@ -82,17 +85,16 @@ function* openTabInUserContext(userConte
let browser = gBrowser.getBrowserForTab(tab);
yield BrowserTestUtils.browserLoaded(browser);
return { tab, browser };
}
function waitForNewCookie() {
return new Promise(resolve => {
Services.obs.addObserver(function observer(subj, topic, data) {
- let cookie = subj.QueryInterface(Ci.nsICookie2);
if (data == "added") {
Services.obs.removeObserver(observer, topic);
resolve();
}
}, "cookie-changed", false);
});
}
@@ -117,25 +119,25 @@ add_task(function* test() {
// which should only be visible in that context.
let cookie = USER_CONTEXTS[userContextId];
// Open our tab in the given user context.
let { tab, browser } = yield* openTabInUserContext(userContextId);
yield Promise.all([
waitForNewCookie(),
- ContentTask.spawn(browser, cookie, cookie => content.document.cookie = cookie)
+ ContentTask.spawn(browser, cookie,
+ passedCookie => content.document.cookie = passedCookie)
]);
// Ensure the tab's session history is up-to-date.
yield TabStateFlusher.flush(browser);
lastSessionRestore = ss.getWindowState(window);
// Remove the tab.
gBrowser.removeTab(tab);
}
let state = JSON.parse(lastSessionRestore);
is(state.windows[0].cookies.length, USER_CONTEXTS.length,
"session restore should have each container's cookie");
});
-
--- a/browser/components/sessionstore/test/browser_switch_remoteness.js
+++ b/browser/components/sessionstore/test/browser_switch_remoteness.js
@@ -1,8 +1,11 @@
+// This file spawns content tasks.
+/* eslint-env mozilla/frame-script */
+
"use strict";
const URL = "http://example.com/browser_switch_remoteness_";
function countHistoryEntries(browser, expected) {
return ContentTask.spawn(browser, { expected }, function* (args) {
let Ci = Components.interfaces;
let webNavigation = docShell.QueryInterface(Ci.nsIWebNavigation);
--- a/browser/components/sessionstore/test/browser_upgrade_backup.js
+++ b/browser/components/sessionstore/test/browser_upgrade_backup.js
@@ -26,17 +26,16 @@ var prepareTest = Task.async(function* (
});
/**
* Retrieves all upgrade backups and returns them in an array.
*/
var getUpgradeBackups = Task.async(function* () {
let iterator;
let backups = [];
- let upgradeBackupPrefix = Paths.upgradeBackupPrefix;
try {
iterator = new OS.File.DirectoryIterator(Paths.backups);
// iterate over all files in the backup directory
yield iterator.forEach(function(file) {
// check the upgradeBackupPrefix
if (file.path.startsWith(Paths.upgradeBackupPrefix)) {
@@ -126,9 +125,8 @@ add_task(function* test_upgrade_backup_r
// check that exactly one new backup was created
is(newBackups.length, 1, "one new backup was created that was not removed");
yield SessionFile.write(""); // Second call to write() should not trigger anything
backups = yield getUpgradeBackups();
is(backups.length, maxUpgradeBackups, "second call to SessionFile.write() didn't create or remove more backups");
});
-
--- a/browser/components/sessionstore/test/browser_windowStateContainer.js
+++ b/browser/components/sessionstore/test/browser_windowStateContainer.js
@@ -1,8 +1,11 @@
+// This file spawns content tasks.
+/* eslint-env mozilla/frame-script */
+
"use strict";
requestLongerTimeout(2);
add_task(function* setup() {
yield SpecialPowers.pushPrefEnv({
set: [["dom.ipc.processCount", 1]]
});
@@ -114,9 +117,8 @@ add_task(function* () {
args.expectedId,
"The document has the correct userContextId");
});
}
yield BrowserTestUtils.closeWindow(win);
yield BrowserTestUtils.closeWindow(win2);
});
-
--- a/browser/components/sessionstore/test/content-forms.js
+++ b/browser/components/sessionstore/test/content-forms.js
@@ -1,12 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+/* eslint-env mozilla/frame-script */
+
"use strict";
var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
/**
* This frame script is only loaded for sessionstore mochitests. It contains
* a bunch of utility functions used to test form data collection and
* restoration in remote browsers.
--- a/browser/components/sessionstore/test/content.js
+++ b/browser/components/sessionstore/test/content.js
@@ -1,12 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+/* eslint-env mozilla/frame-script */
+
"use strict";
var Cu = Components.utils;
var Ci = Components.interfaces;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/sessionstore/FrameTree.jsm", this);
var gFrameTree = new FrameTree(this);
--- a/browser/components/sessionstore/test/head.js
+++ b/browser/components/sessionstore/test/head.js
@@ -10,26 +10,26 @@ const TAB_STATE_RESTORING = 2;
const ROOT = getRootDirectory(gTestPath);
const HTTPROOT = ROOT.replace("chrome://mochitests/content/", "http://example.com/");
const FRAME_SCRIPTS = [
ROOT + "content.js",
ROOT + "content-forms.js"
];
-var mm = Cc["@mozilla.org/globalmessagemanager;1"]
+var globalMM = Cc["@mozilla.org/globalmessagemanager;1"]
.getService(Ci.nsIMessageListenerManager);
for (let script of FRAME_SCRIPTS) {
- mm.loadFrameScript(script, true);
+ globalMM.loadFrameScript(script, true);
}
registerCleanupFunction(() => {
for (let script of FRAME_SCRIPTS) {
- mm.removeDelayedFrameScript(script, true);
+ globalMM.removeDelayedFrameScript(script, true);
}
});
const {Promise} = Cu.import("resource://gre/modules/Promise.jsm", {});
const {SessionStore} = Cu.import("resource:///modules/sessionstore/SessionStore.jsm", {});
const {SessionSaver} = Cu.import("resource:///modules/sessionstore/SessionSaver.jsm", {});
const {SessionFile} = Cu.import("resource:///modules/sessionstore/SessionFile.jsm", {});
const {TabState} = Cu.import("resource:///modules/sessionstore/TabState.jsm", {});
@@ -211,17 +211,17 @@ function waitForTopic(aTopic, aTimeout,
observing = false;
}
let timeout = setTimeout(function() {
removeObserver();
aCallback(false);
}, aTimeout);
- function observer(aSubject, aTopic, aData) {
+ function observer(subject, topic, data) {
removeObserver();
timeout = clearTimeout(timeout);
executeSoon(() => aCallback(true));
}
registerCleanupFunction(function() {
removeObserver();
if (timeout) {
@@ -282,17 +282,17 @@ var promiseForEachSessionRestoreFile = T
cb(data, key);
}
});
function promiseBrowserLoaded(aBrowser, ignoreSubFrames = true, wantLoad = null) {
return BrowserTestUtils.browserLoaded(aBrowser, !ignoreSubFrames, wantLoad);
}
-function whenWindowLoaded(aWindow, aCallback = next) {
+function whenWindowLoaded(aWindow, aCallback) {
aWindow.addEventListener("load", function() {
executeSoon(function executeWhenWindowLoaded() {
aCallback(aWindow);
});
}, {once: true});
}
function promiseWindowLoaded(aWindow) {
return new Promise(resolve => whenWindowLoaded(aWindow, resolve));
@@ -485,16 +485,20 @@ function promiseTabRestoring(tab) {
function sendMessage(browser, name, data = {}) {
browser.messageManager.sendAsyncMessage(name, data);
return promiseContentMessage(browser, name);
}
// This creates list of functions that we will map to their corresponding
// ss-test:* messages names. Those will be sent to the frame script and
// be used to read and modify form data.
+/* global getTextContent, getInputValue, setInputValue, getInputChecked
+ setInputChecked, getSelectedIndex, setSelectedIndex,
+ getMultipleSelected, setMultipleSelected, getFileNameArray,
+ setFileNameArray */
const FORM_HELPERS = [
"getTextContent",
"getInputValue", "setInputValue",
"getInputChecked", "setInputChecked",
"getSelectedIndex", "setSelectedIndex",
"getMultipleSelected", "setMultipleSelected",
"getFileNameArray", "setFileNameArray",
];
@@ -506,18 +510,18 @@ for (let name of FORM_HELPERS) {
// Removes the given tab immediately and returns a promise that resolves when
// all pending status updates (messages) of the closing tab have been received.
function promiseRemoveTab(tab) {
return BrowserTestUtils.removeTab(tab);
}
// Write DOMSessionStorage data to the given browser.
-function modifySessionStorage(browser, data, options = {}) {
- return ContentTask.spawn(browser, [data, options], function* ([data, options]) {
+function modifySessionStorage(browser, storageData, storageOptions = {}) {
+ return ContentTask.spawn(browser, [storageData, storageOptions], function* ([data, options]) {
let frame = content;
if (options && "frameIndex" in options) {
frame = content.frames[options.frameIndex];
}
let keys = new Set(Object.keys(data));
let storage = frame.sessionStorage;