--- a/.eslintignore
+++ b/.eslintignore
@@ -61,26 +61,28 @@ browser/base/content/browser-social.js
browser/base/content/nsContextMenu.js
browser/base/content/sanitizeDialog.js
browser/base/content/test/general/file_csp_block_all_mixedcontent.html
browser/base/content/test/urlbar/file_blank_but_not_blank.html
browser/base/content/newtab/**
browser/components/downloads/**
browser/components/feeds/**
browser/components/privatebrowsing/**
-browser/components/sessionstore/**
browser/components/tabview/**
browser/components/translation/**
# generated files in cld2
browser/components/translation/cld2/cld-worker.js
browser/extensions/pdfjs/**
# generated or library files in pocket
browser/extensions/pocket/content/panels/js/tmpl.js
browser/extensions/pocket/content/panels/js/vendor/**
browser/locales/**
+# Test files that are really json not js, and don't need to be linted.
+browser/components/sessionstore/test/unit/data/sessionstore_valid.js
+browser/components/sessionstore/test/unit/data/sessionstore_invalid.js
# devtools/ exclusions
devtools/client/canvasdebugger/**
devtools/client/commandline/**
devtools/client/debugger/**
devtools/client/eyedropper/**
devtools/client/framework/**
!devtools/client/framework/selection.js
--- a/browser/components/sessionstore/ContentRestore.jsm
+++ b/browser/components/sessionstore/ContentRestore.jsm
@@ -235,21 +235,24 @@ ContentRestoreInternal.prototype = {
} else {
// If there's nothing to restore, we should still blank the page.
webNavigation.loadURI("about:blank",
Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_HISTORY,
null, null, null);
}
return true;
- } catch (ex if ex instanceof Ci.nsIException) {
- // Ignore page load errors, but return false to signal that the load never
- // happened.
- return false;
+ } catch (ex) {
+ if (ex instanceof Ci.nsIException) {
+ // Ignore page load errors, but return false to signal that the load never
+ // happened.
+ return false;
+ }
}
+ return null;
},
/**
* To be called after restoreHistory(). Removes all listeners needed for
* pending tabs and makes sure to notify when the tab finished loading.
*/
restoreTabContentStarted(finishCallback) {
// The reload listener is no longer needed.
--- a/browser/components/sessionstore/PrivacyFilter.jsm
+++ b/browser/components/sessionstore/PrivacyFilter.jsm
@@ -46,17 +46,17 @@ this.PrivacyFilter = Object.freeze({
* @param data The form data as collected from a tab.
* @return object
*/
filterFormData: function (data) {
// If the given form data object has an associated URL that we are not
// allowed to store data for, bail out. We explicitly discard data for any
// children as well even if storing data for those frames would be allowed.
if (data.url && !PrivacyLevel.check(data.url)) {
- return;
+ return null;
}
let retval = {};
for (let key of Object.keys(data)) {
if (key === "children") {
let recurse = child => this.filterFormData(child);
let children = data.children.map(recurse).filter(child => child);
--- a/browser/components/sessionstore/SessionFile.jsm
+++ b/browser/components/sessionstore/SessionFile.jsm
@@ -236,27 +236,29 @@ var SessionFileInternal = {
source: source,
parsed: parsed
};
Telemetry.getHistogramById("FX_SESSION_RESTORE_CORRUPT_FILE").
add(false);
Telemetry.getHistogramById("FX_SESSION_RESTORE_READ_FILE_MS").
add(Date.now() - startMs);
break;
- } catch (ex if ex instanceof OS.File.Error && ex.becauseNoSuchFile) {
- exists = false;
- } catch (ex if ex instanceof OS.File.Error) {
- // The file might be inaccessible due to wrong permissions
- // or similar failures. We'll just count it as "corrupted".
- console.error("Could not read session file ", ex, ex.stack);
- corrupted = true;
- } catch (ex if ex instanceof SyntaxError) {
- console.error("Corrupt session file (invalid JSON found) ", ex, ex.stack);
- // File is corrupted, try next file
- corrupted = true;
+ } catch (ex) {
+ if (ex instanceof OS.File.Error && ex.becauseNoSuchFile) {
+ exists = false;
+ } else if (ex instanceof OS.File.Error) {
+ // The file might be inaccessible due to wrong permissions
+ // or similar failures. We'll just count it as "corrupted".
+ console.error("Could not read session file ", ex, ex.stack);
+ corrupted = true;
+ } else if (ex instanceof SyntaxError) {
+ console.error("Corrupt session file (invalid JSON found) ", ex, ex.stack);
+ // File is corrupted, try next file
+ corrupted = true;
+ }
} finally {
if (exists) {
noFilesFound = false;
Telemetry.getHistogramById("FX_SESSION_RESTORE_CORRUPT_FILE").
add(corrupted);
}
}
}
@@ -377,17 +379,17 @@ var SessionFileInternal = {
});
},
wipe: function () {
return this._postToWorker("wipe");
},
_recordTelemetry: function(telemetry) {
- for (let id of Object.keys(telemetry)){
+ for (let id of Object.keys(telemetry)) {
let value = telemetry[id];
let samples = [];
if (Array.isArray(value)) {
samples.push(...value);
} else {
samples.push(value);
}
let histogram = Telemetry.getHistogramById(id);
--- a/browser/components/sessionstore/SessionMigration.jsm
+++ b/browser/components/sessionstore/SessionMigration.jsm
@@ -60,18 +60,18 @@ var SessionMigrationInternal = {
});
let url = "about:welcomeback";
let formdata = {id: {sessionData: state}, url};
return {windows: [{tabs: [{entries: [{url}], formdata}]}]};
},
/**
* Asynchronously read session restore state (JSON) from a path
*/
- readState: function(aPath) {
- return Task.spawn(function() {
+ readState: function* (aPath) {
+ return Task.spawn(function* () {
let bytes = yield OS.File.read(aPath);
let text = gDecoder.decode(bytes);
let state = JSON.parse(text);
throw new Task.Result(state);
});
},
/**
* Asynchronously write session restore state as JSON to a path
@@ -82,17 +82,17 @@ var SessionMigrationInternal = {
}
}
var SessionMigration = {
/**
* Migrate a limited set of session data from one path to another.
*/
migrate: function(aFromPath, aToPath) {
- return Task.spawn(function() {
+ return Task.spawn(function* () {
let inState = yield SessionMigrationInternal.readState(aFromPath);
let outState = SessionMigrationInternal.convertState(inState);
// Unfortunately, we can't use SessionStore's own SessionFile to
// write out the data because it has a dependency on the profile dir
// being known. When the migration runs, there is no guarantee that
// that's true.
yield SessionMigrationInternal.writeState(aToPath, outState);
});
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -875,17 +875,17 @@ var SessionStoreInternal = {
/**
* Record telemetry measurements stored in an object.
* @param telemetry
* {histogramID: value, ...} An object mapping histogramIDs to the
* value to be recorded for that ID,
*/
recordTelemetry: function (telemetry) {
- for (let histogramId in telemetry){
+ for (let histogramId in telemetry) {
Telemetry.getHistogramById(histogramId).add(telemetry[histogramId]);
}
},
/* ........ Window Event Handlers .............. */
/**
* Implement nsIDOMEventListener for handling various window and tab events
@@ -1542,17 +1542,17 @@ var SessionStoreInternal = {
progress.current = 0;
// We'll iterate through the Promise array, yielding each one, so as to
// provide useful progress information to AsyncShutdown.
for (let [win, promise] of windowPromises) {
yield promise;
this._collectWindowData(win);
progress.current++;
- };
+ }
// We must cache this because _getMostRecentBrowserWindow will always
// return null by the time quit-application occurs.
var activeWindow = this._getMostRecentBrowserWindow();
if (activeWindow)
this.activeWindowSSiCache = activeWindow.__SSi || "";
DirtyWindows.clear();
}),
@@ -2656,16 +2656,17 @@ var SessionStoreInternal = {
});
}
// Don't continue if the tab was closed before TabStateFlusher.flush resolves.
if (tab.linkedBrowser) {
let tabState = TabState.collect(tab);
return { index: tabState.index - 1, entries: tabState.entries }
}
+ return null;
},
/**
* See if aWindow is usable for use when restoring a previous session via
* restoreLastSession. If usable, prepare it for use.
*
* @param aWindow
* the window to inspect & prepare
--- a/browser/components/sessionstore/content/aboutSessionRestore.js
+++ b/browser/components/sessionstore/content/aboutSessionRestore.js
@@ -237,18 +237,22 @@ function toggleRowChecked(aIx) {
// (un)check all tabs of this window as well
for (let tab of item.tabs) {
tab.checked = item.checked;
treeView.treeBox.invalidateRow(gTreeData.indexOf(tab));
}
}
else {
// update the window's checkmark as well (0 means "partially checked")
- item.parent.checked = item.parent.tabs.every(isChecked) ? true :
- item.parent.tabs.some(isChecked) ? 0 : false;
+ item.parent.checked = false;
+ if (item.parent.tabs.every(isChecked)) {
+ item.parent.checked = true;
+ } else if (item.parent.tabs.some(isChecked)) {
+ item.parent.checked = 0;
+ }
treeView.treeBox.invalidateRow(gTreeData.indexOf(item.parent));
}
// we only disable the button when there's no cancel button.
if (document.getElementById("errorCancel")) {
document.getElementById("errorTryAgain").disabled = !gTreeData.some(isChecked);
}
}
@@ -276,17 +280,17 @@ function restoreSingleTab(aIx, aShifted)
var treeView = {
treeBox: null,
selection: null,
get rowCount() { return gTreeData.length; },
setTree: function(treeBox) { this.treeBox = treeBox; },
getCellText: function(idx, column) { return gTreeData[idx].label; },
isContainer: function(idx) { return "open" in gTreeData[idx]; },
- getCellValue: function(idx, column){ return gTreeData[idx].checked; },
+ getCellValue: function(idx, column) { return gTreeData[idx].checked; },
isContainerOpen: function(idx) { return gTreeData[idx].open; },
isContainerEmpty: function(idx) { return false; },
isSeparator: function(idx) { return false; },
isSorted: function() { return false; },
isEditable: function(idx, column) { return false; },
canDrop: function(idx, orientation, dt) { return false; },
getLevel: function(idx) { return this.isContainer(idx) ? 0 : 1; },
--- a/browser/components/sessionstore/content/content-sessionStore.js
+++ b/browser/components/sessionstore/content/content-sessionStore.js
@@ -819,23 +819,25 @@ var MessageQueue = {
try {
// 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
- });
+ } 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
+ });
+ }
}
},
};
EventListener.init();
MessageListener.init();
FormDataListener.init();
PageStyleListener.init();
--- a/browser/components/sessionstore/nsSessionStartup.js
+++ b/browser/components/sessionstore/nsSessionStartup.js
@@ -168,45 +168,40 @@ SessionStartup.prototype = {
let resumeFromCrash = Services.prefs.getBoolPref("browser.sessionstore.resume_from_crash");
CrashMonitor.previousCheckpoints.then(checkpoints => {
if (checkpoints) {
// If the previous session finished writing the final state, we'll
// assume there was no crash.
this._previousSessionCrashed = !checkpoints["sessionstore-final-state-write-complete"];
-
- } else {
- // If the Crash Monitor could not load a checkpoints file it will
- // provide null. This could occur on the first run after updating to
- // a version including the Crash Monitor, or if the checkpoints file
- // was removed, or on first startup with this profile, or after Firefox Reset.
-
- if (noFilesFound) {
- // There was no checkpoints file and no sessionstore.js or its backups
- // so we will assume that this was a fresh profile.
- this._previousSessionCrashed = false;
+ }
+ // If the Crash Monitor could not load a checkpoints file it will
+ // provide null. This could occur on the first run after updating to
+ // a version including the Crash Monitor, or if the checkpoints file
+ // was removed, or on first startup with this profile, or after Firefox Reset.
+ else if (noFilesFound) {
+ // There was no checkpoints file and no sessionstore.js or its backups
+ // so we will assume that this was a fresh profile.
+ this._previousSessionCrashed = false;
+ } else {
+ // If this is the first run after an update, sessionstore.js should
+ // still contain the session.state flag to indicate if the session
+ // crashed. If it is not present, we will assume this was not the first
+ // run after update and the checkpoints file was somehow corrupted or
+ // removed by a crash.
+ //
+ // If the session.state flag is present, we will fallback to using it
+ // for crash detection - If the last write of sessionstore.js had it
+ // set to "running", we crashed.
+ let stateFlagPresent = (this._initialState.session &&
+ this._initialState.session.state);
- } else {
- // If this is the first run after an update, sessionstore.js should
- // still contain the session.state flag to indicate if the session
- // crashed. If it is not present, we will assume this was not the first
- // run after update and the checkpoints file was somehow corrupted or
- // removed by a crash.
- //
- // If the session.state flag is present, we will fallback to using it
- // for crash detection - If the last write of sessionstore.js had it
- // set to "running", we crashed.
- let stateFlagPresent = (this._initialState.session &&
- this._initialState.session.state);
-
-
- this._previousSessionCrashed = !stateFlagPresent ||
- (this._initialState.session.state == STATE_RUNNING_STR);
- }
+ this._previousSessionCrashed = !stateFlagPresent ||
+ (this._initialState.session.state == STATE_RUNNING_STR);
}
// Report shutdown success via telemetry. Shortcoming here are
// being-killed-by-OS-shutdown-logic, shutdown freezing after
// session restore was written, etc.
Services.telemetry.getHistogramById("SHUTDOWN_OK").add(!this._previousSessionCrashed);
// set the startup type
--- a/browser/components/sessionstore/test/browser_248970_b_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_248970_b_perwindowpb.js
@@ -30,17 +30,17 @@ function test() {
for (let win of windowsToClose) {
yield BrowserTestUtils.closeWindow(win);
}
});
function test(aLambda) {
try {
return aLambda() || true;
- } catch(ex) { }
+ } catch (ex) { }
return false;
}
function getElementByXPath(aTab, aQuery) {
let doc = aTab.linkedBrowser.contentDocument;
let xptype = Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE;
return doc.evaluate(aQuery, doc, null, xptype, null).singleNodeValue;
}
--- a/browser/components/sessionstore/test/browser_393716.js
+++ b/browser/components/sessionstore/test/browser_393716.js
@@ -3,17 +3,17 @@
"use strict";
const URL = "about:config";
/**
* Bug 393716 - Basic tests for getTabState(), setTabState(), and duplicateTab().
*/
-add_task(function test_set_tabstate() {
+add_task(function* test_set_tabstate() {
let key = "Unique key: " + Date.now();
let value = "Unique value: " + Math.random();
// create a new tab
let tab = gBrowser.addTab(URL);
ss.setTabValue(tab, key, value);
yield promiseBrowserLoaded(tab.linkedBrowser);
@@ -30,17 +30,17 @@ add_task(function test_set_tabstate() {
"Got the expected state object (test URL)");
ok(state.extData && state.extData[key] == value,
"Got the expected state object (test manually set tab value)");
// clean up
gBrowser.removeTab(tab);
});
-add_task(function test_set_tabstate_and_duplicate() {
+add_task(function* test_set_tabstate_and_duplicate() {
let key2 = "key2";
let value2 = "Value " + Math.random();
let value3 = "Another value: " + Date.now();
let state = { entries: [{ url: URL }], extData: { key2: value2 } };
// create a new tab
let tab = gBrowser.addTab();
// set the tab's state
--- a/browser/components/sessionstore/test/browser_394759_behavior.js
+++ b/browser/components/sessionstore/test/browser_394759_behavior.js
@@ -68,9 +68,9 @@ add_task(function* test_closed_window_st
{isPopup: false},
{isPopup: false},
{isPopup: false},
{isPopup: false}];
let expectedResults2 = {mac: {popup: 0, normal: 3},
other: {popup: 0, normal: 3}};
yield testWindows(windowsToOpen2, expectedResults2);
-});
\ No newline at end of file
+});
--- a/browser/components/sessionstore/test/browser_456342.js
+++ b/browser/components/sessionstore/test/browser_456342.js
@@ -3,17 +3,17 @@
"use strict";
const URL = ROOT + "browser_456342_sample.xhtml";
/**
* Bug 456342 - Restore values from non-standard input field types.
*/
-add_task(function test_restore_nonstandard_input_values() {
+add_task(function* test_restore_nonstandard_input_values() {
// Add tab with various non-standard input field types.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Fill in form values.
let expectedValue = Math.random();
yield setFormElementValues(browser, {value: expectedValue});
--- a/browser/components/sessionstore/test/browser_459906_sample.html
+++ b/browser/components/sessionstore/test/browser_459906_sample.html
@@ -31,11 +31,11 @@
r.overrideMimeType("text/plain");
r.send(null);
}
return "on";
});
frames[1].document.designMode = "on";
- };
+ }
</script>
</body>
--- a/browser/components/sessionstore/test/browser_461743_sample.html
+++ b/browser/components/sessionstore/test/browser_461743_sample.html
@@ -46,11 +46,11 @@
}
frames[0].document.addEventListener("DOMNodeInserted", loadChrome, true);
frames[0].document.addEventListener("DOMNodeInserted", delay, true);
frames[0].document.addEventListener("DOMNodeInserted", loadExploit, true);
frames[0].document.addEventListener("DOMNodeInserted", done, true);
frames[0].document.designMode = "on";
- };
+ }
</script>
</body>
--- a/browser/components/sessionstore/test/browser_463205.js
+++ b/browser/components/sessionstore/test/browser_463205.js
@@ -5,17 +5,17 @@
const URL = ROOT + "browser_463205_sample.html";
/**
* Bug 463205 - Check URLs before restoring form data to make sure a malicious
* website can't modify frame URLs and make us inject form data into the wrong
* web pages.
*/
-add_task(function test_check_urls_before_restoring() {
+add_task(function* test_check_urls_before_restoring() {
// Add a blank tab.
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Restore form data with a valid URL.
yield promiseTabState(tab, getState(URL));
--- a/browser/components/sessionstore/test/browser_466937.js
+++ b/browser/components/sessionstore/test/browser_466937.js
@@ -3,17 +3,17 @@
"use strict";
const URL = ROOT + "browser_466937_sample.html";
/**
* Bug 466937 - Prevent file stealing with sessionstore.
*/
-add_task(function test_prevent_file_stealing() {
+add_task(function* test_prevent_file_stealing() {
// Add a tab with some file input fields.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Generate a path to a 'secret' file.
let file = Services.dirsvc.get("TmpD", Ci.nsIFile);
file.append("466937_test.file");
--- a/browser/components/sessionstore/test/browser_467409-backslashplosion.js
+++ b/browser/components/sessionstore/test/browser_467409-backslashplosion.js
@@ -25,17 +25,17 @@ const STATE3 = createEntries(JSON.string
function createEntries(sessionData) {
return {
entries: [{url: "about:sessionrestore"}],
formdata: {id: {sessionData: sessionData}, url: "about:sessionrestore"}
};
}
-add_task(function test_nested_about_sessionrestore() {
+add_task(function* test_nested_about_sessionrestore() {
// Prepare a blank tab.
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// test 1
yield promiseTabState(tab, STATE);
yield checkState("test1", tab);
--- a/browser/components/sessionstore/test/browser_485482.js
+++ b/browser/components/sessionstore/test/browser_485482.js
@@ -4,17 +4,17 @@
"use strict";
const URL = ROOT + "browser_485482_sample.html";
/**
* Bug 485482 - Make sure that we produce valid XPath expressions even for very
* weird HTML documents.
*/
-add_task(function test_xpath_exp_for_strange_documents() {
+add_task(function* test_xpath_exp_for_strange_documents() {
// Load a page with weird tag names.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Fill in some values.
let uniqueValue = Math.random();
yield setInputValue(browser, {selector: "input[type=text]", value: uniqueValue});
--- a/browser/components/sessionstore/test/browser_506482.js
+++ b/browser/components/sessionstore/test/browser_506482.js
@@ -14,20 +14,20 @@ function test() {
get("ProfD", Ci.nsIFile);
function getSessionstoreFile() {
let sessionStoreJS = profilePath.clone();
sessionStoreJS.append("sessionstore.js");
return sessionStoreJS;
}
function getSessionstorejsModificationTime() {
let file = getSessionstoreFile();
- if (file.exists())
+ if (file.exists()) {
return file.lastModifiedTime;
- else
- return -1;
+ }
+ return -1;
}
// delete existing sessionstore.js, to make sure we're not reading
// the mtime of an old one initially.
let sessionStoreJS = getSessionstoreFile();
if (sessionStoreJS.exists())
sessionStoreJS.remove(false);
--- a/browser/components/sessionstore/test/browser_522545.js
+++ b/browser/components/sessionstore/test/browser_522545.js
@@ -187,17 +187,17 @@ function test() {
// Make sure this tab isn't loading and state is clear before we test.
is(browser.userTypedValue, null, "userTypedValue is empty to start");
ok(!browser.didStartLoadSinceLastUserTyping(),
"Initially, no load should be ongoing");
let inputText = "example.org";
gURLBar.focus();
gURLBar.value = inputText.slice(0, -1);
- EventUtils.synthesizeKey(inputText.slice(-1) , {});
+ EventUtils.synthesizeKey(inputText.slice(-1), {});
executeSoon(function () {
is(browser.userTypedValue, "example.org",
"userTypedValue was set when changing URLBar value");
ok(!browser.didStartLoadSinceLastUserTyping(),
"No load started since changing URLBar value");
// Now make sure ss gets these values too
--- a/browser/components/sessionstore/test/browser_528776.js
+++ b/browser/components/sessionstore/test/browser_528776.js
@@ -6,16 +6,16 @@ function browserWindowsCount(expected) {
++count;
}
is(count, expected,
"number of open browser windows according to nsIWindowMediator");
is(JSON.parse(ss.getBrowserState()).windows.length, expected,
"number of open browser windows according to getBrowserState");
}
-add_task(function() {
+add_task(function* () {
browserWindowsCount(1);
let win = yield BrowserTestUtils.openNewBrowserWindow();
browserWindowsCount(2);
yield BrowserTestUtils.closeWindow(win);
browserWindowsCount(1);
});
--- a/browser/components/sessionstore/test/browser_586147.js
+++ b/browser/components/sessionstore/test/browser_586147.js
@@ -3,17 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
function observeOneRestore(callback) {
let topic = "sessionstore-browser-state-restored";
Services.obs.addObserver(function onRestore() {
Services.obs.removeObserver(onRestore, topic);
callback();
}, topic, false);
-};
+}
function test() {
waitForExplicitFinish();
// There should be one tab when we start the test
let [origTab] = gBrowser.visibleTabs;
let hiddenTab = gBrowser.addTab();
--- a/browser/components/sessionstore/test/browser_597071.js
+++ b/browser/components/sessionstore/test/browser_597071.js
@@ -1,16 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Bug 597071 - Closed windows should only be resurrected when there is a single
* popup window
*/
-add_task(function test_close_last_nonpopup_window() {
+add_task(function* test_close_last_nonpopup_window() {
// Purge the list of closed windows.
forgetClosedWindows();
let oldState = ss.getWindowState(window);
let popupState = {windows: [
{tabs: [{entries: []}], isPopup: true, hidden: "toolbar"}
]};
--- a/browser/components/sessionstore/test/browser_662743.js
+++ b/browser/components/sessionstore/test/browser_662743.js
@@ -14,29 +14,29 @@ function test() {
let testTabCount = 0;
let formData = [
// default case
{ },
// new format
// index doesn't match value (testing an option in between (two))
- { id:{ "select_id": {"selectedIndex":0,"value":"val2"} } },
+ { id:{ "select_id": {"selectedIndex":0, "value":"val2"} } },
// index doesn't match value (testing an invalid value)
- { id:{ "select_id": {"selectedIndex":4,"value":"val8"} } },
+ { id:{ "select_id": {"selectedIndex":4, "value":"val8"} } },
// index doesn't match value (testing an invalid index)
- { id:{ "select_id": {"selectedIndex":8,"value":"val5"} } },
+ { id:{ "select_id": {"selectedIndex":8, "value":"val5"} } },
// index and value match position zero
- { id:{ "select_id": {"selectedIndex":0,"value":"val0"} }, xpath: {} },
+ { id:{ "select_id": {"selectedIndex":0, "value":"val0"} }, xpath: {} },
// index doesn't match value (testing the last option (seven))
- { id:{},"xpath":{ "/xhtml:html/xhtml:body/xhtml:select[@name='select_name']": {"selectedIndex":1,"value":"val7"} } },
+ { id:{}, "xpath":{ "/xhtml:html/xhtml:body/xhtml:select[@name='select_name']": {"selectedIndex":1, "value":"val7"} } },
// index and value match the default option "selectedIndex":3,"value":"val3"
- { xpath: { "/xhtml:html/xhtml:body/xhtml:select[@name='select_name']" : {"selectedIndex":3,"value":"val3"} } },
+ { xpath: { "/xhtml:html/xhtml:body/xhtml:select[@name='select_name']" : {"selectedIndex":3, "value":"val3"} } },
// index matches default option however it doesn't match value
- { id:{ "select_id": {"selectedIndex":3,"value":"val4"} } },
+ { id:{ "select_id": {"selectedIndex":3, "value":"val4"} } },
];
let expectedValues = [
null, // default value
"val2",
null, // default value (invalid value)
"val5", // value is still valid (even it has an invalid index)
"val0",
--- a/browser/components/sessionstore/test/browser_911547.js
+++ b/browser/components/sessionstore/test/browser_911547.js
@@ -11,17 +11,17 @@ add_task(function* test() {
let tab = gBrowser.selectedTab = gBrowser.addTab(testURL);
gBrowser.selectedTab = tab;
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// this is a baseline to ensure CSP is active
// attempt to inject and run a script via inline (pre-restore, allowed)
- injectInlineScript(browser,'document.getElementById("test_id").value = "fail";');
+ injectInlineScript(browser, 'document.getElementById("test_id").value = "fail";');
is(browser.contentDocument.getElementById("test_id").value, "ok",
"CSP should block the inline script that modifies test_id");
// attempt to click a link to a data: URI (will inherit the CSP of the
// origin document) and navigate to the data URI in the link.
browser.contentDocument.getElementById("test_data_link").click();
yield promiseBrowserLoaded(browser);
--- a/browser/components/sessionstore/test/browser_broadcast.js
+++ b/browser/components/sessionstore/test/browser_broadcast.js
@@ -4,33 +4,33 @@
"use strict";
const INITIAL_VALUE = "browser_broadcast.js-initial-value-" + Date.now();
/**
* This test ensures we won't lose tab data queued in the content script when
* closing a tab.
*/
-add_task(function flush_on_tabclose() {
+add_task(function* flush_on_tabclose() {
let tab = yield createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser;
yield modifySessionStorage(browser, {test: "on-tab-close"});
yield promiseRemoveTab(tab);
let [{state: {storage}}] = JSON.parse(ss.getClosedTabData(window));
is(storage["http://example.com"].test, "on-tab-close",
"sessionStorage data has been flushed on TabClose");
});
/**
* This test ensures we won't lose tab data queued in the content script when
* duplicating a tab.
*/
-add_task(function flush_on_duplicate() {
+add_task(function* flush_on_duplicate() {
let tab = yield createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser;
yield modifySessionStorage(browser, {test: "on-duplicate"});
let tab2 = ss.duplicateTab(window, tab);
yield promiseTabRestored(tab2);
yield promiseRemoveTab(tab2);
@@ -40,34 +40,34 @@ add_task(function flush_on_duplicate() {
gBrowser.removeTab(tab);
});
/**
* This test ensures we won't lose tab data queued in the content script when
* a window is closed.
*/
-add_task(function flush_on_windowclose() {
+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());
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.
*/
-add_task(function flush_on_settabstate() {
+add_task(function* flush_on_settabstate() {
let tab = yield createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser;
// Flush to make sure our tab state is up-to-date.
yield TabStateFlusher.flush(browser);
let state = ss.getTabState(tab);
yield modifySessionStorage(browser, {test: "on-set-tab-state"});
@@ -85,17 +85,17 @@ add_task(function flush_on_settabstate()
gBrowser.removeTab(tab);
});
/**
* This test ensures that we won't lose tab data that has been sent
* asynchronously just before closing a tab. Flushing must re-send all data
* that hasn't been received by chrome, yet.
*/
-add_task(function flush_on_tabclose_racy() {
+add_task(function* flush_on_tabclose_racy() {
let tab = yield createTabWithStorageData(["http://example.com"]);
let browser = tab.linkedBrowser;
// Flush to make sure we start with an empty queue.
yield TabStateFlusher.flush(browser);
yield modifySessionStorage(browser, {test: "on-tab-close-racy"});
@@ -111,17 +111,17 @@ add_task(function flush_on_tabclose_racy
function promiseNewWindow() {
let deferred = Promise.defer();
whenNewWindowLoaded({private: false}, deferred.resolve);
return deferred.promise;
}
function createTabWithStorageData(urls, win = window) {
- return Task.spawn(function task() {
+ return Task.spawn(function* task() {
let tab = win.gBrowser.addTab();
let browser = tab.linkedBrowser;
for (let url of urls) {
browser.loadURI(url);
yield promiseBrowserLoaded(browser);
yield modifySessionStorage(browser, {test: INITIAL_VALUE});
}
--- a/browser/components/sessionstore/test/browser_capabilities.js
+++ b/browser/components/sessionstore/test/browser_capabilities.js
@@ -3,17 +3,17 @@
"use strict";
/**
* These tests ensures that disabling features by flipping nsIDocShell.allow*
* properties are (re)stored as disabled. Disallowed features must be
* re-enabled when the tab is re-used by another tab restoration.
*/
-add_task(function docshell_capabilities() {
+add_task(function* docshell_capabilities() {
let tab = yield createTab();
let browser = tab.linkedBrowser;
let docShell = browser.docShell;
// Get the list of capabilities for docShells.
let flags = Object.keys(docShell).filter(k => k.startsWith("allow"));
// Check that everything is allowed by default for new tabs.
--- a/browser/components/sessionstore/test/browser_cleaner.js
+++ b/browser/components/sessionstore/test/browser_cleaner.js
@@ -23,17 +23,17 @@ function isRecent(stamp) {
is(typeof stamp, "number", "This is a timestamp");
return Date.now() - stamp <= 60000;
}
function promiseCleanup () {
info("Cleaning up browser");
return promiseBrowserState(getClosedState());
-};
+}
function getClosedState() {
return Cu.cloneInto(CLOSED_STATE, {});
}
var CLOSED_STATE;
add_task(function* init() {
--- a/browser/components/sessionstore/test/browser_cookies.js
+++ b/browser/components/sessionstore/test/browser_cookies.js
@@ -79,17 +79,17 @@ add_task(function* test_run() {
});
});
/**
* Generic test function to check sessionstore's cookie collection module with
* different cookie domains given in the Set-Cookie header. See above for some
* usage examples.
*/
-var testCookieCollection = Task.async(function (params) {
+var testCookieCollection = Task.async(function* (params) {
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
let urlParams = new URLSearchParams();
let value = Math.random();
urlParams.append("value", value);
if (params.domain) {
--- a/browser/components/sessionstore/test/browser_crashedTabs.js
+++ b/browser/components/sessionstore/test/browser_crashedTabs.js
@@ -120,17 +120,17 @@ function promiseTabCrashedReady(browser)
}, false, true);
});
}
/**
* Checks that if a tab crashes, that information about the tab crashed
* page does not get added to the tab history.
*/
-add_task(function test_crash_page_not_in_history() {
+add_task(function* test_crash_page_not_in_history() {
let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser;
ok(browser.isRemoteBrowser, "Should be a remote browser");
yield promiseBrowserLoaded(browser);
browser.loadURI(PAGE_1);
yield promiseBrowserLoaded(browser);
@@ -149,17 +149,17 @@ add_task(function test_crash_page_not_in
gBrowser.removeTab(newTab);
});
/**
* Checks that if a tab crashes, that when we browse away from that page
* to a non-blacklisted site (so the browser becomes remote again), that
* we record history for that new visit.
*/
-add_task(function test_revived_history_from_remote() {
+add_task(function* test_revived_history_from_remote() {
let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser;
ok(browser.isRemoteBrowser, "Should be a remote browser");
yield promiseBrowserLoaded(browser);
browser.loadURI(PAGE_1);
yield promiseBrowserLoaded(browser);
@@ -188,17 +188,17 @@ add_task(function test_revived_history_f
gBrowser.removeTab(newTab);
});
/**
* Checks that if a tab crashes, that when we browse away from that page
* to a blacklisted site (so the browser stays non-remote), that
* we record history for that new visit.
*/
-add_task(function test_revived_history_from_non_remote() {
+add_task(function* test_revived_history_from_non_remote() {
let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser;
ok(browser.isRemoteBrowser, "Should be a remote browser");
yield promiseBrowserLoaded(browser);
browser.loadURI(PAGE_1);
yield promiseBrowserLoaded(browser);
@@ -226,17 +226,17 @@ add_task(function test_revived_history_f
gBrowser.removeTab(newTab);
});
/**
* Checks that we can revive a crashed tab back to the page that
* it was on when it crashed.
*/
-add_task(function test_revive_tab_from_session_store() {
+add_task(function* test_revive_tab_from_session_store() {
let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser;
ok(browser.isRemoteBrowser, "Should be a remote browser");
yield promiseBrowserLoaded(browser);
browser.loadURI(PAGE_1);
yield promiseBrowserLoaded(browser);
@@ -279,17 +279,17 @@ add_task(function test_revive_tab_from_s
gBrowser.removeTab(newTab);
gBrowser.removeTab(newTab2);
});
/**
* Checks that we can revive multiple crashed tabs back to the pages
* that they were on when they crashed.
*/
-add_task(function test_revive_all_tabs_from_session_store() {
+add_task(function* test_revive_all_tabs_from_session_store() {
let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser;
ok(browser.isRemoteBrowser, "Should be a remote browser");
yield promiseBrowserLoaded(browser);
browser.loadURI(PAGE_1);
yield promiseBrowserLoaded(browser);
@@ -339,17 +339,17 @@ add_task(function test_revive_all_tabs_f
yield BrowserTestUtils.closeWindow(win2);
gBrowser.removeTab(newTab);
});
/**
* Checks that about:tabcrashed can close the current tab
*/
-add_task(function test_close_tab_after_crash() {
+add_task(function* test_close_tab_after_crash() {
let newTab = gBrowser.addTab();
gBrowser.selectedTab = newTab;
let browser = newTab.linkedBrowser;
ok(browser.isRemoteBrowser, "Should be a remote browser");
yield promiseBrowserLoaded(browser);
browser.loadURI(PAGE_1);
yield promiseBrowserLoaded(browser);
--- a/browser/components/sessionstore/test/browser_dying_cache.js
+++ b/browser/components/sessionstore/test/browser_dying_cache.js
@@ -58,9 +58,10 @@ function checkWindowState(window) {
}
function shouldThrow(f) {
try {
f();
} catch (e) {
return true;
}
+ return null;
}
--- a/browser/components/sessionstore/test/browser_dynamic_frames.js
+++ b/browser/components/sessionstore/test/browser_dynamic_frames.js
@@ -2,17 +2,17 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Ensure that static frames of framesets are serialized but dynamically
* inserted iframes are ignored.
*/
-add_task(function () {
+add_task(function* () {
// This URL has the following frames:
// + data:text/html,A (static)
// + data:text/html,B (static)
// + data:text/html,C (dynamic iframe)
const URL = "data:text/html;charset=utf-8," +
"<frameset cols=50%25,50%25><frame src='data:text/html,A'>" +
"<frame src='data:text/html,B'></frameset>" +
"<script>var i=document.createElement('iframe');" +
@@ -40,17 +40,17 @@ add_task(function () {
gBrowser.removeTab(tab);
});
/**
* Ensure that iframes created by the network parser are serialized but
* dynamically inserted iframes are ignored. Navigating a subframe should
* create a second root entry that doesn't contain any dynamic children either.
*/
-add_task(function () {
+add_task(function* () {
// This URL has the following frames:
// + data:text/html,A (static)
// + data:text/html,C (dynamic iframe)
const URL = "data:text/html;charset=utf-8," +
"<iframe name=t src='data:text/html,A'></iframe>" +
"<a id=lnk href='data:text/html,B' target=t>clickme</a>" +
"<script>var i=document.createElement('iframe');" +
"i.setAttribute('src', 'data:text/html,C');" +
--- a/browser/components/sessionstore/test/browser_form_restore_events.js
+++ b/browser/components/sessionstore/test/browser_form_restore_events.js
@@ -4,17 +4,17 @@
"use strict";
const URL = ROOT + "browser_form_restore_events_sample.html";
/**
* Originally a test for Bug 476161, but then expanded to include all input
* types in bug 640136.
*/
-add_task(function () {
+add_task(function* () {
// Load a page with some form elements.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// text fields
yield setInputValue(browser, {id: "modify01", value: Math.random()});
yield setInputValue(browser, {id: "modify02", value: Date.now()});
@@ -24,17 +24,17 @@ add_task(function () {
yield setInputValue(browser, {id: "modify04", value: Date.now()});
// file
let file = Services.dirsvc.get("TmpD", Ci.nsIFile);
yield setInputValue(browser, {id: "modify05", value: file.path});
// select
yield setSelectedIndex(browser, {id: "modify06", index: 1});
- yield setMultipleSelected(browser, {id: "modify07", indices: [0,1,2]});
+ yield setMultipleSelected(browser, {id: "modify07", indices: [0, 1, 2]});
// checkbox
yield setInputChecked(browser, {id: "modify08", checked: true});
yield setInputChecked(browser, {id: "modify09", checked: false});
// radio
yield setInputChecked(browser, {id: "modify10", checked: true});
yield setInputChecked(browser, {id: "modify11", checked: true});
--- a/browser/components/sessionstore/test/browser_formdata.js
+++ b/browser/components/sessionstore/test/browser_formdata.js
@@ -4,27 +4,27 @@
"use strict";
requestLongerTimeout(2);
/**
* This test ensures that form data collection respects the privacy level as
* set by the user.
*/
-add_task(function test_formdata() {
+add_task(function* test_formdata() {
const URL = "http://mochi.test:8888/browser/browser/components/" +
"sessionstore/test/browser_formdata_sample.html";
const OUTER_VALUE = "browser_formdata_" + Math.random();
const INNER_VALUE = "browser_formdata_" + Math.random();
// Creates a tab, loads a page with some form fields,
// modifies their values and closes the tab.
- function createAndRemoveTab() {
- return Task.spawn(function () {
+ function* createAndRemoveTab() {
+ return Task.spawn(function* () {
// Create a new tab.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Modify form data.
yield setInputValue(browser, {id: "txt", value: OUTER_VALUE});
yield setInputValue(browser, {id: "txt", value: INNER_VALUE, frame: 0});
@@ -58,17 +58,17 @@ add_task(function test_formdata() {
Services.prefs.clearUserPref("browser.sessionstore.privacy_level");
});
/**
* This test ensures that a malicious website can't trick us into restoring
* form data into a wrong website and that we always check the stored URL
* before doing so.
*/
-add_task(function test_url_check() {
+add_task(function* test_url_check() {
const URL = "data:text/html;charset=utf-8,<input%20id=input>";
const VALUE = "value-" + Math.random();
// Create a tab with an iframe containing an input field.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
@@ -93,17 +93,17 @@ add_task(function test_url_check() {
// Cleanup.
gBrowser.removeTab(tab);
});
/**
* This test ensures that collecting form data works as expected when having
* nested frame sets.
*/
-add_task(function test_nested() {
+add_task(function* test_nested() {
const URL = "data:text/html;charset=utf-8," +
"<iframe src='data:text/html;charset=utf-8," +
"<input autofocus=true>'/>";
const FORM_DATA = {
children: [{
xpath: {"/xhtml:html/xhtml:body/xhtml:input": "M"},
url: "data:text/html;charset=utf-8,<input%20autofocus=true>"
@@ -138,17 +138,17 @@ add_task(function test_nested() {
// Cleanup.
gBrowser.removeTab(tab);
});
/**
* This test ensures that collecting form data for documents with
* designMode=on works as expected.
*/
-add_task(function test_design_mode() {
+add_task(function* test_design_mode() {
const URL = "data:text/html;charset=utf-8,<h1>mozilla</h1>" +
"<script>document.designMode='on'</script>";
// Load a tab with an editable document.
let tab = gBrowser.selectedTab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
--- a/browser/components/sessionstore/test/browser_formdata_format.js
+++ b/browser/components/sessionstore/test/browser_formdata_format.js
@@ -26,17 +26,17 @@ function test() {
{ "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value17", id: { "input1" : "value18" } },
{ "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value19", id: { "input1" : "value20" }, xpath: { "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value21" } },
{ "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value22", xpath: { "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value23" } },
{ "#input1" : "value24", "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value25", id: { "input1" : "value26" } },
{ "#input1" : "value27", "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value28", id: { "input1" : "value29" }, xpath: { "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value30" } },
{ "#input1" : "value31", "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value32", xpath: { "/xhtml:html/xhtml:body/xhtml:input[@name='input2']" : "value33" } }
]
let expectedValues = [
- [ "" , "" ],
+ [ "", "" ],
// old format
[ "value0", "" ],
[ "value1", "value2" ],
[ "", "value3" ],
// new format
[ "value4", "" ],
[ "value5", "" ],
[ "value6", "value7" ],
@@ -70,17 +70,17 @@ function test() {
function testTabRestoreData(aFormData, aExpectedValue, aCallback) {
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 }], formdata: aFormData };
- Task.spawn(function () {
+ Task.spawn(function* () {
yield promiseBrowserLoaded(tab.linkedBrowser);
yield promiseTabState(tab, tabState);
yield TabStateFlusher.flush(tab.linkedBrowser);
let restoredTabState = JSON.parse(ss.getTabState(tab));
let restoredFormData = restoredTabState.formdata;
if (restoredFormData) {
--- a/browser/components/sessionstore/test/browser_formdata_xpath.js
+++ b/browser/components/sessionstore/test/browser_formdata_xpath.js
@@ -33,17 +33,17 @@ const FIELDS = {
"//select[@multiple]": [1, 3],
"//textarea[1]": "",
"//textarea[2]": "Some text... " + Math.random(),
"//textarea[3]": "Some more text\n" + new Date(),
"//input[@type='file'][1]": [FILE1],
"//input[@type='file'][2]": [FILE1, FILE2]
};
-add_task(function test_form_data_restoration() {
+add_task(function* test_form_data_restoration() {
// Load page with some input fields.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Fill in some values.
for (let xpath of Object.keys(FIELDS)) {
yield setFormValue(browser, xpath);
--- a/browser/components/sessionstore/test/browser_frame_history.js
+++ b/browser/components/sessionstore/test/browser_frame_history.js
@@ -3,17 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/**
Ensure that frameset history works properly when restoring a tab,
provided that the frameset is static.
*/
// Loading a toplevel frameset
-add_task(function() {
+add_task(function* () {
let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index.html";
let tab = gBrowser.addTab(testURL);
gBrowser.selectedTab = tab;
info("Opening a page with three frames, 4 loads should take place");
yield waitForLoadsInBrowser(tab.linkedBrowser, 4);
let browser_b = tab.linkedBrowser.contentDocument.getElementsByTagName("frame")[1];
@@ -46,17 +46,17 @@ add_task(function() {
is(frames[i].contentDocument.location,
getRootDirectory(gTestPath) + "browser_frame_history_" + expectedURLEnds[i],
"frame " + i + " has the right url");
}
gBrowser.removeTab(newTab);
});
// Loading the frameset inside an iframe
-add_task(function() {
+add_task(function* () {
let testURL = getRootDirectory(gTestPath) + "browser_frame_history_index2.html";
let tab = gBrowser.addTab(testURL);
gBrowser.selectedTab = tab;
info("iframe: Opening a page with an iframe containing three frames, 5 loads should take place");
yield waitForLoadsInBrowser(tab.linkedBrowser, 5);
let browser_b = tab.linkedBrowser.contentDocument.
@@ -93,17 +93,17 @@ add_task(function() {
is(frames[i].contentDocument.location,
getRootDirectory(gTestPath) + "browser_frame_history_" + expectedURLEnds[i],
"frame " + i + " has the right url");
}
gBrowser.removeTab(newTab);
});
// Now, test that we don't record history if the iframe is added dynamically
-add_task(function() {
+add_task(function* () {
// Start with an empty history
let blankState = JSON.stringify({
windows: [{
tabs: [{ entries: [{ url: "about:blank" }] }],
_closedTabs: []
}],
_closedWindows: []
});
@@ -137,17 +137,17 @@ add_task(function() {
info("dynamic: Clicking on link 2, 1 load should take place");
promise = waitForLoadsInBrowser(tab.linkedBrowser, 1);
EventUtils.sendMouseEvent({type:"click"}, links[1], browser_b.contentWindow);
yield promise;
info("Check in the state that we have not stored this history");
let state = ss.getBrowserState();
info(JSON.stringify(JSON.parse(state), null, "\t"));
- is(state.indexOf("c1.html"), -1, "History entry was not stored in the session state");;
+ is(state.indexOf("c1.html"), -1, "History entry was not stored in the session state");
gBrowser.removeTab(tab);
});
// helper functions
function waitForLoadsInBrowser(aBrowser, aLoadCount) {
let deferred = Promise.defer();
let loadCount = 0;
aBrowser.addEventListener("load", function(aEvent) {
--- a/browser/components/sessionstore/test/browser_frametree.js
+++ b/browser/components/sessionstore/test/browser_frametree.js
@@ -8,17 +8,17 @@ const URL_FRAMESET = HTTPROOT + "browser
/**
* This ensures that loading a page normally, aborting a page load, reloading
* a page, navigating using the bfcache, and ignoring frames that were
* created dynamically work as expect. We expect the frame tree to be reset
* when a page starts loading and we also expect a valid frame tree to exist
* when it has stopped loading.
*/
-add_task(function test_frametree() {
+add_task(function* test_frametree() {
const FRAME_TREE_SINGLE = { href: URL };
const FRAME_TREE_FRAMESET = {
href: URL_FRAMESET,
children: [{href: URL}, {href: URL}, {href: URL}]
};
// Create a tab with a single frame.
let tab = gBrowser.addTab(URL);
@@ -60,17 +60,17 @@ add_task(function test_frametree() {
gBrowser.removeTab(tab);
});
/**
* This test ensures that we ignore frames that were created dynamically at or
* after the load event. SessionStore can't handle these and will not restore
* or collect any data for them.
*/
-add_task(function test_frametree_dynamic() {
+add_task(function* test_frametree_dynamic() {
// The frame tree as expected. The first two frames are static
// and the third one was created on DOMContentLoaded.
const FRAME_TREE = {
href: URL_FRAMESET,
children: [{href: URL}, {href: URL}, {href: URL}]
};
const FRAME_TREE_REMOVED = {
href: URL_FRAMESET,
--- a/browser/components/sessionstore/test/browser_history_persist.js
+++ b/browser/components/sessionstore/test/browser_history_persist.js
@@ -2,17 +2,17 @@
* http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Ensure that history entries that should not be persisted are restored in the
* same state.
*/
-add_task(function check_history_not_persisted() {
+add_task(function* check_history_not_persisted() {
// Create an about:blank tab
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Retrieve the tab state.
yield TabStateFlusher.flush(browser);
let state = JSON.parse(ss.getTabState(tab));
@@ -39,17 +39,17 @@ add_task(function check_history_not_pers
// Cleanup.
gBrowser.removeTab(tab);
});
/**
* Check that entries default to being persisted when the attribute doesn't
* exist
*/
-add_task(function check_history_default_persisted() {
+add_task(function* check_history_default_persisted() {
// Create an about:blank tab
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Retrieve the tab state.
yield TabStateFlusher.flush(browser);
let state = JSON.parse(ss.getTabState(tab));
--- a/browser/components/sessionstore/test/browser_label_and_icon.js
+++ b/browser/components/sessionstore/test/browser_label_and_icon.js
@@ -15,17 +15,17 @@ add_task(function setup() {
registerCleanupFunction(() => {
Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
});
});
/**
* Ensure that a pending tab has label and icon correctly set.
*/
-add_task(function test_label_and_icon() {
+add_task(function* test_label_and_icon() {
// Create a new tab.
let tab = gBrowser.addTab("about:robots");
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Retrieve the tab state.
yield TabStateFlusher.flush(browser);
let state = ss.getTabState(tab);
--- a/browser/components/sessionstore/test/browser_merge_closed_tabs.js
+++ b/browser/components/sessionstore/test/browser_merge_closed_tabs.js
@@ -1,16 +1,16 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* This test ensures that closed tabs are merged when restoring
* a window state without overwriting tabs.
*/
-add_task(function () {
+add_task(function* () {
const initialState = {
windows: [{
tabs: [
{ entries: [{ url: "about:blank" }] }
],
_closedTabs: [
{ state: { entries: [{ ID: 1000, url: "about:blank" }]} },
{ state: { entries: [{ ID: 1001, url: "about:blank" }]} }
--- a/browser/components/sessionstore/test/browser_pageStyle.js
+++ b/browser/components/sessionstore/test/browser_pageStyle.js
@@ -4,17 +4,17 @@
"use strict";
const URL = getRootDirectory(gTestPath) + "browser_pageStyle_sample.html";
const URL_NESTED = getRootDirectory(gTestPath) + "browser_pageStyle_sample_nested.html";
/**
* This test ensures that page style information is correctly persisted.
*/
-add_task(function page_style() {
+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) {
yield enableStyleSheetsForSet(browser, title);
@@ -48,17 +48,17 @@ add_task(function page_style() {
gBrowser.removeTab(tab);
gBrowser.removeTab(tab2);
});
/**
* This test ensures that page style notification from nested documents are
* received and the page style is persisted correctly.
*/
-add_task(function nested_page_style() {
+add_task(function* nested_page_style() {
let tab = gBrowser.addTab(URL_NESTED);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
yield enableSubDocumentStyleSheetsForSet(browser, "alternate");
yield promiseRemoveTab(tab);
let [{state: {pageStyle}}] = JSON.parse(ss.getClosedTabData(window));
--- a/browser/components/sessionstore/test/browser_parentProcessRestoreHash.js
+++ b/browser/components/sessionstore/test/browser_parentProcessRestoreHash.js
@@ -61,17 +61,17 @@ add_task(function* () {
let resolveLocationChangePromise;
let locationChangePromise = new Promise(r => resolveLocationChangePromise = r);
let wpl = {
onStateChange(wpl, 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)) {
+ if (location.spec == "about:blank" || (state == docStop)) {
return;
}
is(location.spec, TESTURL, "Got the expected URL");
resolveLocationChangePromise();
},
};
gBrowser.addProgressListener(wpl);
--- a/browser/components/sessionstore/test/browser_privatetabs.js
+++ b/browser/components/sessionstore/test/browser_privatetabs.js
@@ -3,17 +3,17 @@
add_task(function cleanup() {
info("Forgetting closed tabs");
while (ss.getClosedTabCount(window)) {
ss.forgetClosedTab(window, 0);
}
});
-add_task(function() {
+add_task(function* () {
let URL_PUBLIC = "http://example.com/public/" + Math.random();
let URL_PRIVATE = "http://example.com/private/" + Math.random();
let tab1, tab2;
try {
// Setup a public tab and a private tab
info("Setting up public tab");
tab1 = gBrowser.addTab(URL_PUBLIC);
yield promiseBrowserLoaded(tab1.linkedBrowser);
@@ -54,17 +54,17 @@ add_task(function() {
gBrowser.removeTab(tab1);
}
if (tab2) {
gBrowser.removeTab(tab2);
}
}
});
-add_task(function () {
+add_task(function* () {
const FRAME_SCRIPT = "data:," +
"docShell.QueryInterface%28Components.interfaces.nsILoadContext%29.usePrivateBrowsing%3Dtrue";
// Clear the list of closed windows.
forgetClosedWindows();
// Create a new window to attach our frame script to.
let win = yield promiseNewWindowLoaded();
@@ -96,17 +96,17 @@ add_task(function () {
ok(state.isPrivate, "tab considered private");
// Check that all private tabs are removed when the non-private
// window is closed and we don't save windows without any tabs.
yield BrowserTestUtils.closeWindow(win);
is(ss.getClosedWindowCount(), 0, "no windows to restore");
});
-add_task(function () {
+add_task(function* () {
// Clear the list of closed windows.
forgetClosedWindows();
// Create a new window to attach our frame script to.
let win = yield promiseNewWindowLoaded({private: true});
// Create a new tab in the new window that will load the frame script.
let tab = win.gBrowser.addTab("about:mozilla");
--- a/browser/components/sessionstore/test/browser_restore_redirect.js
+++ b/browser/components/sessionstore/test/browser_restore_redirect.js
@@ -1,17 +1,17 @@
"use strict";
const BASE = "http://example.com/browser/browser/components/sessionstore/test/";
const TARGET = BASE + "restore_redirect_target.html";
/**
* Ensure that a http redirect leaves a working tab.
*/
-add_task(function check_http_redirect() {
+add_task(function* check_http_redirect() {
let state = {
entries: [{ url: BASE + "restore_redirect_http.html" }]
};
// Open a new tab to restore into.
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
yield promiseTabState(tab, state);
@@ -27,17 +27,17 @@ add_task(function check_http_redirect()
// Cleanup.
yield promiseRemoveTab(tab);
});
/**
* Ensure that a js redirect leaves a working tab.
*/
-add_task(function check_js_redirect() {
+add_task(function* check_js_redirect() {
let state = {
entries: [{ url: BASE + "restore_redirect_js.html" }]
};
let loadPromise = new Promise(resolve => {
function listener(msg) {
if (msg.data.url.endsWith("restore_redirect_target.html")) {
window.messageManager.removeMessageListener("ss-test:loadEvent", listener);
--- a/browser/components/sessionstore/test/browser_scrollPositions.js
+++ b/browser/components/sessionstore/test/browser_scrollPositions.js
@@ -17,17 +17,17 @@ const SCROLL2_Y = Math.round(400 * (1 +
const SCROLL2_STR = SCROLL2_X + "," + SCROLL2_Y;
requestLongerTimeout(2);
/**
* This test ensures that we properly serialize and restore scroll positions
* for an average page without any frames.
*/
-add_task(function test_scroll() {
+add_task(function* test_scroll() {
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Scroll down a little.
yield sendMessage(browser, "ss-test:setScrollPosition", {x: SCROLL_X, y: SCROLL_Y});
yield checkScroll(tab, {scroll: SCROLL_STR}, "scroll is fine");
@@ -60,17 +60,17 @@ add_task(function test_scroll() {
yield promiseRemoveTab(tab);
yield promiseRemoveTab(tab2);
});
/**
* This tests ensures that we properly serialize and restore scroll positions
* for multiple frames of pages with framesets.
*/
-add_task(function test_scroll_nested() {
+add_task(function* test_scroll_nested() {
let tab = gBrowser.addTab(URL_FRAMESET);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Scroll the first child frame down a little.
yield sendMessage(browser, "ss-test:setScrollPosition", {x: SCROLL_X, y: SCROLL_Y, frame: 0});
yield checkScroll(tab, {children: [{scroll: SCROLL_STR}]}, "scroll is fine");
@@ -104,17 +104,17 @@ add_task(function test_scroll_nested() {
yield promiseRemoveTab(tab);
yield promiseRemoveTab(tab2);
});
/**
* Test that scroll positions persist after restoring background tabs in
* a restored window (bug 1228518).
*/
-add_task(function test_scroll_background_tabs() {
+add_task(function* test_scroll_background_tabs() {
pushPrefs(["browser.sessionstore.restore_on_demand", true]);
let newWin = yield BrowserTestUtils.openNewBrowserWindow();
let tab = newWin.gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield BrowserTestUtils.browserLoaded(browser);
// Scroll down a little.
--- a/browser/components/sessionstore/test/browser_scrollPositionsReaderMode.js
+++ b/browser/components/sessionstore/test/browser_scrollPositionsReaderMode.js
@@ -12,17 +12,17 @@ const SCROLL_READER_MODE_Y = Math.round(
const SCROLL_READER_MODE_STR = "0," + SCROLL_READER_MODE_Y;
requestLongerTimeout(2);
/**
* Test that scroll positions of about reader page after restoring background
* tabs in a restored window (bug 1153393).
*/
-add_task(function test_scroll_background_about_reader_tabs() {
+add_task(function* test_scroll_background_about_reader_tabs() {
pushPrefs(["browser.sessionstore.restore_on_demand", true]);
let newWin = yield BrowserTestUtils.openNewBrowserWindow();
let tab = newWin.gBrowser.addTab(READER_MODE_URL);
let browser = tab.linkedBrowser;
yield Promise.all([
BrowserTestUtils.browserLoaded(browser),
BrowserTestUtils.waitForContentEvent(browser, "AboutReaderContentReady")
--- a/browser/components/sessionstore/test/browser_sessionHistory.js
+++ b/browser/components/sessionstore/test/browser_sessionHistory.js
@@ -3,17 +3,17 @@
"use strict";
requestLongerTimeout(2);
/**
* Ensure that starting a load invalidates shistory.
*/
-add_task(function test_load_start() {
+add_task(function* test_load_start() {
// Create a new tab.
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Load a new URI.
yield BrowserTestUtils.loadURI(browser, "about:mozilla");
@@ -31,17 +31,17 @@ add_task(function test_load_start() {
// Cleanup.
gBrowser.removeTab(tab);
});
/**
* Ensure that anchor navigation invalidates shistory.
*/
-add_task(function test_hashchange() {
+add_task(function* test_hashchange() {
const URL = "data:text/html;charset=utf-8,<a id=a href=%23>clickme</a>";
// Create a new tab.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Check that we start with a single shistory entry.
@@ -60,17 +60,17 @@ add_task(function test_hashchange() {
// Cleanup.
gBrowser.removeTab(tab);
});
/**
* Ensure that loading pages from the bfcache invalidates shistory.
*/
-add_task(function test_pageshow() {
+add_task(function* test_pageshow() {
const URL = "data:text/html;charset=utf-8,<h1>first</h1>";
const URL2 = "data:text/html;charset=utf-8,<h1>second</h1>";
// Create a new tab.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
@@ -90,17 +90,17 @@ add_task(function test_pageshow() {
// Cleanup.
gBrowser.removeTab(tab);
});
/**
* Ensure that subframe navigation invalidates shistory.
*/
-add_task(function test_subframes() {
+add_task(function* test_subframes() {
const URL = "data:text/html;charset=utf-8," +
"<iframe src=http%3A//example.com/ name=t></iframe>" +
"<a id=a1 href=http%3A//example.com/1 target=t>clickme</a>" +
"<a id=a2 href=http%3A//example.com/%23 target=t>clickme</a>";
// Create a new tab.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
@@ -138,17 +138,17 @@ add_task(function test_subframes() {
// Cleanup.
gBrowser.removeTab(tab);
});
/**
* Ensure that navigating from an about page invalidates shistory.
*/
-add_task(function test_about_page_navigate() {
+add_task(function* test_about_page_navigate() {
// Create a new tab.
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Check that we have a single shistory entry.
yield TabStateFlusher.flush(browser);
let {entries} = JSON.parse(ss.getTabState(tab));
@@ -166,17 +166,17 @@ add_task(function test_about_page_naviga
// Cleanup.
gBrowser.removeTab(tab);
});
/**
* Ensure that history.pushState and history.replaceState invalidate shistory.
*/
-add_task(function test_pushstate_replacestate() {
+add_task(function* test_pushstate_replacestate() {
// Create a new tab.
let tab = gBrowser.addTab("http://example.com/1");
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Check that we have a single shistory entry.
yield TabStateFlusher.flush(browser);
let {entries} = JSON.parse(ss.getTabState(tab));
@@ -205,17 +205,17 @@ add_task(function test_pushstate_replace
// Cleanup.
gBrowser.removeTab(tab);
});
/**
* Ensure that slow loading subframes will invalidate shistory.
*/
-add_task(function test_slow_subframe_load() {
+add_task(function* test_slow_subframe_load() {
const SLOW_URL = "http://mochi.test:8888/browser/browser/components/" +
"sessionstore/test/browser_sessionHistory_slow.sjs";
const URL = "data:text/html;charset=utf-8," +
"<frameset cols=50%25,50%25>" +
"<frame src='" + SLOW_URL + "'>" +
"</frameset>";
--- a/browser/components/sessionstore/test/browser_sessionStorage.js
+++ b/browser/components/sessionstore/test/browser_sessionStorage.js
@@ -10,17 +10,17 @@ const URL = "http://mochi.test:8888/brow
const OUTER_VALUE = "outer-value-" + RAND;
const INNER_VALUE = "inner-value-" + RAND;
/**
* This test ensures that setting, modifying and restoring sessionStorage data
* works as expected.
*/
-add_task(function session_storage() {
+add_task(function* session_storage() {
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Flush to make sure chrome received all data.
yield TabStateFlusher.flush(browser);
let {storage} = JSON.parse(ss.getTabState(tab));
@@ -97,17 +97,17 @@ add_task(function session_storage() {
yield promiseRemoveTab(tab);
yield promiseRemoveTab(tab2);
});
/**
* This test ensures that purging domain data also purges data from the
* sessionStorage data collected for tabs.
*/
-add_task(function purge_domain() {
+add_task(function* purge_domain() {
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Purge data for "mochi.test".
yield purgeDomainData(browser, "mochi.test");
// Flush to make sure chrome received all data.
@@ -121,17 +121,17 @@ add_task(function purge_domain() {
yield promiseRemoveTab(tab);
});
/**
* This test ensures that collecting sessionStorage data respects the privacy
* levels as set by the user.
*/
-add_task(function respect_privacy_level() {
+add_task(function* respect_privacy_level() {
let tab = gBrowser.addTab(URL + "&secure");
yield promiseBrowserLoaded(tab.linkedBrowser);
yield promiseRemoveTab(tab);
let [{state: {storage}}] = JSON.parse(ss.getClosedTabData(window));
is(storage["http://mochi.test:8888"].test, OUTER_VALUE,
"http sessionStorage data has been saved");
is(storage["https://example.com"].test, INNER_VALUE,
--- a/browser/components/sessionstore/test/browser_windowRestore_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_windowRestore_perwindowpb.js
@@ -5,17 +5,17 @@
// This test checks that closed private windows can't be restored
function test() {
waitForExplicitFinish();
// Purging the list of closed windows
forgetClosedWindows();
- // Load a private window, then close it
+ // Load a private window, then close it
// and verify it doesn't get remembered for restoring
whenNewWindowLoaded({private: true}, function (win) {
info("The private window got loaded");
win.addEventListener("SSWindowClosing", function onclosing() {
win.removeEventListener("SSWindowClosing", onclosing, false);
executeSoon(function () {
is(ss.getClosedWindowCount(), 0,
"The private window should not have been stored");
--- a/browser/components/sessionstore/test/unit/head.js
+++ b/browser/components/sessionstore/test/unit/head.js
@@ -24,9 +24,9 @@ function afterSessionStartupInitializati
// Start sessionstartup initialization.
let startup = Cc["@mozilla.org/browser/sessionstartup;1"].
getService(Ci.nsIObserver);
Services.obs.addObserver(startup, "final-ui-startup", false);
Services.obs.addObserver(startup, "quit-application", false);
Services.obs.notifyObservers(null, "final-ui-startup", "");
Services.obs.addObserver(observer, "sessionstore-state-finalized", false);
-};
+}
--- a/browser/components/sessionstore/test/unit/test_startup_nosession_async.js
+++ b/browser/components/sessionstore/test/unit/test_startup_nosession_async.js
@@ -14,9 +14,9 @@ function run_test() {
do_test_pending();
let startup = Cc["@mozilla.org/browser/sessionstartup;1"].
getService(Ci.nsISessionStartup);
afterSessionStartupInitialization(function cb() {
do_check_eq(startup.sessionType, Ci.nsISessionStartup.NO_SESSION);
do_test_finished();
});
-}
\ No newline at end of file
+}