Bug 1311347 - Enable eslint of browser/components/sessionstore/. Manual fixes. r=jaws

MozReview-Commit-ID: AupJNLZJ2Ye
This commit is contained in:
Mark Banner
2017-03-13 10:32:03 +00:00
parent 03b4896b94
commit e20b9ee0f3
59 changed files with 201 additions and 186 deletions

View File

@@ -288,7 +288,7 @@ ContentRestoreInternal.prototype = {
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)

View File

@@ -77,17 +77,17 @@ var PageStyleInternal = {
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);
}

View File

@@ -356,10 +356,10 @@ var CookieStore = {
/**
* 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 => {
@@ -381,7 +381,7 @@ var CookieStore = {
// <.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);
}

View File

@@ -856,7 +856,7 @@ var SessionStoreInternal = {
}
}
break;
case "SessionStore:restoreHistoryComplete":
case "SessionStore:restoreHistoryComplete": {
// Notify the tabbrowser that the tab chrome has been restored.
let tabData = TabState.collect(tab);
@@ -900,6 +900,7 @@ var SessionStoreInternal = {
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
@@ -945,7 +946,6 @@ var SessionStoreInternal = {
break;
default:
throw new Error(`received unknown message '${aMessage.name}'`);
break;
}
},
@@ -1141,17 +1141,15 @@ var SessionStoreInternal = {
// 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
@@ -1198,9 +1196,8 @@ var SessionStoreInternal = {
// 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];
}
@@ -2455,7 +2452,7 @@ var SessionStoreInternal = {
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] || "";
}
@@ -2786,10 +2783,10 @@ var SessionStoreInternal = {
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;
}
@@ -2879,7 +2876,6 @@ var SessionStoreInternal = {
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("|"));
@@ -3154,11 +3150,9 @@ var SessionStoreInternal = {
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 = [];
}
@@ -3742,14 +3736,13 @@ var SessionStoreInternal = {
}
}
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);
},

View File

@@ -2,6 +2,8 @@
* 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.
*/

View File

@@ -164,7 +164,6 @@ var TabStateInternal = {
// 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];

View File

@@ -2,11 +2,9 @@
* 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;
@@ -15,6 +13,11 @@ 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");
@@ -834,11 +837,10 @@ var MessageQueue = {
});
} 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
}
});
}
}

View File

@@ -32,7 +32,7 @@ function test() {
}
});
function test(aLambda) {
function checkNoThrow(aLambda) {
try {
return aLambda() || true;
} catch (ex) { }
@@ -73,9 +73,9 @@ function test() {
(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";
@@ -93,7 +93,6 @@ function test() {
"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 } };
@@ -117,15 +116,15 @@ function test() {
"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
@@ -135,14 +134,14 @@ function test() {
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,
@@ -153,8 +152,8 @@ function test() {
"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();
});

View File

@@ -5,39 +5,41 @@
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");
}

View File

@@ -16,9 +16,9 @@ add_task(function* () {
return false;
}
////////////////////////////
// setWindowValue, et al. //
////////////////////////////
/**
* setWindowValue, et al.
*/
let key = "Unique name: " + Date.now();
let value = "Unique value: " + Math.random();
@@ -37,9 +37,9 @@ add_task(function* () {
// 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();
@@ -63,9 +63,9 @@ add_task(function* () {
// clean up
yield promiseRemoveTab(tab);
/////////////////////////////////////
// getClosedTabCount, undoCloseTab //
/////////////////////////////////////
/**
* getClosedTabCount, undoCloseTab
*/
// get closed tab count
let count = ss.getClosedTabCount(window);

View File

@@ -76,7 +76,7 @@ add_task(function* setup() {
document.documentElement.setAttribute("windowtype", "navigator:testrunner");
registerCleanupFunction(() => {
document.documentElement.setAttribute("windowtype", "navigator:browser");
document.documentElement.setAttribute("windowtype", oldWinType);
});
});
@@ -471,4 +471,3 @@ add_task(function* test_mac_notifications() {
"Got expected browser-lastwindow-close-granted notifications");
});
});

View File

@@ -35,6 +35,7 @@ add_task(function* () {
});
function promiseSHistoryCount(browser) {
/* eslint-env mozilla/frame-script */
return ContentTask.spawn(browser, null, function* () {
return docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory.count;
});

View File

@@ -29,7 +29,7 @@ function test() {
// 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;
@@ -73,7 +73,8 @@ function test() {
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,

View File

@@ -24,15 +24,15 @@ function test() {
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.
@@ -41,12 +41,12 @@ function test() {
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!");

View File

@@ -18,7 +18,7 @@ function test() {
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");

View File

@@ -35,7 +35,7 @@
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);

View File

@@ -41,7 +41,7 @@ add_task(function* () {
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");

View File

@@ -44,7 +44,7 @@
}
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);

View File

@@ -21,7 +21,7 @@ function test() {
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");

View File

@@ -47,7 +47,7 @@
}
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);

View File

@@ -21,7 +21,7 @@ function test() {
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");

View File

@@ -12,8 +12,7 @@
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";
}

View File

@@ -49,7 +49,7 @@ function test() {
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");
@@ -57,7 +57,7 @@ function test() {
// 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");

View File

@@ -53,7 +53,7 @@ function test() {
} 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();

View File

@@ -37,10 +37,10 @@ function test() {
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);

View File

@@ -11,8 +11,6 @@ function test() {
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 = { };

View File

@@ -1,7 +1,7 @@
/* 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}]},
@@ -33,7 +33,7 @@ function test_loadTabs(restoreHiddenTabs, callback) {
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");

View File

@@ -200,7 +200,7 @@ function test_undoCloseTab() {
function test_setWindowState() {
let testState = {
let newState = {
windows: [{
tabs: [
{ entries: [{ url: "about:mozilla", triggeringPrincipal_base64 }], extData: { "foo": "bar" } },
@@ -243,7 +243,7 @@ function test_setWindowState() {
window.addEventListener("SSWindowStateReady", onSSWindowStateReady);
gBrowser.tabContainer.addEventListener("SSTabRestored", onSSTabRestored);
ss.setWindowState(window, JSON.stringify(testState), true);
ss.setWindowState(window, JSON.stringify(newState), true);
}

View File

@@ -10,10 +10,6 @@ function test() {
is(gBrowser.visibleTabs.length, num, msg);
}
let assertNumberOfPinnedTabs = function(num, msg) {
is(gBrowser._numPinnedTabs, num, msg);
}
waitForExplicitFinish();
// check prerequisites

View File

@@ -14,12 +14,12 @@ const testState = {
};
// 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);

View File

@@ -9,8 +9,8 @@ function test() {
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]);

View File

@@ -29,10 +29,10 @@ function test() {
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 }] }]}]};

View File

@@ -6,11 +6,10 @@
<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);
@@ -22,4 +21,3 @@ function boom()
<iframe src="data:text/html;charset=utf-8,1" id="f"></iframe>
</body>
</html>

View File

@@ -31,7 +31,7 @@ add_task(function* test_1() {
"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");
@@ -100,11 +100,11 @@ add_task(function* test_3() {
"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.

View File

@@ -33,12 +33,13 @@ function restoreClosedTabWithValue(rval) {
}
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 = {

View File

@@ -1,5 +1,8 @@
"use strict";
// This file generates content tasks.
/* eslint-env mozilla/frame-script */
const PAGE = "http://example.com/";
/**
@@ -32,8 +35,8 @@ add_task(function* test_add_interesting_window() {
// 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");

View File

@@ -205,7 +205,7 @@ add_task(function* test_background_crash_multiple() {
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);

View File

@@ -53,7 +53,7 @@ add_task(function* flush_on_windowclose() {
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");
});

View File

@@ -46,9 +46,9 @@ function assertNotificationCount(count) {
}
function* awaitNotification(callback) {
let awaitNotification = TestUtils.topicObserved(TOPIC);
let notification = TestUtils.topicObserved(TOPIC);
executeSoon(callback);
yield awaitNotification;
yield notification;
}
add_task(function* test_closedObjectsChangedNotifications() {

View File

@@ -37,9 +37,9 @@ function assertNotificationCount(count) {
}
function* awaitNotification(callback) {
let awaitNotification = TestUtils.topicObserved(TOPIC);
let notification = TestUtils.topicObserved(TOPIC);
executeSoon(callback);
yield awaitNotification;
yield notification;
}
add_task(function* test_closedObjectsChangedNotifications() {

View File

@@ -97,14 +97,14 @@ var testCookieCollection = async function(params) {
}
// 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.

View File

@@ -1,6 +1,9 @@
/* 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);
@@ -23,8 +26,8 @@ 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();
};

View File

@@ -27,9 +27,6 @@ add_task(function* test() {
ss.setWindowValue(win, "foo", "bar");
checkWindowState(win);
let state = ss.getWindowState(win);
let closedTabData = ss.getClosedTabData(win);
// Close our window.
yield BrowserTestUtils.closeWindow(win);

View File

@@ -73,7 +73,7 @@ add_task(function* () {
});
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);
});
}

View File

@@ -65,7 +65,6 @@ function test() {
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 };

View File

@@ -23,13 +23,13 @@ add_task(function* () {
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");
});
}

View File

@@ -26,9 +26,10 @@ add_task(function*() {
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");
});

View File

@@ -16,14 +16,14 @@ add_task(function* page_style() {
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);

View File

@@ -61,7 +61,7 @@ add_task(function* () {
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 |

View File

@@ -1,3 +1,6 @@
// This file spawns content tasks.
/* eslint-env mozilla/frame-script */
"use strict";
/**

View File

@@ -1,3 +1,6 @@
// This file spawns content tasks.
/* eslint-env mozilla/frame-script */
"use strict";
const STATE = {

View File

@@ -1,6 +1,9 @@
/* 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";

View File

@@ -2,6 +2,9 @@
* 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* () {
@@ -87,7 +90,6 @@ function* openTabInUserContext(userContextId) {
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();
@@ -122,7 +124,8 @@ add_task(function* test() {
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.
@@ -138,4 +141,3 @@ add_task(function* test() {
is(state.windows[0].cookies.length, USER_CONTEXTS.length,
"session restore should have each container's cookie");
});

View File

@@ -1,3 +1,6 @@
// This file spawns content tasks.
/* eslint-env mozilla/frame-script */
"use strict";
const URL = "http://example.com/browser_switch_remoteness_";

View File

@@ -31,7 +31,6 @@ var prepareTest = Task.async(function* () {
var getUpgradeBackups = Task.async(function* () {
let iterator;
let backups = [];
let upgradeBackupPrefix = Paths.upgradeBackupPrefix;
try {
iterator = new OS.File.DirectoryIterator(Paths.backups);
@@ -131,4 +130,3 @@ add_task(function* test_upgrade_backup_removal() {
backups = yield getUpgradeBackups();
is(backups.length, maxUpgradeBackups, "second call to SessionFile.write() didn't create or remove more backups");
});

View File

@@ -1,3 +1,6 @@
// This file spawns content tasks.
/* eslint-env mozilla/frame-script */
"use strict";
requestLongerTimeout(2);
@@ -119,4 +122,3 @@ add_task(function* () {
yield BrowserTestUtils.closeWindow(win);
yield BrowserTestUtils.closeWindow(win2);
});

View File

@@ -2,6 +2,8 @@
* 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;

View File

@@ -2,6 +2,8 @@
* 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;

View File

@@ -15,16 +15,16 @@ const FRAME_SCRIPTS = [
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);
}
});
@@ -216,7 +216,7 @@ function waitForTopic(aTopic, aTimeout, aCallback) {
aCallback(false);
}, aTimeout);
function observer(aSubject, aTopic, aData) {
function observer(subject, topic, data) {
removeObserver();
timeout = clearTimeout(timeout);
executeSoon(() => aCallback(true));
@@ -287,7 +287,7 @@ 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);
@@ -490,6 +490,10 @@ function sendMessage(browser, name, data = {}) {
// 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",
@@ -511,8 +515,8 @@ function promiseRemoveTab(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];