--- a/browser/components/sessionstore/ContentRestore.jsm
+++ b/browser/components/sessionstore/ContentRestore.jsm
@@ -170,17 +170,17 @@ ContentRestoreInternal.prototype = {
}
});
},
/**
* Start loading the current page. When the data has finished loading from the
* network, finishCallback is called. Returns true if the load was successful.
*/
- restoreTabContent: function (loadArguments, isRemotenessUpdate, finishCallback) {
+ restoreTabContent(loadArguments, isRemotenessUpdate, finishCallback) {
let tabData = this._tabData;
this._tabData = null;
let webNavigation = this.docShell.QueryInterface(Ci.nsIWebNavigation);
let history = webNavigation.sessionHistory;
// Listen for the tab to finish loading.
this.restoreTabContentStarted(finishCallback);
@@ -194,17 +194,17 @@ ContentRestoreInternal.prototype = {
}
try {
if (loadArguments) {
// A load has been redirected to a new process so get history into the
// same state it was before the load started then trigger the load.
let referrer = loadArguments.referrer ?
Utils.makeURI(loadArguments.referrer) : null;
- let referrerPolicy = ('referrerPolicy' in loadArguments
+ let referrerPolicy = ("referrerPolicy" in loadArguments
? loadArguments.referrerPolicy
: Ci.nsIHttpChannel.REFERRER_POLICY_UNSET);
let postData = loadArguments.postData ?
Utils.makeInputStream(loadArguments.postData) : null;
let triggeringPrincipal = loadArguments.triggeringPrincipal
? Utils.deserializePrincipal(loadArguments.triggeringPrincipal)
: null;
@@ -279,17 +279,17 @@ ContentRestoreInternal.prototype = {
});
},
/**
* Finish restoring the tab by filling in form data and setting the scroll
* position. The restore is complete when this function exits. It should be
* called when the "load" event fires for the restoring tab.
*/
- restoreDocument: function () {
+ restoreDocument() {
if (!this._restoringDocument) {
return;
}
let {entry, pageStyle, formdata, scrollPositions} = this._restoringDocument;
this._restoringDocument = null;
let window = this.docShell.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindow);
@@ -303,17 +303,17 @@ ContentRestoreInternal.prototype = {
* Cancel an ongoing restore. This function can be called any time between
* restoreHistory and restoreDocument.
*
* This function is called externally (if a restore is canceled) and
* internally (when the loads for a restore have finished). In the latter
* case, it's called before restoreDocument, so it cannot clear
* _restoringDocument.
*/
- resetRestore: function () {
+ resetRestore() {
this._tabData = null;
if (this._historyListener) {
this._historyListener.uninstall();
}
this._historyListener = null;
if (this._progressListener) {
@@ -336,28 +336,28 @@ function HistoryListener(docShell, callb
this.callback = callback;
}
HistoryListener.prototype = {
QueryInterface: XPCOMUtils.generateQI([
Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference
]),
- uninstall: function () {
+ uninstall() {
let shistory = this.webNavigation.sessionHistory;
if (shistory) {
shistory.removeSHistoryListener(this);
}
},
- OnHistoryGoBack: function(backURI) { return true; },
- OnHistoryGoForward: function(forwardURI) { return true; },
- OnHistoryGotoIndex: function(index, gotoURI) { return true; },
- OnHistoryPurge: function(numEntries) { return true; },
- OnHistoryReplaceEntry: function(index) {},
+ OnHistoryGoBack(backURI) { return true; },
+ OnHistoryGoForward(forwardURI) { return true; },
+ OnHistoryGotoIndex(index, gotoURI) { return true; },
+ OnHistoryPurge(numEntries) { return true; },
+ OnHistoryReplaceEntry(index) {},
// This will be called for a pending tab when loadURI(uri) is called where
// the given |uri| only differs in the fragment.
OnHistoryNewEntry(newURI) {
let currentURI = this.webNavigation.currentURI;
// Ignore new SHistory entries with the same URI as those do not indicate
// a navigation inside a document by changing the #hash part of the URL.
@@ -406,32 +406,32 @@ function ProgressListener(docShell, call
}
ProgressListener.prototype = {
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference
]),
- uninstall: function() {
+ uninstall() {
this.webProgress.removeProgressListener(this);
},
- onStateChange: function(webProgress, request, stateFlags, status) {
+ onStateChange(webProgress, request, stateFlags, status) {
let {STATE_IS_WINDOW, STATE_STOP, STATE_START} = Ci.nsIWebProgressListener;
if (!webProgress.isTopLevel || !(stateFlags & STATE_IS_WINDOW)) {
return;
}
if (stateFlags & STATE_START && this.callbacks.onStartRequest) {
this.callbacks.onStartRequest();
}
if (stateFlags & STATE_STOP && this.callbacks.onStopRequest) {
this.callbacks.onStopRequest();
}
},
- onLocationChange: function() {},
- onProgressChange: function() {},
- onStatusChange: function() {},
- onSecurityChange: function() {},
+ onLocationChange() {},
+ onProgressChange() {},
+ onStatusChange() {},
+ onSecurityChange() {},
};
--- a/browser/components/sessionstore/DocShellCapabilities.jsm
+++ b/browser/components/sessionstore/DocShellCapabilities.jsm
@@ -5,46 +5,46 @@
"use strict";
this.EXPORTED_SYMBOLS = ["DocShellCapabilities"];
/**
* The external API exported by this module.
*/
this.DocShellCapabilities = Object.freeze({
- collect: function (docShell) {
+ collect(docShell) {
return DocShellCapabilitiesInternal.collect(docShell);
},
- restore: function (docShell, disallow) {
+ restore(docShell, disallow) {
return DocShellCapabilitiesInternal.restore(docShell, disallow);
},
});
/**
* Internal functionality to save and restore the docShell.allow* properties.
*/
var DocShellCapabilitiesInternal = {
// List of docShell capabilities to (re)store. These are automatically
// retrieved from a given docShell if not already collected before.
// This is made so they're automatically in sync with all nsIDocShell.allow*
// properties.
caps: null,
- allCapabilities: function (docShell) {
+ allCapabilities(docShell) {
if (!this.caps) {
let keys = Object.keys(docShell);
this.caps = keys.filter(k => k.startsWith("allow")).map(k => k.slice(5));
}
return this.caps;
},
- collect: function (docShell) {
+ collect(docShell) {
let caps = this.allCapabilities(docShell);
return caps.filter(cap => !docShell["allow" + cap]);
},
- restore: function (docShell, disallow) {
+ restore(docShell, disallow) {
let caps = this.allCapabilities(docShell);
for (let cap of caps)
docShell["allow" + cap] = !disallow.has(cap);
},
};
--- a/browser/components/sessionstore/FrameTree.jsm
+++ b/browser/components/sessionstore/FrameTree.jsm
@@ -75,41 +75,41 @@ FrameTreeInternal.prototype = {
/**
* Adds a given observer |obs| to the set of observers that will be notified
* when the frame tree is reset (when a new document starts loading) or
* recollected (when a document finishes loading).
*
* @param obs (object)
*/
- addObserver: function (obs) {
+ addObserver(obs) {
this._observers.add(obs);
},
/**
* Notifies all observers that implement the given |method|.
*
* @param method (string)
*/
- notifyObservers: function (method) {
+ notifyObservers(method) {
for (let obs of this._observers) {
if (obs.hasOwnProperty(method)) {
obs[method]();
}
}
},
/**
* Checks whether a given |frame| is contained in the collected frame tree.
* If it is not, this indicates that we should not collect data for it.
*
* @param frame (nsIDOMWindow)
* @return bool
*/
- contains: function (frame) {
+ contains(frame) {
return this._frames.has(frame);
},
/**
* Recursively applies the given function |cb| to the stored frame tree. Use
* this method to collect sessionstore data for all reachable frames stored
* in the frame tree.
*
@@ -119,17 +119,17 @@ FrameTreeInternal.prototype = {
*
* The object returned by |cb| cannot have any property named "children" as
* that is used to store information about subframes in the tree returned
* by |map()| and might be overridden.
*
* @param cb (function)
* @return object
*/
- map: function (cb) {
+ map(cb) {
let frames = this._frames;
function walk(frame) {
let obj = cb(frame) || {};
if (frames.has(frame)) {
let children = [];
@@ -164,17 +164,17 @@ FrameTreeInternal.prototype = {
/**
* Applies the given function |cb| to all frames stored in the tree. Use this
* method if |map()| doesn't suit your needs and you want more control over
* how data is collected.
*
* @param cb (function)
* This callback receives the current frame as the only argument.
*/
- forEach: function (cb) {
+ forEach(cb) {
let frames = this._frames;
function walk(frame) {
cb(frame);
if (!frames.has(frame)) {
return;
}
@@ -191,32 +191,32 @@ FrameTreeInternal.prototype = {
/**
* Stores a given |frame| and its children in the frame tree.
*
* @param frame (nsIDOMWindow)
* @param index (int)
* The index in the given frame's parent's child list.
*/
- collect: function (frame, index = 0) {
+ collect(frame, index = 0) {
// Mark the given frame as contained in the frame tree.
this._frames.set(frame, index);
// Mark the given frame's subframes as contained in the tree.
Array.forEach(frame.frames, this.collect, this);
},
/**
* @see nsIWebProgressListener.onStateChange
*
* We want to be notified about:
* - new documents that start loading to clear the current frame tree;
* - completed document loads to recollect reachable frames.
*/
- onStateChange: function (webProgress, request, stateFlags, status) {
+ onStateChange(webProgress, request, stateFlags, status) {
// Ignore state changes for subframes because we're only interested in the
// top-document starting or stopping its load. We thus only care about any
// changes to the root of the frame tree, not to any of its nodes/leafs.
if (!webProgress.isTopLevel || webProgress.DOMWindow != this.content) {
return;
}
// onStateChange will be fired when loading the initial about:blank URI for
@@ -239,16 +239,16 @@ FrameTreeInternal.prototype = {
this.collect(webProgress.DOMWindow);
// Notify observers that the frame tree has been reset.
this.notifyObservers("onFrameTreeCollected");
}
},
// Unused nsIWebProgressListener methods.
- onLocationChange: function () {},
- onProgressChange: function () {},
- onSecurityChange: function () {},
- onStatusChange: function () {},
+ onLocationChange() {},
+ onProgressChange() {},
+ onSecurityChange() {},
+ onStatusChange() {},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference])
};
--- a/browser/components/sessionstore/GlobalState.jsm
+++ b/browser/components/sessionstore/GlobalState.jsm
@@ -23,62 +23,62 @@ function GlobalStateInternal() {
// Storage for global state.
this.state = {};
}
GlobalStateInternal.prototype = {
/**
* Get all value from the global state.
*/
- getState: function() {
+ getState() {
return this.state;
},
/**
* Clear all currently stored global state.
*/
- clear: function() {
+ clear() {
this.state = {};
},
/**
* Retrieve a value from the global state.
*
* @param aKey
* A key the value is stored under.
* @return The value stored at aKey, or an empty string if no value is set.
*/
- get: function(aKey) {
+ get(aKey) {
return this.state[aKey] || "";
},
/**
* Set a global value.
*
* @param aKey
* A key to store the value under.
*/
- set: function(aKey, aStringValue) {
+ set(aKey, aStringValue) {
this.state[aKey] = aStringValue;
},
/**
* Delete a global value.
*
* @param aKey
* A key to delete the value for.
*/
- delete: function(aKey) {
+ delete(aKey) {
delete this.state[aKey];
},
/**
* Set the current global state from a state object. Any previous global
* state will be removed, even if the new state does not contain a matching
* key.
*
* @param aState
* A state object to extract global state from to be set.
*/
- setFromState: function (aState) {
+ setFromState(aState) {
this.state = (aState && aState.global) || {};
}
};
--- a/browser/components/sessionstore/PageStyle.jsm
+++ b/browser/components/sessionstore/PageStyle.jsm
@@ -7,33 +7,33 @@
this.EXPORTED_SYMBOLS = ["PageStyle"];
const Ci = Components.interfaces;
/**
* The external API exported by this module.
*/
this.PageStyle = Object.freeze({
- collect: function (docShell, frameTree) {
+ collect(docShell, frameTree) {
return PageStyleInternal.collect(docShell, frameTree);
},
- restoreTree: function (docShell, data) {
+ restoreTree(docShell, data) {
PageStyleInternal.restoreTree(docShell, data);
}
});
// Signifies that author style level is disabled for the page.
const NO_STYLE = "_nostyle";
var PageStyleInternal = {
/**
* Collects the selected style sheet sets for all reachable frames.
*/
- collect: function (docShell, frameTree) {
+ collect(docShell, frameTree) {
let result = frameTree.map(({document: doc}) => {
let style;
if (doc) {
// http://dev.w3.org/csswg/cssom/#persisting-the-selected-css-style-sheet-set
style = doc.selectedStyleSheetSet || doc.lastStyleSheetSet;
}
@@ -66,17 +66,17 @@ var PageStyleInternal = {
* disabled: true, // when true, author styles will be disabled
* pageStyle: "Dusk",
* children: [
* null,
* {pageStyle: "Mozilla", children: [ ... ]}
* ]
* }
*/
- restoreTree: function (docShell, data) {
+ restoreTree(docShell, data) {
let disabled = data.disabled || false;
let markupDocumentViewer =
docShell.contentViewer;
markupDocumentViewer.authorStyleDisabled = disabled;
function restoreFrame(root, data) {
if (data.hasOwnProperty("pageStyle")) {
root.document.selectedStyleSheetSet = data.pageStyle;
--- a/browser/components/sessionstore/PrivacyFilter.jsm
+++ b/browser/components/sessionstore/PrivacyFilter.jsm
@@ -21,17 +21,17 @@ this.PrivacyFilter = Object.freeze({
/**
* Filters the given (serialized) session storage |data| according to the
* current privacy level and returns a new object containing only data that
* we're allowed to store.
*
* @param data The session storage data as collected from a tab.
* @return object
*/
- filterSessionStorageData: function (data) {
+ filterSessionStorageData(data) {
let retval = {};
for (let host of Object.keys(data)) {
if (PrivacyLevel.check(host)) {
retval[host] = data[host];
}
}
@@ -41,17 +41,17 @@ this.PrivacyFilter = Object.freeze({
/**
* Filters the given (serialized) form |data| according to the current
* privacy level and returns a new object containing only data that we're
* allowed to store.
*
* @param data The form data as collected from a tab.
* @return object
*/
- filterFormData: function (data) {
+ filterFormData(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 null;
}
let retval = {};
@@ -76,17 +76,17 @@ this.PrivacyFilter = Object.freeze({
/**
* Removes any private windows and tabs from a given browser state object.
*
* @param browserState (object)
* The browser state for which we remove any private windows and tabs.
* The given object will be modified.
*/
- filterPrivateWindowsAndTabs: function (browserState) {
+ filterPrivateWindowsAndTabs(browserState) {
// Remove private opened windows.
for (let i = browserState.windows.length - 1; i >= 0; i--) {
let win = browserState.windows[i];
if (win.isPrivate) {
browserState.windows.splice(i, 1);
if (browserState.selectedWindow >= i) {
@@ -108,17 +108,17 @@ this.PrivacyFilter = Object.freeze({
/**
* Removes open private tabs from a given window state object.
*
* @param winState (object)
* The window state for which we remove any private tabs.
* The given object will be modified.
*/
- filterPrivateTabs: function (winState) {
+ filterPrivateTabs(winState) {
// Remove open private tabs.
for (let i = winState.tabs.length - 1; i >= 0 ; i--) {
let tab = winState.tabs[i];
if (tab.isPrivate) {
winState.tabs.splice(i, 1);
if (winState.selected >= i) {
--- a/browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm
+++ b/browser/components/sessionstore/RecentlyClosedTabsAndWindowsMenuUtils.jsm
@@ -32,18 +32,18 @@ this.RecentlyClosedTabsAndWindowsMenuUti
* The tag name that will be used when creating the UI items.
* @param aPrefixRestoreAll (defaults to false)
* Whether the 'restore all tabs' item is suffixed or prefixed to the list.
* If suffixed (the default) a separator will be inserted before it.
* @param aRestoreAllLabel (defaults to "menuRestoreAllTabs.label")
* Which localizable string to use for the 'restore all tabs' item.
* @returns A document fragment with UI items for each recently closed tab.
*/
- getTabsFragment: function(aWindow, aTagName, aPrefixRestoreAll=false,
- aRestoreAllLabel="menuRestoreAllTabs.label") {
+ getTabsFragment(aWindow, aTagName, aPrefixRestoreAll = false,
+ aRestoreAllLabel = "menuRestoreAllTabs.label") {
let doc = aWindow.document;
let fragment = doc.createDocumentFragment();
if (SessionStore.getClosedTabCount(aWindow) != 0) {
let closedTabs = SessionStore.getClosedTabData(aWindow, false);
for (let i = 0; i < closedTabs.length; i++) {
createEntry(aTagName, false, i, closedTabs[i], doc,
closedTabs[i].title, fragment);
}
@@ -62,18 +62,18 @@ this.RecentlyClosedTabsAndWindowsMenuUti
* The tag name that will be used when creating the UI items.
* @param aPrefixRestoreAll (defaults to false)
* Whether the 'restore all windows' item is suffixed or prefixed to the list.
* If suffixed (the default) a separator will be inserted before it.
* @param aRestoreAllLabel (defaults to "menuRestoreAllWindows.label")
* Which localizable string to use for the 'restore all windows' item.
* @returns A document fragment with UI items for each recently closed window.
*/
- getWindowsFragment: function(aWindow, aTagName, aPrefixRestoreAll=false,
- aRestoreAllLabel="menuRestoreAllWindows.label") {
+ getWindowsFragment(aWindow, aTagName, aPrefixRestoreAll = false,
+ aRestoreAllLabel = "menuRestoreAllWindows.label") {
let closedWindowData = SessionStore.getClosedWindowData(false);
let doc = aWindow.document;
let fragment = doc.createDocumentFragment();
if (closedWindowData.length != 0) {
let menuLabelString = navigatorBundle.GetStringFromName("menuUndoCloseWindowLabel");
let menuLabelStringSingleTab =
navigatorBundle.GetStringFromName("menuUndoCloseWindowSingleTabLabel");
@@ -99,17 +99,17 @@ this.RecentlyClosedTabsAndWindowsMenuUti
/**
* Re-open a closed tab and put it to the end of the tab strip.
* Used for a middle click.
* @param aEvent
* The event when the user clicks the menu item
*/
- _undoCloseMiddleClick: function(aEvent) {
+ _undoCloseMiddleClick(aEvent) {
if (aEvent.button != 1)
return;
aEvent.view.undoCloseTab(aEvent.originalTarget.getAttribute("value"));
aEvent.view.gBrowser.moveTabToEnd();
},
};
@@ -167,17 +167,17 @@ function createEntry(aTagName, aIsWindow
if (activeIndex >= 0 && tabData.entries[activeIndex]) {
element.setAttribute("targetURI", tabData.entries[activeIndex].url);
}
if (!aIsWindowsFragment) {
element.addEventListener("click", RecentlyClosedTabsAndWindowsMenuUtils._undoCloseMiddleClick);
}
if (aIndex == 0) {
- element.setAttribute("key", "key_undoClose" + (aIsWindowsFragment? "Window" : "Tab"));
+ element.setAttribute("key", "key_undoClose" + (aIsWindowsFragment ? "Window" : "Tab"));
}
aFragment.appendChild(element);
}
/**
* Create an entry to restore all closed windows or tabs.
* @param aDocument
@@ -199,16 +199,16 @@ function createEntry(aTagName, aIsWindow
function createRestoreAllEntry(aDocument, aFragment, aPrefixRestoreAll,
aIsWindowsFragment, aRestoreAllLabel,
aEntryCount, aTagName) {
let restoreAllElements = aDocument.createElementNS(kNSXUL, aTagName);
restoreAllElements.classList.add("restoreallitem");
restoreAllElements.setAttribute("label", navigatorBundle.GetStringFromName(aRestoreAllLabel));
restoreAllElements.setAttribute("oncommand",
"for (var i = 0; i < " + aEntryCount + "; i++) undoClose" +
- (aIsWindowsFragment? "Window" : "Tab") + "();");
+ (aIsWindowsFragment ? "Window" : "Tab") + "();");
if (aPrefixRestoreAll) {
aFragment.insertBefore(restoreAllElements, aFragment.firstChild);
} else {
aFragment.appendChild(aDocument.createElementNS(kNSXUL, "menuseparator"));
aFragment.appendChild(restoreAllElements);
}
-}
\ No newline at end of file
+}
--- a/browser/components/sessionstore/SessionCookies.jsm
+++ b/browser/components/sessionstore/SessionCookies.jsm
@@ -19,21 +19,21 @@ XPCOMUtils.defineLazyModuleGetter(this,
// MAX_EXPIRY should be 2^63-1, but JavaScript can't handle that precision.
const MAX_EXPIRY = Math.pow(2, 62);
/**
* The external API implemented by the SessionCookies module.
*/
this.SessionCookies = Object.freeze({
- update: function (windows) {
+ update(windows) {
SessionCookiesInternal.update(windows);
},
- getHostsForWindow: function (window, checkPrivacy = false) {
+ getHostsForWindow(window, checkPrivacy = false) {
return SessionCookiesInternal.getHostsForWindow(window, checkPrivacy);
},
restore(cookies) {
SessionCookiesInternal.restore(cookies);
}
});
@@ -50,33 +50,33 @@ var SessionCookiesInternal = {
* Retrieve the list of all hosts contained in the given windows' session
* history entries (per window) and collect the associated cookies for those
* hosts, if any. The given state object is being modified.
*
* @param windows
* Array of window state objects.
* [{ tabs: [...], cookies: [...] }, ...]
*/
- update: function (windows) {
+ update(windows) {
this._ensureInitialized();
for (let window of windows) {
let cookies = [];
// Collect all hosts for the current window.
let hosts = this.getHostsForWindow(window, true);
for (let host of Object.keys(hosts)) {
let isPinned = hosts[host];
for (let cookie of CookieStore.getCookiesForHost(host)) {
// _getCookiesForHost() will only return hosts with the right privacy
// rules, so there is no need to do anything special with this call
// to PrivacyLevel.canSave().
- if (PrivacyLevel.canSave({isHttps: cookie.secure, isPinned: isPinned})) {
+ if (PrivacyLevel.canSave({isHttps: cookie.secure, isPinned})) {
cookies.push(cookie);
}
}
}
// Don't include/keep empty cookie sections.
if (cookies.length) {
window.cookies = cookies;
@@ -94,17 +94,17 @@ var SessionCookiesInternal = {
* A window state object containing tabs with history entries.
* @param checkPrivacy (bool)
* Whether to check the privacy level for each host.
* @return {object} A map of hosts for a given window state object. The keys
* will be hosts, the values are boolean and determine
* whether we will use the deferred privacy level when
* checking how much data to save on quitting.
*/
- getHostsForWindow: function (window, checkPrivacy = false) {
+ getHostsForWindow(window, checkPrivacy = false) {
let hosts = {};
for (let tab of window.tabs) {
for (let entry of tab.entries) {
this._extractHostsFromEntry(entry, hosts, checkPrivacy, tab.pinned);
}
}
@@ -130,17 +130,17 @@ var SessionCookiesInternal = {
}
}
},
/**
* Handles observers notifications that are sent whenever cookies are added,
* changed, or removed. Ensures that the storage is updated accordingly.
*/
- observe: function (subject, topic, data) {
+ observe(subject, topic, data) {
switch (data) {
case "added":
case "changed":
this._updateCookie(subject);
break;
case "deleted":
this._removeCookie(subject);
break;
@@ -158,17 +158,17 @@ var SessionCookiesInternal = {
throw new Error("Unhandled cookie-changed notification.");
}
},
/**
* If called for the first time in a session, iterates all cookies in the
* cookies service and puts them into the store if they're session cookies.
*/
- _ensureInitialized: function () {
+ _ensureInitialized() {
if (!this._initialized) {
this._reloadCookies();
this._initialized = true;
Services.obs.addObserver(this, "cookie-changed", false);
}
},
/**
@@ -180,32 +180,31 @@ var SessionCookiesInternal = {
* @param hosts
* the hash that will be used to store hosts eg, { hostname: true }
* @param checkPrivacy
* should we check the privacy level for https
* @param isPinned
* is the entry we're evaluating for a pinned tab; used only if
* checkPrivacy
*/
- _extractHostsFromEntry: function (entry, hosts, checkPrivacy, isPinned) {
+ _extractHostsFromEntry(entry, hosts, checkPrivacy, isPinned) {
let host = entry._host;
let scheme = entry._scheme;
// If host & scheme aren't defined, then we are likely here in the startup
// process via _splitCookiesFromWindow. In that case, we'll turn entry.url
// into an nsIURI and get host/scheme from that. This will throw for about:
// urls in which case we don't need to do anything.
if (!host && !scheme) {
try {
let uri = Utils.makeURI(entry.url);
host = uri.host;
scheme = uri.scheme;
this._extractHostsFromHostScheme(host, scheme, hosts, checkPrivacy, isPinned);
- }
- catch (ex) { }
+ } catch (ex) { }
}
if (entry.children) {
for (let child of entry.children) {
this._extractHostsFromEntry(child, hosts, checkPrivacy, isPinned);
}
}
},
@@ -221,69 +220,68 @@ var SessionCookiesInternal = {
* @param hosts
* the hash that will be used to store hosts eg, { hostname: true }
* @param checkPrivacy
* should we check the privacy level for https
* @param isPinned
* is the entry we're evaluating for a pinned tab; used only if
* checkPrivacy
*/
- _extractHostsFromHostScheme:
- function (host, scheme, hosts, checkPrivacy, isPinned) {
+ _extractHostsFromHostScheme(host, scheme, hosts, checkPrivacy, isPinned) {
// host and scheme may not be set (for about: urls for example), in which
// case testing scheme will be sufficient.
if (/https?/.test(scheme) && !hosts[host] &&
(!checkPrivacy ||
- PrivacyLevel.canSave({isHttps: scheme == "https", isPinned: isPinned}))) {
+ PrivacyLevel.canSave({isHttps: scheme == "https", isPinned}))) {
// By setting this to true or false, we can determine when looking at
// the host in update() if we should check for privacy.
hosts[host] = isPinned;
} else if (scheme == "file") {
hosts[host] = true;
}
},
/**
* Updates or adds a given cookie to the store.
*/
- _updateCookie: function (cookie) {
+ _updateCookie(cookie) {
cookie.QueryInterface(Ci.nsICookie2);
if (cookie.isSession) {
CookieStore.set(cookie);
} else {
CookieStore.delete(cookie);
}
},
/**
* Removes a given cookie from the store.
*/
- _removeCookie: function (cookie) {
+ _removeCookie(cookie) {
cookie.QueryInterface(Ci.nsICookie2);
if (cookie.isSession) {
CookieStore.delete(cookie);
}
},
/**
* Removes a given list of cookies from the store.
*/
- _removeCookies: function (cookies) {
+ _removeCookies(cookies) {
for (let i = 0; i < cookies.length; i++) {
this._removeCookie(cookies.queryElementAt(i, Ci.nsICookie2));
}
},
/**
* Iterates all cookies in the cookies service and puts them into the store
* if they're session cookies.
*/
- _reloadCookies: function () {
+ _reloadCookies() {
let iter = Services.cookies.enumerator;
while (iter.hasMoreElements()) {
this._updateCookie(iter.getNext());
}
}
};
/**
@@ -356,17 +354,17 @@ var CookieStore = {
_hosts: new Map(),
/**
* Returns the list of stored session cookies for a given host.
*
* @param host
* A string containing the host name we want to get cookies for.
*/
- getCookiesForHost: function (host) {
+ getCookiesForHost(host) {
let cookies = [];
let appendCookiesForHost = host => {
if (!this._hosts.has(host)) {
return;
}
for (let pathToNamesMap of this._hosts.get(host).values()) {
@@ -391,17 +389,17 @@ var CookieStore = {
},
/**
* Stores a given cookie.
*
* @param cookie
* The nsICookie2 object to add to the storage.
*/
- set: function (cookie) {
+ set(cookie) {
let jscookie = {host: cookie.host, value: cookie.value};
// Only add properties with non-default values to save a few bytes.
if (cookie.path) {
jscookie.path = cookie.path;
}
if (cookie.name) {
@@ -428,37 +426,37 @@ var CookieStore = {
},
/**
* Removes a given cookie.
*
* @param cookie
* The nsICookie2 object to be removed from storage.
*/
- delete: function (cookie) {
+ delete(cookie) {
this._ensureMap(cookie).delete(cookie.name);
},
/**
* Removes all cookies.
*/
- clear: function () {
+ clear() {
this._hosts.clear();
},
/**
* Creates all maps necessary to store a given cookie.
*
* @param cookie
* The nsICookie2 object to create maps for.
*
* @return The newly created Map instance mapping cookie names to
* internal jscookies, in the given path of the given host.
*/
- _ensureMap: function (cookie) {
+ _ensureMap(cookie) {
if (!this._hosts.has(cookie.host)) {
this._hosts.set(cookie.host, new Map());
}
let originAttributesMap = this._hosts.get(cookie.host);
// If cookie.originAttributes is null, originAttributes will be an empty string.
let originAttributes = ChromeUtils.originAttributesToSuffix(cookie.originAttributes);
if (!originAttributesMap.has(originAttributes)) {
--- a/browser/components/sessionstore/SessionFile.jsm
+++ b/browser/components/sessionstore/SessionFile.jsm
@@ -61,29 +61,29 @@ const PREF_MAX_UPGRADE_BACKUPS = "browse
const PREF_MAX_SERIALIZE_BACK = "browser.sessionstore.max_serialize_back";
const PREF_MAX_SERIALIZE_FWD = "browser.sessionstore.max_serialize_forward";
this.SessionFile = {
/**
* Read the contents of the session file, asynchronously.
*/
- read: function () {
+ read() {
return SessionFileInternal.read();
},
/**
* Write the contents of the session file, asynchronously.
*/
- write: function (aData) {
+ write(aData) {
return SessionFileInternal.write(aData);
},
/**
* Wipe the contents of the session file, asynchronously.
*/
- wipe: function () {
+ wipe() {
return SessionFileInternal.wipe();
},
/**
* Return the paths to the files used to store, backup, etc.
* the state of the file.
*/
get Paths() {
@@ -221,25 +221,25 @@ var SessionFileInternal = {
let exists = true;
try {
let path = this.Paths[key];
let startMs = Date.now();
let source = yield OS.File.read(path, { encoding: "utf-8" });
let parsed = JSON.parse(source);
- if (!SessionStore.isFormatVersionCompatible(parsed.version || ["sessionrestore", 0] /*fallback for old versions*/)) {
+ if (!SessionStore.isFormatVersionCompatible(parsed.version || ["sessionrestore", 0] /* fallback for old versions*/)) {
// Skip sessionstore files that we don't understand.
Cu.reportError("Cannot extract data from Session Restore file " + path + ". Wrong format/version: " + JSON.stringify(parsed.version) + ".");
continue;
}
result = {
origin: key,
- source: source,
- parsed: parsed
+ source,
+ 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) {
@@ -307,17 +307,17 @@ var SessionFileInternal = {
// Initialization will be complete once `this._deferredInitialized.promise`
// resolves.
this.read();
}
yield this._deferredInitialized.promise;
return SessionWorker.post(...args)
}),
- write: function (aData) {
+ write(aData) {
if (RunState.isClosed) {
return Promise.reject(new Error("SessionFile is closed"));
}
let isFinalWrite = false;
if (RunState.isClosing) {
// If shutdown has started, we will want to stop receiving
// write instructions.
@@ -374,21 +374,21 @@ var SessionFileInternal = {
AsyncShutdown.profileBeforeChange.removeBlocker(promise);
if (isFinalWrite) {
Services.obs.notifyObservers(null, "sessionstore-final-state-write-complete", "");
}
});
},
- wipe: function () {
+ wipe() {
return this._postToWorker("wipe");
},
- _recordTelemetry: function(telemetry) {
+ _recordTelemetry(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);
}
--- a/browser/components/sessionstore/SessionMigration.jsm
+++ b/browser/components/sessionstore/SessionMigration.jsm
@@ -10,22 +10,22 @@ const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
Cu.import("resource://gre/modules/Task.jsm", this);
Cu.import("resource://gre/modules/osfile.jsm", this);
XPCOMUtils.defineLazyModuleGetter(this, "Utils",
"resource://gre/modules/sessionstore/Utils.jsm");
// An encoder to UTF-8.
-XPCOMUtils.defineLazyGetter(this, "gEncoder", function () {
+XPCOMUtils.defineLazyGetter(this, "gEncoder", function() {
return new TextEncoder();
});
// A decoder.
-XPCOMUtils.defineLazyGetter(this, "gDecoder", function () {
+XPCOMUtils.defineLazyGetter(this, "gDecoder", function() {
return new TextDecoder();
});
var SessionMigrationInternal = {
/**
* Convert the original session restore state into a minimal state. It will
* only contain:
* - open windows
@@ -34,17 +34,17 @@ var SessionMigrationInternal = {
* - with pinned state
* - with tab group info (hidden + group id)
* - with selected tab info
* - with selected window info
*
* The complete state is then wrapped into the "about:welcomeback" page as
* form field info to be restored when restoring the state.
*/
- convertState: function(aStateObj) {
+ convertState(aStateObj) {
let state = {
selectedWindow: aStateObj.selectedWindow,
_closedWindows: []
};
state.windows = aStateObj.windows.map(function(oldWin) {
var win = {extData: {}};
win.tabs = oldWin.tabs.map(function(oldTab) {
var tab = {};
@@ -66,38 +66,38 @@ var SessionMigrationInternal = {
let url = "about:welcomeback";
let formdata = {id: {sessionData: state}, url};
let entry = { url, triggeringPrincipal_base64: Utils.SERIALIZED_SYSTEMPRINCIPAL };
return { windows: [{ tabs: [{ entries: [ entry ], formdata}]}]};
},
/**
* Asynchronously read session restore state (JSON) from a path
*/
- readState: function(aPath) {
+ readState(aPath) {
return Task.spawn(function*() {
let bytes = yield OS.File.read(aPath);
let text = gDecoder.decode(bytes);
let state = JSON.parse(text);
return state;
});
},
/**
* Asynchronously write session restore state as JSON to a path
*/
- writeState: function(aPath, aState) {
+ writeState(aPath, aState) {
let bytes = gEncoder.encode(JSON.stringify(aState));
return OS.File.writeAtomic(aPath, bytes, {tmpPath: aPath + ".tmp"});
}
}
var SessionMigration = {
/**
* Migrate a limited set of session data from one path to another.
*/
- migrate: function(aFromPath, aToPath) {
+ migrate(aFromPath, aToPath) {
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/SessionSaver.jsm
+++ b/browser/components/sessionstore/SessionSaver.jsm
@@ -26,17 +26,17 @@ XPCOMUtils.defineLazyModuleGetter(this,
XPCOMUtils.defineLazyModuleGetter(this, "SessionStore",
"resource:///modules/sessionstore/SessionStore.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SessionFile",
"resource:///modules/sessionstore/SessionFile.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "PrivateBrowsingUtils",
"resource://gre/modules/PrivateBrowsingUtils.jsm");
// Minimal interval between two save operations (in milliseconds).
-XPCOMUtils.defineLazyGetter(this, "gInterval", function () {
+XPCOMUtils.defineLazyGetter(this, "gInterval", function() {
const PREF = "browser.sessionstore.interval";
// Observer that updates the cached value when the preference changes.
Services.prefs.addObserver(PREF, () => {
this.gInterval = Services.prefs.getIntPref(PREF);
// Cancel any pending runs and call runDelayed() with
// zero to apply the newly configured interval.
@@ -49,17 +49,17 @@ XPCOMUtils.defineLazyGetter(this, "gInte
// Notify observers about a given topic with a given subject.
function notify(subject, topic) {
Services.obs.notifyObservers(subject, topic, "");
}
// TelemetryStopwatch helper functions.
function stopWatch(method) {
- return function (...histograms) {
+ return function(...histograms) {
for (let hist of histograms) {
TelemetryStopwatch[method]("FX_SESSION_RESTORE_" + hist);
}
};
}
var stopWatchStart = stopWatch("start");
var stopWatchCancel = stopWatch("cancel");
@@ -67,41 +67,41 @@ var stopWatchFinish = stopWatch("finish"
/**
* The external API implemented by the SessionSaver module.
*/
this.SessionSaver = Object.freeze({
/**
* Immediately saves the current session to disk.
*/
- run: function () {
+ run() {
return SessionSaverInternal.run();
},
/**
* Saves the current session to disk delayed by a given amount of time. Should
* another delayed run be scheduled already, we will ignore the given delay
* and state saving may occur a little earlier.
*/
- runDelayed: function () {
+ runDelayed() {
SessionSaverInternal.runDelayed();
},
/**
* Sets the last save time to the current time. This will cause us to wait for
* at least the configured interval when runDelayed() is called next.
*/
- updateLastSaveTime: function () {
+ updateLastSaveTime() {
SessionSaverInternal.updateLastSaveTime();
},
/**
* Cancels all pending session saves.
*/
- cancel: function () {
+ cancel() {
SessionSaverInternal.cancel();
}
});
/**
* The internal API.
*/
var SessionSaverInternal = {
@@ -116,66 +116,66 @@ var SessionSaverInternal = {
* this to determine the correct interval between delayed saves to not deceed
* the configured session write interval.
*/
_lastSaveTime: 0,
/**
* Immediately saves the current session to disk.
*/
- run: function () {
+ run() {
return this._saveState(true /* force-update all windows */);
},
/**
* Saves the current session to disk delayed by a given amount of time. Should
* another delayed run be scheduled already, we will ignore the given delay
* and state saving may occur a little earlier.
*
* @param delay (optional)
* The minimum delay in milliseconds to wait for until we collect and
* save the current session.
*/
- runDelayed: function (delay = 2000) {
+ runDelayed(delay = 2000) {
// Bail out if there's a pending run.
if (this._timeoutID) {
return;
}
// Interval until the next disk operation is allowed.
delay = Math.max(this._lastSaveTime + gInterval - Date.now(), delay, 0);
// Schedule a state save.
this._timeoutID = setTimeout(() => this._saveStateAsync(), delay);
},
/**
* Sets the last save time to the current time. This will cause us to wait for
* at least the configured interval when runDelayed() is called next.
*/
- updateLastSaveTime: function () {
+ updateLastSaveTime() {
this._lastSaveTime = Date.now();
},
/**
* Cancels all pending session saves.
*/
- cancel: function () {
+ cancel() {
clearTimeout(this._timeoutID);
this._timeoutID = null;
},
/**
* Saves the current session state. Collects data and writes to disk.
*
* @param forceUpdateAllWindows (optional)
* Forces us to recollect data for all windows and will bypass and
* update the corresponding caches.
*/
- _saveState: function (forceUpdateAllWindows = false) {
+ _saveState(forceUpdateAllWindows = false) {
// Cancel any pending timeouts.
this.cancel();
if (PrivateBrowsingUtils.permanentPrivateBrowsing) {
// Don't save (or even collect) anything in permanent private
// browsing mode
this.updateLastSaveTime();
@@ -236,28 +236,28 @@ var SessionSaverInternal = {
return this._writeState(state);
},
/**
* Saves the current session state. Collects data asynchronously and calls
* _saveState() to collect data again (with a cache hit rate of hopefully
* 100%) and write to disk afterwards.
*/
- _saveStateAsync: function () {
+ _saveStateAsync() {
// Allow scheduling delayed saves again.
this._timeoutID = null;
// Write to disk.
this._saveState();
},
/**
* Write the given state object to disk.
*/
- _writeState: function (state) {
+ _writeState(state) {
// We update the time stamp before writing so that we don't write again
// too soon, if saving is requested before the write completes. Without
// this update we may save repeatedly if actions cause a runDelayed
// before writing has completed. See Bug 902280
this.updateLastSaveTime();
// Write (atomically) to a session file, using a tmp file. Once the session
// file is successfully updated, save the time stamp of the last save and
--- a/browser/components/sessionstore/SessionStorage.jsm
+++ b/browser/components/sessionstore/SessionStorage.jsm
@@ -28,46 +28,46 @@ this.SessionStorage = Object.freeze({
* @param docShell
* That tab's docshell (containing the sessionStorage)
* @param frameTree
* The docShell's FrameTree instance.
* @return Returns a nested object that will have hosts as keys and per-host
* session storage data as strings. For example:
* {"example.com": {"key": "value", "my_number": "123"}}
*/
- collect: function (docShell, frameTree) {
+ collect(docShell, frameTree) {
return SessionStorageInternal.collect(docShell, frameTree);
},
/**
* Restores all sessionStorage "super cookies".
* @param aDocShell
* A tab's docshell (containing the sessionStorage)
* @param aStorageData
* A nested object with storage data to be restored that has hosts as
* keys and per-host session storage data as strings. For example:
* {"example.com": {"key": "value", "my_number": "123"}}
*/
- restore: function (aDocShell, aStorageData) {
+ restore(aDocShell, aStorageData) {
SessionStorageInternal.restore(aDocShell, aStorageData);
},
});
var SessionStorageInternal = {
/**
* Reads all session storage data from the given docShell.
* @param docShell
* A tab's docshell (containing the sessionStorage)
* @param frameTree
* The docShell's FrameTree instance.
* @return Returns a nested object that will have hosts as keys and per-host
* session storage data as strings. For example:
* {"example.com": {"key": "value", "my_number": "123"}}
*/
- collect: function (docShell, frameTree) {
+ collect(docShell, frameTree) {
let data = {};
let visitedOrigins = new Set();
frameTree.forEach(frame => {
let principal = getPrincipalForFrame(docShell, frame);
if (!principal) {
return;
}
@@ -103,17 +103,17 @@ var SessionStorageInternal = {
* Writes session storage data to the given tab.
* @param aDocShell
* A tab's docshell (containing the sessionStorage)
* @param aStorageData
* A nested object with storage data to be restored that has hosts as
* keys and per-host session storage data as strings. For example:
* {"example.com": {"key": "value", "my_number": "123"}}
*/
- restore: function (aDocShell, aStorageData) {
+ restore(aDocShell, aStorageData) {
for (let origin of Object.keys(aStorageData)) {
let data = aStorageData[origin];
let principal;
try {
let attrs = aDocShell.getOriginAttributes();
let originURI = Services.io.newURI(origin);
@@ -144,17 +144,17 @@ var SessionStorageInternal = {
/**
* Reads an entry in the session storage data contained in a tab's history.
* @param aURI
* That history entry uri
* @param aDocShell
* A tab's docshell (containing the sessionStorage)
*/
- _readEntry: function (aPrincipal, aDocShell) {
+ _readEntry(aPrincipal, aDocShell) {
let hostData = {};
let storage;
let window = aDocShell.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
try {
let storageManager = aDocShell.QueryInterface(Ci.nsIDOMStorageManager);
storage = storageManager.getStorage(window, aPrincipal);
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -321,17 +321,17 @@ this.SessionStore = {
persistTabAttribute: function ss_persistTabAttribute(aName) {
SessionStoreInternal.persistTabAttribute(aName);
},
restoreLastSession: function ss_restoreLastSession() {
SessionStoreInternal.restoreLastSession();
},
- getCurrentState: function (aUpdateAll) {
+ getCurrentState(aUpdateAll) {
return SessionStoreInternal.getCurrentState(aUpdateAll);
},
reviveCrashedTab(aTab) {
return SessionStoreInternal.reviveCrashedTab(aTab);
},
reviveAllCrashedTabs() {
@@ -378,17 +378,17 @@ this.SessionStore = {
/**
* Filters out not worth-saving tabs from a given browser state object.
*
* @param aState (object)
* The browser state for which we remove worth-saving tabs.
* The given object will be modified.
*/
- keepOnlyWorthSavingTabs: function (aState) {
+ keepOnlyWorthSavingTabs(aState) {
for (let i = aState.windows.length - 1; i >= 0; i--) {
let win = aState.windows[i];
for (let j = win.tabs.length - 1; j >= 0; j--) {
let tab = win.tabs[j];
if (!SessionStoreInternal._shouldSaveTab(tab)) {
win.tabs.splice(j, 1);
if (win.selected > j) {
win.selected--;
@@ -497,17 +497,17 @@ var SessionStoreInternal = {
// where we keep the session we actually wanted to restore in case the user
// decides to later open a non-private window as well.
_deferredInitialState: null,
// Keeps track of whether a notification needs to be sent that closed objects have changed.
_closedObjectsChanged: false,
// A promise resolved once initialization is complete
- _deferredInitialized: (function () {
+ _deferredInitialized: (function() {
let deferred = {};
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});
return deferred;
@@ -566,34 +566,34 @@ var SessionStoreInternal = {
}
}
return "tab";
},
/**
* Initialize the sessionstore service.
*/
- init: function () {
+ init() {
if (this._initialized) {
throw new Error("SessionStore.init() must only be called once!");
}
TelemetryTimestamps.add("sessionRestoreInitialized");
OBSERVING.forEach(function(aTopic) {
Services.obs.addObserver(this, aTopic, true);
}, this);
this._initPrefs();
this._initialized = true;
},
/**
* Initialize the session using the state provided by SessionStartup
*/
- initSession: function () {
+ initSession() {
TelemetryStopwatch.start("FX_SESSION_RESTORE_STARTUP_INIT_SESSION_MS");
let state;
let ss = gSessionStartup;
if (ss.doRestore() ||
ss.sessionType == Ci.nsISessionStartup.DEFER_SESSION) {
state = ss.state;
}
@@ -609,18 +609,17 @@ var SessionStoreInternal = {
if (iniState.windows.length)
state = iniState;
else
state = null;
if (remainingState.windows.length) {
LastSession.setState(remainingState);
}
- }
- else {
+ } else {
// Get the last deferred session in case the user still wants to
// restore it
LastSession.setState(state.lastSessionState);
if (ss.previousSessionCrashed) {
this._recentCrashes = (state.session &&
state.session.recentCrashes || 0) + 1;
@@ -650,31 +649,30 @@ var SessionStoreInternal = {
if (state.windows[0].sizemode == "minimized")
state.windows[0].sizemode = "normal";
// clear any lastSessionWindowID attributes since those don't matter
// during normal restore
state.windows.forEach(function(aWindow) {
delete aWindow.__lastSessionWindowID;
});
}
- }
- catch (ex) { debug("The session file is invalid: " + ex); }
+ } catch (ex) { debug("The session file is invalid: " + ex); }
}
// at this point, we've as good as resumed the session, so we can
// clear the resume_session_once flag, if it's set
if (!RunState.isQuitting &&
this._prefBranch.getBoolPref("sessionstore.resume_session_once"))
this._prefBranch.setBoolPref("sessionstore.resume_session_once", false);
TelemetryStopwatch.finish("FX_SESSION_RESTORE_STARTUP_INIT_SESSION_MS");
return state;
},
- _initPrefs : function() {
+ _initPrefs() {
this._prefBranch = Services.prefs.getBranch("browser.");
gDebuggingEnabled = this._prefBranch.getBoolPref("sessionstore.debug");
Services.prefs.addObserver("browser.sessionstore.debug", () => {
gDebuggingEnabled = this._prefBranch.getBoolPref("sessionstore.debug");
}, false);
@@ -952,17 +950,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) {
+ recordTelemetry(telemetry) {
for (let histogramId in telemetry) {
Telemetry.getHistogramById(histogramId).add(telemetry[histogramId]);
}
},
/* ........ Window Event Handlers .............. */
/**
@@ -1134,18 +1132,17 @@ var SessionStoreInternal = {
// global data must be restored before restoreWindow is called so that
// it happens before observers are notified
this._globalState.setFromState(aInitialState);
let overwrite = this._isCmdLineEmpty(aWindow, aInitialState);
let options = {firstWindow: true, overwriteTabs: overwrite};
this.restoreWindows(aWindow, aInitialState, options);
}
- }
- else {
+ } else {
// Nothing to restore, notify observers things are complete.
Services.obs.notifyObservers(null, NOTIFY_WINDOWS_RESTORED, "");
}
}
// this window was opened by _openWindowWithState
else if (!this._isWindowLoaded(aWindow)) {
let state = this._statesToRestore[aWindow.__SS_restoreID];
let options = {overwriteTabs: true, isFollowUp: state.windows.length == 1};
@@ -1160,18 +1157,17 @@ var SessionStoreInternal = {
// global data must be restored before restoreWindow is called so that
// it happens before observers are notified
this._globalState.setFromState(this._deferredInitialState);
this._restoreCount = this._deferredInitialState.windows ?
this._deferredInitialState.windows.length : 0;
this.restoreWindows(aWindow, this._deferredInitialState, {firstWindow: true});
this._deferredInitialState = null;
- }
- else if (this._restoreLastWindow && aWindow.toolbar.visible &&
+ } else if (this._restoreLastWindow && aWindow.toolbar.visible &&
this._closedWindows.length && !isPrivateWindow) {
// default to the most-recently closed window
// don't use popup windows
let closedWindowState = null;
let closedWindowIndex;
for (let i = 0; i < this._closedWindows.length; i++) {
// Take the first non-popup, point our object at it, and break out.
@@ -1203,18 +1199,17 @@ var SessionStoreInternal = {
if (!normalTabsState.windows.length) {
this._removeClosedWindow(closedWindowIndex);
}
// Or update _closedWindows with the modified state
else {
delete normalTabsState.windows[0].__lastSessionWindowID;
this._closedWindows[closedWindowIndex] = normalTabsState.windows[0];
}
- }
- else {
+ } else {
// If we're just restoring the window, make sure it gets removed from
// _closedWindows.
this._removeClosedWindow(closedWindowIndex);
newWindowState = closedWindowState;
delete newWindowState.hidden;
}
if (newWindowState) {
@@ -1236,17 +1231,17 @@ var SessionStoreInternal = {
}
},
/**
* Called right before a new browser window is shown.
* @param aWindow
* Window reference
*/
- onBeforeBrowserWindowShown: function (aWindow) {
+ onBeforeBrowserWindowShown(aWindow) {
// Register the window.
this.onLoad(aWindow);
// Just call initializeWindow() directly if we're initialized already.
if (this._sessionInitialized) {
this.initializeWindow(aWindow);
return;
}
@@ -1542,17 +1537,17 @@ var SessionStoreInternal = {
this._removeClosedWindow(winIndex);
}
}
},
/**
* On quit application granted
*/
- onQuitApplicationGranted: function ssi_onQuitApplicationGranted(syncShutdown=false) {
+ onQuitApplicationGranted: function ssi_onQuitApplicationGranted(syncShutdown = false) {
// Collect an initial snapshot of window data before we do the flush
this._forEachBrowserWindow((win) => {
this._collectWindowData(win);
});
// Now add an AsyncShutdown blocker that'll spin the event loop
// until the windows have all been flushed.
@@ -1618,17 +1613,17 @@ var SessionStoreInternal = {
*
* total (int):
* The total number of windows to be flushed.
* current (int):
* The current window that we're waiting for a flush on.
*
* @return Promise
*/
- flushAllWindowsAsync: Task.async(function*(progress={}) {
+ flushAllWindowsAsync: Task.async(function*(progress = {}) {
let windowPromises = new Map();
// We collect flush promises and close each window immediately so that
// the user can't start changing any window state while we're waiting
// for the flushes to finish.
this._forEachBrowserWindow((win) => {
windowPromises.set(win, TabStateFlusher.flushWindow(win));
// We have to wait for these messages to come up from
@@ -1777,18 +1772,17 @@ var SessionStoreInternal = {
if (openTabs[j].entries.some(containsDomain, this)) {
openTabs.splice(j, 1);
if (this._closedWindows[ix].selected > j)
this._closedWindows[ix].selected--;
}
}
if (openTabs.length == 0) {
this._closedWindows.splice(ix, 1);
- }
- else if (openTabs.length != openTabCount) {
+ } else if (openTabs.length != openTabCount) {
// Adjust the window's title if we removed an open tab
let selectedTab = openTabs[this._closedWindows[ix].selected - 1];
// some duplication from restoreHistory - make sure we get the correct title
let activeIndex = (selectedTab.index || selectedTab.entries.length) - 1;
if (activeIndex >= selectedTab.entries.length)
activeIndex = selectedTab.entries.length - 1;
this._closedWindows[ix].title = selectedTab.entries[activeIndex].title;
}
@@ -2073,17 +2067,17 @@ var SessionStoreInternal = {
/**
* Handler for the event that is fired when a <xul:browser> crashes.
*
* @param aWindow
* The window that the crashed browser belongs to.
* @param aBrowser
* The <xul:browser> that is now in the crashed state.
*/
- onBrowserCrashed: function(aBrowser) {
+ onBrowserCrashed(aBrowser) {
NS_ASSERT(aBrowser.isRemoteBrowser,
"Only remote browsers should be able to crash");
this.enterCrashedState(aBrowser);
// The browser crashed so we might never receive flush responses.
// Resolve all pending flush requests for the crashed browser.
TabStateFlusher.resolveAll(aBrowser);
},
@@ -2109,36 +2103,36 @@ var SessionStoreInternal = {
let tab = win.gBrowser.getTabForBrowser(browser);
this._resetLocalTabRestoringState(tab);
}
},
// Clean up data that has been closed a long time ago.
// Do not reschedule a save. This will wait for the next regular
// save.
- onIdleDaily: function() {
+ onIdleDaily() {
// Remove old closed windows
this._cleanupOldData([this._closedWindows]);
// Remove closed tabs of closed windows
this._cleanupOldData(this._closedWindows.map((winData) => winData._closedTabs));
// Remove closed tabs of open windows
this._cleanupOldData(Object.keys(this._windows).map((key) => this._windows[key]._closedTabs));
this._notifyOfClosedObjectsChange();
},
// Remove "old" data from an array
- _cleanupOldData: function(targets) {
+ _cleanupOldData(targets) {
const TIME_TO_LIVE = this._prefBranch.getIntPref("sessionstore.cleanup.forget_closed_after");
const now = Date.now();
for (let array of targets) {
- for (let i = array.length - 1; i >= 0; --i) {
+ for (let i = array.length - 1; i >= 0; --i) {
let data = array[i];
// Make sure that we have a timestamp to tell us when the target
// has been closed. If we don't have a timestamp, default to a
// safe timestamp: just now.
data.closedAt = data.closedAt || now;
if (now - data.closedAt > TIME_TO_LIVE) {
array.splice(i, 1);
this._closedObjectsChanged = true;
@@ -2161,18 +2155,17 @@ var SessionStoreInternal = {
return JSON.stringify(state);
},
setBrowserState: function ssi_setBrowserState(aState) {
this._handleClosedWindows();
try {
var state = JSON.parse(aState);
- }
- catch (ex) { /* invalid state object - don't restore anything */ }
+ } catch (ex) { /* invalid state object - don't restore anything */ }
if (!state) {
throw Components.Exception("Invalid state string: not JSON", Cr.NS_ERROR_INVALID_ARG);
}
if (!state.windows) {
throw Components.Exception("No windows", Cr.NS_ERROR_INVALID_ARG);
}
this._browserSetState = true;
@@ -2653,22 +2646,21 @@ var SessionStoreInternal = {
if (winState._closedTabs && winState._closedTabs.length) {
let curWinState = this._windows[windowToUse.__SSi];
curWinState._closedTabs = curWinState._closedTabs.concat(winState._closedTabs);
curWinState._closedTabs.splice(this._max_tabs_undo, curWinState._closedTabs.length);
}
// Restore into that window - pretend it's a followup since we'll already
// have a focused window.
- //XXXzpao This is going to merge extData together (taking what was in
+ // XXXzpao This is going to merge extData together (taking what was in
// winState over what is in the window already.
let options = {overwriteTabs: canOverwriteTabs, isFollowUp: true};
this.restoreWindow(windowToUse, winState, options);
- }
- else {
+ } else {
this._openWindowWithState({ windows: [winState] });
}
}
// Merge closed windows from this session with ones from last session
if (lastSessionState._closedWindows) {
this._closedWindows = this._closedWindows.concat(lastSessionState._closedWindows);
this._capClosedWindows();
@@ -2896,18 +2888,17 @@ var SessionStoreInternal = {
let tab = tabbrowser.tabs[i];
if (homePages.indexOf(tab.linkedBrowser.currentURI.spec) != -1) {
removableTabs.push(tab);
}
}
if (tabbrowser.tabs.length == removableTabs.length) {
canOverwriteTabs = true;
- }
- else {
+ } else {
// If we're not overwriting all of the tabs, then close the home tabs.
for (let i = removableTabs.length - 1; i >= 0; i--) {
tabbrowser.removeTab(removableTabs.pop(), { animate: false });
}
}
return [true, canOverwriteTabs];
},
@@ -2942,33 +2933,32 @@ var SessionStoreInternal = {
},
/**
* gather session data as object
* @param aUpdateAll
* Bool update all windows
* @returns object
*/
- getCurrentState: function (aUpdateAll) {
+ getCurrentState(aUpdateAll) {
this._handleClosedWindows().then(() => {
this._notifyOfClosedObjectsChange();
});
var activeWindow = this._getMostRecentBrowserWindow();
TelemetryStopwatch.start("FX_SESSION_RESTORE_COLLECT_ALL_WINDOWS_DATA_MS");
if (RunState.isRunning) {
// update the data for all windows with activities since the last save operation
this._forEachBrowserWindow(function(aWindow) {
if (!this._isWindowLoaded(aWindow)) // window data is still in _statesToRestore
return;
if (aUpdateAll || DirtyWindows.has(aWindow) || aWindow == activeWindow) {
this._collectWindowData(aWindow);
- }
- else { // always update the window features (whose change alone never triggers a save operation)
+ } else { // always update the window features (whose change alone never triggers a save operation)
this._updateWindowFeatures(aWindow);
}
});
DirtyWindows.clear();
}
TelemetryStopwatch.finish("FX_SESSION_RESTORE_COLLECT_ALL_WINDOWS_DATA_MS");
// An array that at the end will hold all current window data.
@@ -3004,17 +2994,17 @@ var SessionStoreInternal = {
// shallow copy this._closedWindows to preserve current state
let lastClosedWindowsCopy = this._closedWindows.slice();
if (AppConstants.platform != "macosx") {
// If no non-popup browser window remains open, return the state of the last
// closed window(s). We only want to do this when we're actually "ending"
// the session.
- //XXXzpao We should do this for _restoreLastWindow == true, but that has
+ // XXXzpao We should do this for _restoreLastWindow == true, but that has
// its own check for popups. c.f. bug 597619
if (nonPopupCount == 0 && lastClosedWindowsCopy.length > 0 &&
RunState.isQuitting) {
// prepend the last non-popup browser window, so that if the user loads more tabs
// at startup we don't accidentally add them to a popup window
do {
total.unshift(lastClosedWindowsCopy.shift())
} while (total[0].isPopup && lastClosedWindowsCopy.length > 0)
@@ -3036,17 +3026,17 @@ var SessionStoreInternal = {
recentCrashes: this._recentCrashes
};
let state = {
version: ["sessionrestore", FORMAT_VERSION],
windows: total,
selectedWindow: ix + 1,
_closedWindows: lastClosedWindowsCopy,
- session: session,
+ session,
global: this._globalState.getState()
};
if (Cu.isModuleLoaded("resource://devtools/client/scratchpad/scratchpad-manager.jsm")) {
// get open Scratchpad window states too
let scratchpads = ScratchpadManager.getSessionState();
if (scratchpads && scratchpads.length) {
state.scratchpads = scratchpads;
@@ -3080,17 +3070,17 @@ var SessionStoreInternal = {
if (RunState.isRunning) {
this._collectWindowData(aWindow);
}
let windows = [this._windows[aWindow.__SSi]];
SessionCookies.update(windows);
- return { windows: windows };
+ return { windows };
},
/**
* Gathers data about a window and its tabs, and updates its
* entry in this._windows.
*
* @param aWindow
* Window references.
@@ -3229,18 +3219,17 @@ var SessionStoreInternal = {
tabs.push(tab);
if (winData.tabs[t].pinned)
tabbrowser.pinTab(tabs[t]);
if (winData.tabs[t].hidden) {
tabbrowser.hideTab(tabs[t]);
- }
- else {
+ } else {
tabbrowser.showTab(tabs[t]);
numVisibleTabs++;
}
if (!!winData.tabs[t].muted != tabs[t].linkedBrowser.audioMuted) {
tabs[t].toggleMuteAudio(winData.tabs[t].muteReason);
}
}
@@ -3362,18 +3351,17 @@ var SessionStoreInternal = {
// initialize window if necessary
if (aWindow && (!aWindow.__SSi || !this._windows[aWindow.__SSi]))
this.onLoad(aWindow);
let root;
try {
root = (typeof aState == "string") ? JSON.parse(aState) : aState;
- }
- catch (ex) { // invalid state object - don't restore anything
+ } catch (ex) { // invalid state object - don't restore anything
debug(ex);
this._sendRestoreCompletedNotifications();
return;
}
// Restore closed windows if any.
if (root._closedWindows) {
this._closedWindows = root._closedWindows;
@@ -3583,17 +3571,17 @@ var SessionStoreInternal = {
// collect it in TabState._collectBaseTabData().
image: tabData.image || "",
iconLoadingPrincipal: tabData.iconLoadingPrincipal || null,
userTypedValue: tabData.userTypedValue || "",
userTypedClear: tabData.userTypedClear || 0
});
browser.messageManager.sendAsyncMessage("SessionStore:restoreHistory",
- {tabData: tabData, epoch: epoch, loadArguments});
+ {tabData, epoch, loadArguments});
// Restore tab attributes.
if ("attributes" in tabData) {
TabAttributes.set(tab, tabData.attributes);
}
// This could cause us to ignore MAX_CONCURRENT_TAB_RESTORES a bit, but
// it ensures each window will have its selected tab loaded.
@@ -3612,17 +3600,17 @@ var SessionStoreInternal = {
*
* @param aTab
* the tab to restore
* @param aLoadArguments
* optional load arguments used for loadURI()
* @param aReloadInFreshProcess
* true if we want to reload into a fresh process
*/
- restoreTabContent: function (aTab, aLoadArguments = null, aReloadInFreshProcess = false) {
+ restoreTabContent(aTab, aLoadArguments = null, aReloadInFreshProcess = false) {
if (aTab.hasAttribute("customizemode") && !aLoadArguments) {
return;
}
let browser = aTab.linkedBrowser;
let window = aTab.ownerGlobal;
let tabbrowser = window.gBrowser;
let tabData = TabState.clone(aTab);
@@ -3645,30 +3633,30 @@ var SessionStoreInternal = {
// We need a new frameloader either if we are reloading into a fresh
// process, or we have a browser with a grouped session history (as we don't
// support restoring into browsers with grouped session histories directly).
let newFrameloader =
aReloadInFreshProcess || !!browser.frameLoader.groupedSHistory;
let isRemotenessUpdate =
tabbrowser.updateBrowserRemotenessByURL(browser, uri, {
freshProcess: aReloadInFreshProcess,
- newFrameloader: newFrameloader,
+ newFrameloader,
});
if (isRemotenessUpdate) {
// We updated the remoteness, so we need to send the history down again.
//
// Start a new epoch to discard all frame script messages relating to a
// previous epoch. All async messages that are still on their way to chrome
// will be ignored and don't override any tab data set when restoring.
let epoch = this.startNextEpoch(browser);
browser.messageManager.sendAsyncMessage("SessionStore:restoreHistory", {
- tabData: tabData,
- epoch: epoch,
+ tabData,
+ epoch,
loadArguments: aLoadArguments,
isRemotenessUpdate,
});
}
// If the restored browser wants to show view source content, start up a
// view source browser that will load the required frame script.
@@ -3730,29 +3718,28 @@ var SessionStoreInternal = {
/**
* Restore visibility and dimension features to a window
* @param aWindow
* Window reference
* @param aWinData
* Object containing session data for the window
*/
restoreWindowFeatures: function ssi_restoreWindowFeatures(aWindow, aWinData) {
- var hidden = (aWinData.hidden)?aWinData.hidden.split(","):[];
+ var hidden = (aWinData.hidden) ? aWinData.hidden.split(",") : [];
WINDOW_HIDEABLE_FEATURES.forEach(function(aItem) {
aWindow[aItem].visible = hidden.indexOf(aItem) == -1;
});
if (aWinData.isPopup) {
this._windows[aWindow.__SSi].isPopup = true;
if (aWindow.gURLBar) {
aWindow.gURLBar.readOnly = true;
aWindow.gURLBar.setAttribute("enablehistory", "false");
}
- }
- else {
+ } else {
delete this._windows[aWindow.__SSi].isPopup;
if (aWindow.gURLBar) {
aWindow.gURLBar.readOnly = false;
aWindow.gURLBar.setAttribute("enablehistory", "true");
}
}
var _this = this;
@@ -3839,20 +3826,18 @@ var SessionStoreInternal = {
}
if (aWidth && aHeight && (aWidth != win_("width") || aHeight != win_("height"))) {
// Don't resize the window if it's currently maximized and we would
// maximize it again shortly after.
if (aSizeMode != "maximized" || win_("sizemode") != "maximized") {
aWindow.resizeTo(aWidth, aHeight);
}
}
- if (aSizeMode && win_("sizemode") != aSizeMode)
- {
- switch (aSizeMode)
- {
+ if (aSizeMode && win_("sizemode") != aSizeMode) {
+ switch (aSizeMode) {
case "maximized":
aWindow.maximize();
break;
case "minimized":
aWindow.minimize();
break;
case "normal":
aWindow.restore();
@@ -3874,17 +3859,17 @@ var SessionStoreInternal = {
/**
* Save the current session state to disk, after a delay.
*
* @param aWindow (optional)
* Will mark the given window as dirty so that we will recollect its
* data before we start writing.
*/
- saveStateDelayed: function (aWindow = null) {
+ saveStateDelayed(aWindow = null) {
if (aWindow) {
DirtyWindows.add(aWindow);
}
SessionSaver.runDelayed();
},
/* ........ Auxiliary Functions .............. */
@@ -4166,17 +4151,17 @@ var SessionStoreInternal = {
sessionAge && sessionAge >= SIX_HOURS_IN_MS);
},
/**
* @param aWinData is the set of windows in session state
* @param aURL is the single URL we're looking for
* @returns whether the window data contains only the single URL passed
*/
- _hasSingleTabWithURL: function(aWinData, aURL) {
+ _hasSingleTabWithURL(aWinData, aURL) {
if (aWinData &&
aWinData.length == 1 &&
aWinData[0].tabs &&
aWinData[0].tabs.length == 1 &&
aWinData[0].tabs[0].entries &&
aWinData[0].tabs[0].entries.length == 1) {
return aURL == aWinData[0].tabs[0].entries[0].url;
}
@@ -4533,17 +4518,17 @@ var SessionStoreInternal = {
/**
* Reset the restoring state for a particular tab. This will be called when
* removing a tab or when a tab needs to be reset (it's being overwritten).
*
* @param aTab
* The tab that will be "reset"
*/
- _resetLocalTabRestoringState: function (aTab) {
+ _resetLocalTabRestoringState(aTab) {
NS_ASSERT(aTab.linkedBrowser.__SS_restoreState,
"given tab is not restoring");
let browser = aTab.linkedBrowser;
// Keep the tab's previous state for later in this method
let previousState = browser.__SS_restoreState;
@@ -4559,17 +4544,17 @@ var SessionStoreInternal = {
} else if (previousState == TAB_STATE_NEEDS_RESTORE) {
// Make sure that the tab is removed from the list of tabs to restore.
// Again, this is normally done in restoreTabContent, but that isn't being called
// for this tab.
TabRestoreQueue.remove(aTab);
}
},
- _resetTabRestoringState: function (tab) {
+ _resetTabRestoringState(tab) {
NS_ASSERT(tab.linkedBrowser.__SS_restoreState,
"given tab is not restoring");
let browser = tab.linkedBrowser;
browser.messageManager.sendAsyncMessage("SessionStore:resetRestore", {});
this._resetLocalTabRestoringState(tab);
},
@@ -4603,17 +4588,17 @@ var SessionStoreInternal = {
/**
* Each time a <browser> element is restored, we increment its "epoch". To
* check if a message from content-sessionStore.js is out of date, we can
* compare the epoch received with the message to the <browser> element's
* epoch. This function does that, and returns true if |epoch| is up-to-date
* with respect to |browser|.
*/
- isCurrentEpoch: function (browser, epoch) {
+ isCurrentEpoch(browser, epoch) {
return this.getCurrentEpoch(browser) == epoch;
},
/**
* Resets the epoch for a given <browser>. We need to this every time we
* receive a hint that a new docShell has been loaded into the browser as
* the frame script starts out with epoch=0.
*/
@@ -4674,75 +4659,75 @@ var TabRestoreQueue = {
// Preferences used by the TabRestoreQueue to determine which tabs
// are restored automatically and which tabs will be on-demand.
prefs: {
// Lazy getter that returns whether tabs are restored on demand.
get restoreOnDemand() {
let updateValue = () => {
let value = Services.prefs.getBoolPref(PREF);
- let definition = {value: value, configurable: true};
+ let definition = {value, configurable: true};
Object.defineProperty(this, "restoreOnDemand", definition);
return value;
}
const PREF = "browser.sessionstore.restore_on_demand";
Services.prefs.addObserver(PREF, updateValue, false);
return updateValue();
},
// Lazy getter that returns whether pinned tabs are restored on demand.
get restorePinnedTabsOnDemand() {
let updateValue = () => {
let value = Services.prefs.getBoolPref(PREF);
- let definition = {value: value, configurable: true};
+ let definition = {value, configurable: true};
Object.defineProperty(this, "restorePinnedTabsOnDemand", definition);
return value;
}
const PREF = "browser.sessionstore.restore_pinned_tabs_on_demand";
Services.prefs.addObserver(PREF, updateValue, false);
return updateValue();
},
// Lazy getter that returns whether we should restore hidden tabs.
get restoreHiddenTabs() {
let updateValue = () => {
let value = Services.prefs.getBoolPref(PREF);
- let definition = {value: value, configurable: true};
+ let definition = {value, configurable: true};
Object.defineProperty(this, "restoreHiddenTabs", definition);
return value;
}
const PREF = "browser.sessionstore.restore_hidden_tabs";
Services.prefs.addObserver(PREF, updateValue, false);
return updateValue();
}
},
// Resets the queue and removes all tabs.
- reset: function () {
+ reset() {
this.tabs = {priority: [], visible: [], hidden: []};
},
// Adds a tab to the queue and determines its priority bucket.
- add: function (tab) {
+ add(tab) {
let {priority, hidden, visible} = this.tabs;
if (tab.pinned) {
priority.push(tab);
} else if (tab.hidden) {
hidden.push(tab);
} else {
visible.push(tab);
}
},
// Removes a given tab from the queue, if it's in there.
- remove: function (tab) {
+ remove(tab) {
let {priority, hidden, visible} = this.tabs;
// We'll always check priority first since we don't
// have an indicator if a tab will be there or not.
let set = priority;
let index = set.indexOf(tab);
if (index == -1) {
@@ -4751,17 +4736,17 @@ var TabRestoreQueue = {
}
if (index > -1) {
set.splice(index, 1);
}
},
// Returns and removes the tab with the highest priority.
- shift: function () {
+ shift() {
let set;
let {priority, hidden, visible} = this.tabs;
let {restoreOnDemand, restorePinnedTabsOnDemand} = this.prefs;
let restorePinned = !(restoreOnDemand && restorePinnedTabsOnDemand);
if (restorePinned && priority.length) {
set = priority;
} else if (!restoreOnDemand) {
@@ -4771,28 +4756,28 @@ var TabRestoreQueue = {
set = hidden;
}
}
return set && set.shift();
},
// Moves a given tab from the 'hidden' to the 'visible' bucket.
- hiddenToVisible: function (tab) {
+ hiddenToVisible(tab) {
let {hidden, visible} = this.tabs;
let index = hidden.indexOf(tab);
if (index > -1) {
hidden.splice(index, 1);
visible.push(tab);
}
},
// Moves a given tab from the 'visible' to the 'hidden' bucket.
- visibleToHidden: function (tab) {
+ visibleToHidden(tab) {
let {visible, hidden} = this.tabs;
let index = visible.indexOf(tab);
if (index > -1) {
visible.splice(index, 1);
hidden.push(tab);
}
},
@@ -4800,17 +4785,17 @@ var TabRestoreQueue = {
/**
* Returns true if the passed tab is in one of the sets that we're
* restoring content in automatically.
*
* @param tab (<xul:tab>)
* The tab to check
* @returns bool
*/
- willRestoreSoon: function (tab) {
+ willRestoreSoon(tab) {
let { priority, hidden, visible } = this.tabs;
let { restoreOnDemand, restorePinnedTabsOnDemand,
restoreHiddenTabs } = this.prefs;
let restorePinned = !(restoreOnDemand && restorePinnedTabsOnDemand);
let candidateSet = [];
if (restorePinned && priority.length)
candidateSet.push(...priority);
@@ -4828,73 +4813,73 @@ var TabRestoreQueue = {
};
// A map storing a closed window's state data until it goes aways (is GC'ed).
// This ensures that API clients can still read (but not write) states of
// windows they still hold a reference to but we don't.
var DyingWindowCache = {
_data: new WeakMap(),
- has: function (window) {
+ has(window) {
return this._data.has(window);
},
- get: function (window) {
+ get(window) {
return this._data.get(window);
},
- set: function (window, data) {
+ set(window, data) {
this._data.set(window, data);
},
- remove: function (window) {
+ remove(window) {
this._data.delete(window);
}
};
// A weak set of dirty windows. We use it to determine which windows we need to
// recollect data for when getCurrentState() is called.
var DirtyWindows = {
_data: new WeakMap(),
- has: function (window) {
+ has(window) {
return this._data.has(window);
},
- add: function (window) {
+ add(window) {
return this._data.set(window, true);
},
- remove: function (window) {
+ remove(window) {
this._data.delete(window);
},
- clear: function (window) {
+ clear(window) {
this._data = new WeakMap();
}
};
// The state from the previous session (after restoring pinned tabs). This
// state is persisted and passed through to the next session during an app
// restart to make the third party add-on warning not trash the deferred
// session
var LastSession = {
_state: null,
get canRestore() {
return !!this._state;
},
- getState: function () {
+ getState() {
return this._state;
},
- setState: function (state) {
+ setState(state) {
this._state = state;
},
- clear: function () {
+ clear() {
if (this._state) {
this._state = null;
Services.obs.notifyObservers(null, NOTIFY_LAST_SESSION_CLEARED, null);
}
}
};
--- a/browser/components/sessionstore/SessionWorker.js
+++ b/browser/components/sessionstore/SessionWorker.js
@@ -119,17 +119,17 @@ var Agent = {
* @param {object} state The state to write to disk.
* @param {object} options
* - performShutdownCleanup If |true|, we should
* perform shutdown-time cleanup to ensure that private data
* is not left lying around;
* - isFinalWrite If |true|, write to Paths.clean instead of
* Paths.recovery
*/
- write: function (state, options = {}) {
+ write(state, options = {}) {
let exn;
let telemetry = {};
// Cap the number of backward and forward shistory entries on shutdown.
if (options.isFinalWrite) {
for (let window of state.windows) {
for (let tab of window.tabs) {
let lower = 0;
@@ -222,17 +222,17 @@ var Agent = {
// Find all backups
let iterator;
let backups = []; // array that will contain the paths to all upgrade backup
let upgradeBackupPrefix = this.Paths.upgradeBackupPrefix; // access for forEach callback
try {
iterator = new File.DirectoryIterator(this.Paths.backups);
- iterator.forEach(function (file) {
+ iterator.forEach(function(file) {
if (file.path.startsWith(upgradeBackupPrefix)) {
backups.push(file.path);
}
}, this);
} catch (ex) {
// Don't throw immediately
exn = exn || ex;
} finally {
@@ -271,24 +271,24 @@ var Agent = {
if (exn) {
throw exn;
}
return {
result: {
upgradeBackup: upgradeBackupComplete
},
- telemetry: telemetry,
+ telemetry,
};
},
/**
* Wipes all files holding session data from disk.
*/
- wipe: function () {
+ wipe() {
// Don't stop immediately in case of error.
let exn = null;
// Erase main session state file
try {
File.remove(this.Paths.clean);
} catch (ex) {
@@ -327,17 +327,17 @@ var Agent = {
/**
* Wipe a number of files from a directory.
*
* @param {string} path The directory.
* @param {string|null} prefix If provided, only remove files whose
* name starts with a specific prefix.
*/
- _wipeFromDir: function(path, prefix) {
+ _wipeFromDir(path, prefix) {
// Sanity check
if (typeof prefix == "undefined" || prefix == "") {
throw new TypeError();
}
let exn = null;
let iterator = new File.DirectoryIterator(path);
--- a/browser/components/sessionstore/StartupPerformance.jsm
+++ b/browser/components/sessionstore/StartupPerformance.jsm
@@ -52,17 +52,17 @@ this.StartupPerformance = {
// `true` once we are restored
_isRestored: false,
// Statistics on the session we need to restore.
_totalNumberOfEagerTabs: 0,
_totalNumberOfTabs: 0,
_totalNumberOfWindows: 0,
- init: function() {
+ init() {
for (let topic of OBSERVED_TOPICS) {
Services.obs.addObserver(this, topic, false);
}
},
/**
* Return the timestamp at which we finished restoring the latest tab.
*
@@ -78,17 +78,17 @@ this.StartupPerformance = {
*/
get isRestored() {
return this._isRestored;
},
// Called when restoration starts.
// Record the start timestamp, setup the timer and `this._promiseFinished`.
// Behavior is unspecified if there was already an ongoing measure.
- _onRestorationStarts: function(isAutoRestore) {
+ _onRestorationStarts(isAutoRestore) {
this._latestRestoredTimeStamp = this._startTimeStamp = Date.now();
this._totalNumberOfEagerTabs = 0;
this._totalNumberOfTabs = 0;
this._totalNumberOfWindows = 0;
// While we may restore several sessions in a single run of the browser,
// that's a very unusual case, and not really worth measuring, so let's
// stop listening for further restorations.
@@ -126,17 +126,17 @@ this.StartupPerformance = {
// Reset
this._startTimeStamp = null;
} catch (ex) {
console.error("StartupPerformance: error after resolving promise", ex);
}
});
},
- _startTimer: function() {
+ _startTimer() {
if (this._hasFired) {
return;
}
if (this._deadlineTimer) {
clearTimeout(this._deadlineTimer);
}
this._deadlineTimer = setTimeout(() => {
try {
@@ -148,17 +148,17 @@ this.StartupPerformance = {
this._deadlineTimer = null;
this._hasFired = true;
this._resolveFinished = null;
Services.obs.removeObserver(this, "sessionstore-single-window-restored");
}
}, COLLECT_RESULTS_AFTER_MS);
},
- observe: function(subject, topic, details) {
+ observe(subject, topic, details) {
try {
switch (topic) {
case "sessionstore-restoring-on-startup":
this._onRestorationStarts(true);
break;
case "sessionstore-initiating-manual-restore":
this._onRestorationStarts(false);
break;
--- a/browser/components/sessionstore/TabAttributes.jsm
+++ b/browser/components/sessionstore/TabAttributes.jsm
@@ -15,54 +15,54 @@ this.EXPORTED_SYMBOLS = ["TabAttributes"
// 'iconLoadingPrincipal' is same as 'image' that it should be handled by
// using the gBrowser.getIcon()/setIcon() methods.
const ATTRIBUTES_TO_SKIP = new Set(["image", "muted", "pending", "iconLoadingPrincipal"]);
// A set of tab attributes to persist. We will read a given list of tab
// attributes when collecting tab data and will re-set those attributes when
// the given tab data is restored to a new tab.
this.TabAttributes = Object.freeze({
- persist: function (name) {
+ persist(name) {
return TabAttributesInternal.persist(name);
},
- get: function (tab) {
+ get(tab) {
return TabAttributesInternal.get(tab);
},
- set: function (tab, data = {}) {
+ set(tab, data = {}) {
TabAttributesInternal.set(tab, data);
}
});
var TabAttributesInternal = {
_attrs: new Set(),
- persist: function (name) {
+ persist(name) {
if (this._attrs.has(name) || ATTRIBUTES_TO_SKIP.has(name)) {
return false;
}
this._attrs.add(name);
return true;
},
- get: function (tab) {
+ get(tab) {
let data = {};
for (let name of this._attrs) {
if (tab.hasAttribute(name)) {
data[name] = tab.getAttribute(name);
}
}
return data;
},
- set: function (tab, data = {}) {
+ set(tab, data = {}) {
// Clear attributes.
for (let name of this._attrs) {
tab.removeAttribute(name);
}
// Set attributes.
for (let name in data) {
if (!ATTRIBUTES_TO_SKIP.has(name)) {
--- a/browser/components/sessionstore/TabState.jsm
+++ b/browser/components/sessionstore/TabState.jsm
@@ -18,81 +18,81 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource:///modules/sessionstore/TabAttributes.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "Utils",
"resource://gre/modules/sessionstore/Utils.jsm");
/**
* Module that contains tab state collection methods.
*/
this.TabState = Object.freeze({
- update: function (browser, data) {
+ update(browser, data) {
TabStateInternal.update(browser, data);
},
- collect: function (tab) {
+ collect(tab) {
return TabStateInternal.collect(tab);
},
- clone: function (tab) {
+ clone(tab) {
return TabStateInternal.clone(tab);
},
copyFromCache(browser, tabData, options) {
TabStateInternal.copyFromCache(browser, tabData, options);
},
});
var TabStateInternal = {
/**
* Processes a data update sent by the content script.
*/
- update: function (browser, {data}) {
+ update(browser, {data}) {
TabStateCache.update(browser, data);
},
/**
* Collect data related to a single tab, synchronously.
*
* @param tab
* tabbrowser tab
*
* @returns {TabData} An object with the data for this tab. If the
* tab has not been invalidated since the last call to
* collect(aTab), the same object is returned.
*/
- collect: function (tab) {
+ collect(tab) {
return this._collectBaseTabData(tab);
},
/**
* Collect data related to a single tab, including private data.
* Use with caution.
*
* @param tab
* tabbrowser tab
*
* @returns {object} An object with the data for this tab. This data is never
* cached, it will always be read from the tab and thus be
* up-to-date.
*/
- clone: function (tab) {
+ clone(tab) {
return this._collectBaseTabData(tab, {includePrivateData: true});
},
/**
* Collects basic tab data for a given tab.
*
* @param tab
* tabbrowser tab
* @param options (object)
* {includePrivateData: true} to always include private data
*
* @returns {object} An object with the basic data for this tab.
*/
- _collectBaseTabData: function (tab, options) {
+ _collectBaseTabData(tab, options) {
let tabData = { entries: [], lastAccessed: tab.lastAccessed };
let browser = tab.linkedBrowser;
if (tab.pinned) {
tabData.pinned = true;
}
tabData.hidden = tab.hidden;
--- a/browser/components/sessionstore/TabStateCache.jsm
+++ b/browser/components/sessionstore/TabStateCache.jsm
@@ -21,61 +21,61 @@ this.TabStateCache = Object.freeze({
* Retrieves cached data for a given |tab| or associated |browser|.
*
* @param browserOrTab (xul:tab or xul:browser)
* The tab or browser to retrieve cached data for.
* @return (object)
* The cached data stored for the given |tab|
* or associated |browser|.
*/
- get: function (browserOrTab) {
+ get(browserOrTab) {
return TabStateCacheInternal.get(browserOrTab);
},
/**
* Updates cached data for a given |tab| or associated |browser|.
*
* @param browserOrTab (xul:tab or xul:browser)
* The tab or browser belonging to the given tab data.
* @param newData (object)
* The new data to be stored for the given |tab|
* or associated |browser|.
*/
- update: function (browserOrTab, newData) {
+ update(browserOrTab, newData) {
TabStateCacheInternal.update(browserOrTab, newData);
}
});
var TabStateCacheInternal = {
_data: new WeakMap(),
/**
* Retrieves cached data for a given |tab| or associated |browser|.
*
* @param browserOrTab (xul:tab or xul:browser)
* The tab or browser to retrieve cached data for.
* @return (object)
* The cached data stored for the given |tab|
* or associated |browser|.
*/
- get: function (browserOrTab) {
+ get(browserOrTab) {
return this._data.get(browserOrTab.permanentKey);
},
/**
* Helper function used by update (see below). For message size
* optimization sometimes we don't update the whole session storage
* only the values that have been changed.
*
* @param data (object)
* The cached data where we want to update the changes.
* @param change (object)
* The actual changed values per domain.
*/
- updatePartialStorageChange: function (data, change) {
+ updatePartialStorageChange(data, change) {
if (!data.storage) {
data.storage = {};
}
let storage = data.storage;
for (let domain of Object.keys(change)) {
for (let key of Object.keys(change[domain])) {
let value = change[domain][key];
@@ -100,17 +100,17 @@ var TabStateCacheInternal = {
* index (specified by change.fromIdx)
*
* @param data (object)
* The cached data where we want to update the changes.
* @param change (object)
* Object containing the tail of the history array, and
* some additional metadata.
*/
- updatePartialHistoryChange: function (data, change) {
+ updatePartialHistoryChange(data, change) {
const kLastIndex = Number.MAX_SAFE_INTEGER - 1;
if (!data.history) {
data.history = { entries: [] };
}
let history = data.history;
let toIdx = history.entries.length;
@@ -135,17 +135,17 @@ var TabStateCacheInternal = {
* Updates cached data for a given |tab| or associated |browser|.
*
* @param browserOrTab (xul:tab or xul:browser)
* The tab or browser belonging to the given tab data.
* @param newData (object)
* The new data to be stored for the given |tab|
* or associated |browser|.
*/
- update: function (browserOrTab, newData) {
+ update(browserOrTab, newData) {
let data = this._data.get(browserOrTab.permanentKey) || {};
for (let key of Object.keys(newData)) {
if (key == "storagechange") {
this.updatePartialStorageChange(data, newData.storagechange);
continue;
}
--- a/browser/components/sessionstore/TabStateFlusher.jsm
+++ b/browser/components/sessionstore/TabStateFlusher.jsm
@@ -43,17 +43,17 @@ this.TabStateFlusher = Object.freeze({
* @param flushID (int)
* The ID of the flush that was sent to the browser.
* @param success (bool, optional)
* Whether or not the flush succeeded.
* @param message (string, optional)
* An error message that will be sent to the Console in the
* event that a flush failed.
*/
- resolve(browser, flushID, success=true, message="") {
+ resolve(browser, flushID, success = true, message = "") {
TabStateFlusherInternal.resolve(browser, flushID, success, message);
},
/**
* Resolves all active flush requests for a given browser. This should be
* used when the content process crashed or the final update message was
* seen. In those cases we can't guarantee to ever hear back from the frame
* script so we just resolve all requests instead of discarding them.
@@ -61,17 +61,17 @@ this.TabStateFlusher = Object.freeze({
* @param browser (<xul:browser>)
* The browser for which all flushes are being resolved.
* @param success (bool, optional)
* Whether or not the flushes succeeded.
* @param message (string, optional)
* An error message that will be sent to the Console in the
* event that the flushes failed.
*/
- resolveAll(browser, success=true, message="") {
+ resolveAll(browser, success = true, message = "") {
TabStateFlusherInternal.resolveAll(browser, success, message);
}
});
var TabStateFlusherInternal = {
// Stores the last request ID.
_lastRequestID: 0,
@@ -119,17 +119,17 @@ var TabStateFlusherInternal = {
* @param flushID (int)
* The ID of the flush that was sent to the browser.
* @param success (bool, optional)
* Whether or not the flush succeeded.
* @param message (string, optional)
* An error message that will be sent to the Console in the
* event that a flush failed.
*/
- resolve(browser, flushID, success=true, message="") {
+ resolve(browser, flushID, success = true, message = "") {
// Nothing to do if there are no pending flushes for the given browser.
if (!this._requests.has(browser.permanentKey)) {
return;
}
// Retrieve active requests for given browser.
let perBrowserRequests = this._requests.get(browser.permanentKey);
if (!perBrowserRequests.has(flushID)) {
@@ -155,17 +155,17 @@ var TabStateFlusherInternal = {
* @param browser (<xul:browser>)
* The browser for which all flushes are being resolved.
* @param success (bool, optional)
* Whether or not the flushes succeeded.
* @param message (string, optional)
* An error message that will be sent to the Console in the
* event that the flushes failed.
*/
- resolveAll(browser, success=true, message="") {
+ resolveAll(browser, success = true, message = "") {
// Nothing to do if there are no pending flushes for the given browser.
if (!this._requests.has(browser.permanentKey)) {
return;
}
// Retrieve active requests for given browser.
let perBrowserRequests = this._requests.get(browser.permanentKey);
--- a/browser/components/sessionstore/content/aboutSessionRestore.js
+++ b/browser/components/sessionstore/content/aboutSessionRestore.js
@@ -189,25 +189,23 @@ function onListClick(aEvent) {
let accelKey = AppConstants.platform == "macosx" ?
aEvent.metaKey :
aEvent.ctrlKey;
if ((aEvent.button == 1 || aEvent.button == 0 && aEvent.detail == 2 || accelKey) &&
cell.col.id == "title" &&
!treeView.isContainer(cell.row)) {
restoreSingleTab(cell.row, aEvent.shiftKey);
aEvent.stopPropagation();
- }
- else if (cell.col.id == "restore")
+ } else if (cell.col.id == "restore")
toggleRowChecked(cell.row);
}
}
function onListKeyDown(aEvent) {
- switch (aEvent.keyCode)
- {
+ switch (aEvent.keyCode) {
case KeyEvent.DOM_VK_SPACE:
toggleRowChecked(document.getElementById("tabList").currentIndex);
// Prevent page from scrolling on the space key.
aEvent.preventDefault();
break;
case KeyEvent.DOM_VK_RETURN:
var ix = document.getElementById("tabList").currentIndex;
if (aEvent.ctrlKey && !treeView.isContainer(ix))
@@ -234,18 +232,17 @@ function toggleRowChecked(aIx) {
treeView.treeBox.invalidateRow(aIx);
if (treeView.isContainer(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 {
+ } else {
// Update the window's checkmark as well (0 means "partially checked").
let state = false;
if (item.parent.tabs.every(isChecked)) {
state = true;
} else if (item.parent.tabs.some(isChecked)) {
state = 0;
}
item.parent.checked = state;
@@ -278,91 +275,90 @@ function restoreSingleTab(aIx, aShifted)
}
// Tree controller
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; },
- 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; },
+ get rowCount() { return gTreeData.length; },
+ setTree(treeBox) { this.treeBox = treeBox; },
+ getCellText(idx, column) { return gTreeData[idx].label; },
+ isContainer(idx) { return "open" in gTreeData[idx]; },
+ getCellValue(idx, column) { return gTreeData[idx].checked; },
+ isContainerOpen(idx) { return gTreeData[idx].open; },
+ isContainerEmpty(idx) { return false; },
+ isSeparator(idx) { return false; },
+ isSorted() { return false; },
+ isEditable(idx, column) { return false; },
+ canDrop(idx, orientation, dt) { return false; },
+ getLevel(idx) { return this.isContainer(idx) ? 0 : 1; },
- getParentIndex: function(idx) {
+ getParentIndex(idx) {
if (!this.isContainer(idx))
for (var t = idx - 1; t >= 0 ; t--)
if (this.isContainer(t))
return t;
return -1;
},
- hasNextSibling: function(idx, after) {
+ hasNextSibling(idx, after) {
var thisLevel = this.getLevel(idx);
for (var t = after + 1; t < gTreeData.length; t++)
if (this.getLevel(t) <= thisLevel)
return this.getLevel(t) == thisLevel;
return false;
},
- toggleOpenState: function(idx) {
+ toggleOpenState(idx) {
if (!this.isContainer(idx))
return;
var item = gTreeData[idx];
if (item.open) {
// remove this window's tab rows from the view
var thisLevel = this.getLevel(idx);
for (var t = idx + 1; t < gTreeData.length && this.getLevel(t) > thisLevel; t++);
var deletecount = t - idx - 1;
gTreeData.splice(idx + 1, deletecount);
this.treeBox.rowCountChanged(idx + 1, -deletecount);
- }
- else {
+ } else {
// add this window's tab rows to the view
var toinsert = gTreeData[idx].tabs;
for (var i = 0; i < toinsert.length; i++)
gTreeData.splice(idx + i + 1, 0, toinsert[i]);
this.treeBox.rowCountChanged(idx + 1, toinsert.length);
}
item.open = !item.open;
this.treeBox.invalidateRow(idx);
},
- getCellProperties: function(idx, column) {
+ getCellProperties(idx, column) {
if (column.id == "restore" && this.isContainer(idx) && gTreeData[idx].checked === 0)
return "partial";
if (column.id == "title")
return this.getImageSrc(idx, column) ? "icon" : "noicon";
return "";
},
- getRowProperties: function(idx) {
+ getRowProperties(idx) {
var winState = gTreeData[idx].parent || gTreeData[idx];
if (winState.ix % 2 != 0)
return "alternate";
return "";
},
- getImageSrc: function(idx, column) {
+ getImageSrc(idx, column) {
if (column.id == "title")
return gTreeData[idx].src || null;
return null;
},
- getProgressMode : function(idx, column) { },
- cycleHeader: function(column) { },
- cycleCell: function(idx, column) { },
- selectionChanged: function() { },
- performAction: function(action) { },
- performActionOnCell: function(action, index, column) { },
- getColumnProperties: function(column) { return ""; }
+ getProgressMode(idx, column) { },
+ cycleHeader(column) { },
+ cycleCell(idx, column) { },
+ selectionChanged() { },
+ performAction(action) { },
+ performActionOnCell(action, index, column) { },
+ getColumnProperties(column) { return ""; }
};
--- a/browser/components/sessionstore/content/content-sessionStore.js
+++ b/browser/components/sessionstore/content/content-sessionStore.js
@@ -31,17 +31,17 @@ XPCOMUtils.defineLazyModuleGetter(this,
"resource://gre/modules/sessionstore/SessionHistory.jsm");
XPCOMUtils.defineLazyModuleGetter(this, "SessionStorage",
"resource:///modules/sessionstore/SessionStorage.jsm");
Cu.import("resource:///modules/sessionstore/FrameTree.jsm", this);
var gFrameTree = new FrameTree(this);
Cu.import("resource:///modules/sessionstore/ContentRestore.jsm", this);
-XPCOMUtils.defineLazyGetter(this, 'gContentRestore',
+XPCOMUtils.defineLazyGetter(this, "gContentRestore",
() => { return new ContentRestore(this) });
// The current epoch.
var gCurrentEpoch = 0;
// A bound to the size of data to store for DOM Storage.
const DOM_STORAGE_MAX_CHARS = 10000000; // 10M characters
@@ -71,21 +71,21 @@ function createLazy(fn) {
}
/**
* Listens for and handles content events that we need for the
* session store service to be notified of state changes in content.
*/
var EventListener = {
- init: function () {
+ init() {
addEventListener("load", this, true);
},
- handleEvent: function (event) {
+ handleEvent(event) {
// Ignore load events from subframes.
if (event.target != content.document) {
return;
}
if (content.document.documentURI.startsWith("about:reader")) {
if (event.type == "load" &&
!content.document.body.classList.contains("loaded")) {
@@ -112,21 +112,21 @@ var MessageListener = {
MESSAGES: [
"SessionStore:restoreHistory",
"SessionStore:restoreTabContent",
"SessionStore:resetRestore",
"SessionStore:flush",
"SessionStore:becomeActiveProcess",
],
- init: function () {
+ init() {
this.MESSAGES.forEach(m => addMessageListener(m, this));
},
- receiveMessage: function ({name, data}) {
+ receiveMessage({name, data}) {
// The docShell might be gone. Don't process messages,
// that will just lead to errors anyway.
if (!docShell) {
return;
}
// A fresh tab always starts with epoch=0. The parent has the ability to
// override that to signal a new era in this tab's life. This enables it
@@ -225,17 +225,17 @@ var MessageListener = {
*
* Causes a SessionStore:update message to be sent that contains the current
* session history.
*
* Example:
* {entries: [{url: "about:mozilla", ...}, ...], index: 1}
*/
var SessionHistoryListener = {
- init: function () {
+ init() {
// The frame tree observer is needed to handle initial subframe loads.
// It will redundantly invalidate with the SHistoryListener in some cases
// but these invalidations are very cheap.
gFrameTree.addObserver(this);
// By adding the SHistoryListener immediately, we will unfortunately be
// notified of every history entry as the tab is restored. We don't bother
// waiting to add the listener later because these notifications are cheap.
@@ -255,24 +255,24 @@ var SessionHistoryListener = {
// will be all confused by that message.
MessageQueue.send();
}
// Listen for page title changes.
addEventListener("DOMTitleChanged", this);
},
- uninit: function () {
+ uninit() {
let sessionHistory = docShell.QueryInterface(Ci.nsIWebNavigation).sessionHistory;
if (sessionHistory) {
sessionHistory.removeSHistoryListener(this);
}
},
- collect: function () {
+ collect() {
// We want to send down a historychange even for full collects in case our
// session history is a partial session history, in which case we don't have
// enough information for a full update. collectFrom(-1) tells the collect
// function to collect all data avaliable in this process.
if (docShell) {
this.collectFrom(-1);
}
},
@@ -281,17 +281,17 @@ var SessionHistoryListener = {
// History can grow relatively big with the nested elements, so if we don't have to, we
// don't want to send the entire history all the time. For a simple optimization
// we keep track of the smallest index from after any change has occured and we just send
// the elements from that index. If something more complicated happens we just clear it
// and send the entire history. We always send the additional info like the current selected
// index (so for going back and forth between history entries we set the index to kLastIndex
// if nothing else changed send an empty array and the additonal info like the selected index)
- collectFrom: function (idx) {
+ collectFrom(idx) {
if (this._fromIdx <= idx) {
// If we already know that we need to update history fromn index N we can ignore any changes
// tha happened with an element with index larger than N.
// Note: initially we use kNoIndex which is MAX_SAFE_INTEGER which means we don't ignore anything
// here, and in case of navigation in the history back and forth we use kLastIndex which ignores
// only the subsequent navigations, but not any new elements added.
return;
}
@@ -307,54 +307,54 @@ var SessionHistoryListener = {
return history;
});
},
handleEvent(event) {
this.collect();
},
- onFrameTreeCollected: function () {
+ onFrameTreeCollected() {
this.collect();
},
- onFrameTreeReset: function () {
+ onFrameTreeReset() {
this.collect();
},
- OnHistoryNewEntry: function (newURI, oldIndex) {
+ OnHistoryNewEntry(newURI, oldIndex) {
this.collectFrom(oldIndex);
},
- OnHistoryGoBack: function (backURI) {
+ OnHistoryGoBack(backURI) {
this.collectFrom(kLastIndex);
return true;
},
- OnHistoryGoForward: function (forwardURI) {
+ OnHistoryGoForward(forwardURI) {
this.collectFrom(kLastIndex);
return true;
},
- OnHistoryGotoIndex: function (index, gotoURI) {
+ OnHistoryGotoIndex(index, gotoURI) {
this.collectFrom(kLastIndex);
return true;
},
- OnHistoryPurge: function (numEntries) {
+ OnHistoryPurge(numEntries) {
this.collect();
return true;
},
- OnHistoryReload: function (reloadURI, reloadFlags) {
+ OnHistoryReload(reloadURI, reloadFlags) {
this.collect();
return true;
},
- OnHistoryReplaceEntry: function (index) {
+ OnHistoryReplaceEntry(index) {
this.collect();
},
QueryInterface: XPCOMUtils.generateQI([
Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference
])
};
@@ -367,40 +367,40 @@ var SessionHistoryListener = {
* scroll positions as a tree of strings. If no frame of the whole frame tree
* is scrolled this will return null so that we don't tack a property onto
* the tabData object in the parent process.
*
* Example:
* {scroll: "100,100", children: [null, null, {scroll: "200,200"}]}
*/
var ScrollPositionListener = {
- init: function () {
+ init() {
addEventListener("scroll", this);
gFrameTree.addObserver(this);
},
- handleEvent: function (event) {
+ handleEvent(event) {
let frame = event.target.defaultView;
// Don't collect scroll data for frames created at or after the load event
// as SessionStore can't restore scroll data for those.
if (gFrameTree.contains(frame)) {
MessageQueue.push("scroll", () => this.collect());
}
},
- onFrameTreeCollected: function () {
+ onFrameTreeCollected() {
MessageQueue.push("scroll", () => this.collect());
},
- onFrameTreeReset: function () {
+ onFrameTreeReset() {
MessageQueue.push("scroll", () => null);
},
- collect: function () {
+ collect() {
return gFrameTree.map(ScrollPosition.collect);
}
};
/**
* Listens for changes to input elements. Whenever the value of an input
* element changes we will re-collect data for the current frame tree and send
* a message to the parent process.
@@ -413,81 +413,81 @@ var ScrollPositionListener = {
* formdata: {url: "http://mozilla.org/", id: {input_id: "input value"}},
* children: [
* null,
* {url: "http://sub.mozilla.org/", id: {input_id: "input value 2"}}
* ]
* }
*/
var FormDataListener = {
- init: function () {
+ init() {
addEventListener("input", this, true);
addEventListener("change", this, true);
gFrameTree.addObserver(this);
},
- handleEvent: function (event) {
+ handleEvent(event) {
let frame = event.target.ownerGlobal;
// Don't collect form data for frames created at or after the load event
// as SessionStore can't restore form data for those.
if (gFrameTree.contains(frame)) {
MessageQueue.push("formdata", () => this.collect());
}
},
- onFrameTreeReset: function () {
+ onFrameTreeReset() {
MessageQueue.push("formdata", () => null);
},
- collect: function () {
+ collect() {
return gFrameTree.map(FormData.collect);
}
};
/**
* Listens for changes to the page style. Whenever a different page style is
* selected or author styles are enabled/disabled we send a message with the
* currently applied style to the chrome process.
*
* Causes a SessionStore:update message to be sent that contains the currently
* selected pageStyle for all reachable frames.
*
* Example:
* {pageStyle: "Dusk", children: [null, {pageStyle: "Mozilla"}]}
*/
var PageStyleListener = {
- init: function () {
+ init() {
Services.obs.addObserver(this, "author-style-disabled-changed", false);
Services.obs.addObserver(this, "style-sheet-applicable-state-changed", false);
gFrameTree.addObserver(this);
},
- uninit: function () {
+ uninit() {
Services.obs.removeObserver(this, "author-style-disabled-changed");
Services.obs.removeObserver(this, "style-sheet-applicable-state-changed");
},
- observe: function (subject, topic) {
+ observe(subject, topic) {
let frame = subject.defaultView;
if (frame && gFrameTree.contains(frame)) {
MessageQueue.push("pageStyle", () => this.collect());
}
},
- collect: function () {
+ collect() {
return PageStyle.collect(docShell, gFrameTree);
},
- onFrameTreeCollected: function () {
+ onFrameTreeCollected() {
MessageQueue.push("pageStyle", () => this.collect());
},
- onFrameTreeReset: function () {
+ onFrameTreeReset() {
MessageQueue.push("pageStyle", () => null);
}
};
/**
* Listens for changes to docShell capabilities. Whenever a new load is started
* we need to re-check the list of capabilities and send message when it has
* changed.
@@ -498,24 +498,24 @@ var PageStyleListener = {
*/
var DocShellCapabilitiesListener = {
/**
* This field is used to compare the last docShell capabilities to the ones
* that have just been collected. If nothing changed we won't send a message.
*/
_latestCapabilities: "",
- init: function () {
+ init() {
gFrameTree.addObserver(this);
},
/**
* onFrameTreeReset() is called as soon as we start loading a page.
*/
- onFrameTreeReset: function() {
+ onFrameTreeReset() {
// The order of docShell capabilities cannot change while we're running
// so calling join() without sorting before is totally sufficient.
let caps = DocShellCapabilities.collect(docShell).join(",");
// Send new data only when the capability list changes.
if (caps != this._latestCapabilities) {
this._latestCapabilities = caps;
MessageQueue.push("disallow", () => caps || null);
@@ -528,33 +528,33 @@ var DocShellCapabilitiesListener = {
* existing ones removed or changed, or the storage is cleared we will send a
* message to the parent process containing up-to-date sessionStorage data.
*
* Causes a SessionStore:update message to be sent that contains the current
* DOMSessionStorage contents. The data is a nested object using host names
* as keys and per-host DOMSessionStorage data as values.
*/
var SessionStorageListener = {
- init: function () {
+ init() {
addEventListener("MozSessionStorageChanged", this, true);
Services.obs.addObserver(this, "browser:purge-domain-data", false);
gFrameTree.addObserver(this);
},
- uninit: function () {
+ uninit() {
Services.obs.removeObserver(this, "browser:purge-domain-data");
},
- handleEvent: function (event) {
+ handleEvent(event) {
if (gFrameTree.contains(event.target)) {
this.collectFromEvent(event);
}
},
- observe: function () {
+ observe() {
// Collect data on the next tick so that any other observer
// that needs to purge data can do its work first.
setTimeout(() => this.collect(), 0);
},
// Before DOM Storage can be written to disk, it needs to be serialized
// for sending across frames/processes, then again to be sent across
// threads, then again to be put in a buffer for the disk. Each of these
@@ -562,17 +562,17 @@ var SessionStorageListener = {
// the OOM), either crash, lose all data for the frame or lose all data
// for the application.
//
// In order to avoid this, compute an estimate of the size of the
// object, and block SessionStorage items that are too large. As
// we also don't want to cause an OOM here, we use a quick and memory-
// efficient approximation: we compute the total sum of string lengths
// involved in this object.
- estimateStorageSize: function(collected) {
+ estimateStorageSize(collected) {
if (!collected) {
return 0;
}
let size = 0;
for (let host of Object.keys(collected)) {
size += host.length;
let perHost = collected[host];
@@ -588,21 +588,21 @@ var SessionStorageListener = {
// We don't want to send all the session storage data for all the frames
// for every change. So if only a few value changed we send them over as
// a "storagechange" event. If however for some reason before we send these
// changes we have to send over the entire sessions storage data, we just
// reset these changes.
_changes: undefined,
- resetChanges: function () {
+ resetChanges() {
this._changes = undefined;
},
- collectFromEvent: function (event) {
+ collectFromEvent(event) {
// TODO: we should take browser.sessionstore.dom_storage_limit into an account here.
if (docShell) {
let {url, key, newValue} = event;
let uri = Services.io.newURI(url);
let domain = uri.prePath;
if (!this._changes) {
this._changes = {};
}
@@ -617,17 +617,17 @@ var SessionStorageListener = {
// First one will collect all the changes the rest of
// these messages will be ignored.
this.resetChanges();
return tmp;
});
}
},
- collect: function () {
+ collect() {
if (docShell) {
// We need the entire session storage, let's reset the pending individual change
// messages.
this.resetChanges();
MessageQueue.push("storage", () => {
let collected = SessionStorage.collect(docShell, gFrameTree);
if (collected == null) {
@@ -644,48 +644,48 @@ var SessionStorageListener = {
return {};
}
return collected;
});
}
},
- onFrameTreeCollected: function () {
+ onFrameTreeCollected() {
this.collect();
},
- onFrameTreeReset: function () {
+ onFrameTreeReset() {
this.collect();
}
};
/**
* Listen for changes to the privacy status of the tab.
* By definition, tabs start in non-private mode.
*
* Causes a SessionStore:update message to be sent for
* field "isPrivate". This message contains
* |true| if the tab is now private
* |null| if the tab is now public - the field is therefore
* not saved.
*/
var PrivacyListener = {
- init: function() {
+ init() {
docShell.addWeakPrivacyTransitionObserver(this);
// Check that value at startup as it might have
// been set before the frame script was loaded.
if (docShell.QueryInterface(Ci.nsILoadContext).usePrivateBrowsing) {
MessageQueue.push("isPrivate", () => true);
}
},
// Ci.nsIPrivacyTransitionObserver
- privateModeChanged: function(enabled) {
+ privateModeChanged(enabled) {
MessageQueue.push("isPrivate", () => enabled || null);
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIPrivacyTransitionObserver,
Ci.nsISupportsWeakReference])
};
/**
@@ -769,33 +769,33 @@ var MessageQueue = {
* but has not been sent to the parent process, yet.
*
* @param key (string)
* A unique identifier specific to the type of data this is passed.
* @param fn (function)
* A function that returns the value that will be sent to the parent
* process.
*/
- push: function (key, fn) {
+ push(key, fn) {
this._data.set(key, createLazy(fn));
if (!this._timeout && !this._timeoutDisabled) {
// Wait a little before sending the message to batch multiple changes.
this._timeout = setTimeout(() => this.send(), this.BATCH_DELAY_MS);
}
},
/**
* Sends queued data to the chrome process.
*
* @param options (object)
* {flushID: 123} to specify that this is a flush
* {isFinal: true} to signal this is the final message sent on unload
*/
- send: function (options = {}) {
+ send(options = {}) {
// Looks like we have been called off a timeout after the tab has been
// closed. The docShell is gone now and we can just return here as there
// is nothing to do.
if (!docShell) {
return;
}
if (this._timeout) {
--- a/browser/components/sessionstore/nsSessionStartup.js
+++ b/browser/components/sessionstore/nsSessionStartup.js
@@ -60,17 +60,17 @@ function debug(aMsg) {
Services.console.logStringMessage(aMsg);
}
function warning(aMsg, aException) {
let consoleMsg = Cc["@mozilla.org/scripterror;1"].createInstance(Ci.nsIScriptError);
consoleMsg.init(aMsg, aException.fileName, null, aException.lineNumber, 0, Ci.nsIScriptError.warningFlag, "component javascript");
Services.console.logMessage(consoleMsg);
}
-var gOnceInitializedDeferred = (function () {
+var gOnceInitializedDeferred = (function() {
let deferred = {};
deferred.promise = new Promise((resolve, reject) => {
deferred.resolve = resolve;
deferred.reject = reject;
});
return deferred;
@@ -122,17 +122,17 @@ SessionStartup.prototype = {
},
/**
* Complete initialization once the Session File has been read
*
* @param source The Session State string read from disk.
* @param parsed The object obtained by parsing |source| as JSON.
*/
- _onSessionFileRead: function ({source, parsed, noFilesFound}) {
+ _onSessionFileRead({source, parsed, noFilesFound}) {
this._initialized = true;
// Let observers modify the state before it is used
let supportsStateString = this._createSupportsString(source);
Services.obs.notifyObservers(supportsStateString, "sessionstore-state-read", "");
let stateString = supportsStateString.data;
if (stateString != source) {
@@ -283,26 +283,26 @@ SessionStartup.prototype = {
/**
* Determines whether automatic session restoration is enabled for this
* launch of the browser. This does not include crash restoration. In
* particular, if session restore is configured to restore only in case of
* crash, this method returns false.
* @returns bool
*/
- isAutomaticRestoreEnabled: function () {
+ isAutomaticRestoreEnabled() {
return Services.prefs.getBoolPref("browser.sessionstore.resume_session_once") ||
Services.prefs.getIntPref("browser.startup.page") == BROWSER_STARTUP_RESUME_SESSION;
},
/**
* Determines whether there is a pending session restore.
* @returns bool
*/
- _willRestore: function () {
+ _willRestore() {
return this._sessionType == Ci.nsISessionStartup.RECOVER_SESSION ||
this._sessionType == Ci.nsISessionStartup.RESUME_SESSION;
},
/**
* Returns whether we will restore a session that ends up replacing the
* homepage. The browser uses this to not start loading the homepage if
* we're going to stop its load anyway shortly after.
--- a/browser/components/sessionstore/nsSessionStore.js
+++ b/browser/components/sessionstore/nsSessionStore.js
@@ -21,17 +21,17 @@ const Ci = Components.interfaces;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
Cu.import("resource:///modules/sessionstore/SessionStore.jsm");
function SessionStoreService() {}
// The SessionStore module's object is frozen. We need to modify our prototype
// and add some properties so let's just copy the SessionStore object.
-Object.keys(SessionStore).forEach(function (aName) {
+Object.keys(SessionStore).forEach(function(aName) {
let desc = Object.getOwnPropertyDescriptor(SessionStore, aName);
Object.defineProperty(SessionStoreService.prototype, aName, desc);
});
SessionStoreService.prototype.classID =
Components.ID("{5280606b-2510-4fe0-97ef-9b5a22eafe6b}");
SessionStoreService.prototype.QueryInterface =
XPCOMUtils.generateQI([Ci.nsISessionStore]);
--- a/browser/components/sessionstore/test/browser_1234021.js
+++ b/browser/components/sessionstore/test/browser_1234021.js
@@ -1,18 +1,18 @@
"use strict";
-const PREF = 'network.cookie.cookieBehavior';
-const PAGE_URL = 'http://mochi.test:8888/browser/' +
- 'browser/components/sessionstore/test/browser_1234021_page.html';
+const PREF = "network.cookie.cookieBehavior";
+const PAGE_URL = "http://mochi.test:8888/browser/" +
+ "browser/components/sessionstore/test/browser_1234021_page.html";
const BEHAVIOR_REJECT = 2;
add_task(function* test() {
yield pushPrefs([PREF, BEHAVIOR_REJECT]);
yield BrowserTestUtils.withNewTab({
- gBrowser: gBrowser,
+ gBrowser,
url: PAGE_URL
}, function* handler(aBrowser) {
yield TabStateFlusher.flush(aBrowser);
ok(true, "Flush didn't time out");
});
});
--- a/browser/components/sessionstore/test/browser_345898.js
+++ b/browser/components/sessionstore/test/browser_345898.js
@@ -4,18 +4,17 @@
function test() {
/** Test for Bug 345898 **/
function test(aLambda) {
try {
aLambda();
return false;
- }
- catch (ex) {
+ } 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");
--- a/browser/components/sessionstore/test/browser_350525.js
+++ b/browser/components/sessionstore/test/browser_350525.js
@@ -7,18 +7,17 @@ add_task(function* setup() {
})
add_task(function* () {
/** Test for Bug 350525 **/
function test(aLambda) {
try {
return aLambda() || true;
- }
- catch (ex) { }
+ } catch (ex) { }
return false;
}
////////////////////////////
// setWindowValue, et al. //
////////////////////////////
let key = "Unique name: " + Date.now();
let value = "Unique value: " + Math.random();
--- a/browser/components/sessionstore/test/browser_354894_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_354894_perwindowpb.js
@@ -149,17 +149,17 @@ let setupTest = Task.async(function*(opt
/**
* Loads a TEST_URLS into a browser window.
*
* @param win (Window)
* The browser window to load the tabs in
*/
function injectTestTabs(win) {
- TEST_URLS.forEach(function (url) {
+ TEST_URLS.forEach(function(url) {
win.gBrowser.addTab(url);
});
}
/**
* Attempts to close a window via BrowserTryToCloseWindow so that
* we get the browser-lastwindow-close-requested and
* browser-lastwindow-close-granted observer notifications.
--- a/browser/components/sessionstore/test/browser_394759_purge.js
+++ b/browser/components/sessionstore/test/browser_394759_purge.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/ForgetAboutSite.jsm");
function waitForClearHistory(aCallback) {
let observer = {
- observe: function(aSubject, aTopic, aData) {
+ observe(aSubject, aTopic, aData) {
Services.obs.removeObserver(this, "browser:purge-domain-data");
setTimeout(aCallback, 0);
}
};
Services.obs.addObserver(observer, "browser:purge-domain-data", false);
}
function test() {
--- a/browser/components/sessionstore/test/browser_447951.js
+++ b/browser/components/sessionstore/test/browser_447951.js
@@ -7,17 +7,17 @@ function test() {
waitForExplicitFinish();
const baseURL = "http://mochi.test:8888/browser/" +
"browser/components/sessionstore/test/browser_447951_sample.html#";
// Make sure the functionality added in bug 943339 doesn't affect the results
gPrefService.setIntPref("browser.sessionstore.max_serialize_back", -1);
gPrefService.setIntPref("browser.sessionstore.max_serialize_forward", -1);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
gPrefService.clearUserPref("browser.sessionstore.max_serialize_back");
gPrefService.clearUserPref("browser.sessionstore.max_serialize_forward");
});
let tab = gBrowser.addTab();
promiseBrowserLoaded(tab.linkedBrowser).then(() => {
let tabState = { entries: [] };
let max_entries = gPrefService.getIntPref("browser.sessionhistory.max_entries");
--- a/browser/components/sessionstore/test/browser_456342.js
+++ b/browser/components/sessionstore/test/browser_456342.js
@@ -36,14 +36,14 @@ add_task(function* test_restore_nonstand
if (savedFormData.xpath[exp] == expectedValue) {
countGood++;
} else {
countBad++;
}
}
is(countGood, 4, "Saved text for non-standard input fields");
- is(countBad, 0, "Didn't save text for ignored field types");
+ is(countBad, 0, "Didn't save text for ignored field types");
});
function setFormElementValues(browser, data) {
return sendMessage(browser, "ss-test:setFormElementValues", data);
}
--- a/browser/components/sessionstore/test/browser_459906.js
+++ b/browser/components/sessionstore/test/browser_459906.js
@@ -42,18 +42,17 @@ function test() {
}
is(iframes[1].document.body.innerHTML, uniqueValue,
"rich textarea's content correctly duplicated");
let innerDomain = null;
try {
innerDomain = iframes[0].document.domain;
- }
- catch (ex) { /* throws for chrome: documents */ }
+ } catch (ex) { /* throws for chrome: documents */ }
is(innerDomain, "mochi.test", "XSS exploit prevented!");
// clean up
gBrowser.removeTab(tab2);
gBrowser.removeTab(tab);
finish();
});
--- a/browser/components/sessionstore/test/browser_461634.js
+++ b/browser/components/sessionstore/test/browser_461634.js
@@ -21,18 +21,17 @@ function test() {
function countByTitle(aClosedTabList, aTitle) {
return aClosedTabList.filter(aData => aData.title == aTitle).length;
}
function testForError(aFunction) {
try {
aFunction();
return false;
- }
- catch (ex) {
+ } catch (ex) {
return ex.name == "NS_ERROR_ILLEGAL_VALUE";
}
}
// Open a window and add the above closed tab list.
let newWin = openDialog(location, "", "chrome,all,dialog=no");
promiseWindowLoaded(newWin).then(() => {
gPrefService.setIntPref("browser.sessionstore.max_tabs_undo",
--- a/browser/components/sessionstore/test/browser_463205.js
+++ b/browser/components/sessionstore/test/browser_463205.js
@@ -30,11 +30,11 @@ add_task(function* test_check_urls_befor
// Cleanup.
gBrowser.removeTab(tab);
});
function getState(url) {
return JSON.stringify({
entries: [{url: URL, triggeringPrincipal_base64}],
- formdata: {url: url, id: {text: "foobar"}}
+ formdata: {url, id: {text: "foobar"}}
});
}
--- a/browser/components/sessionstore/test/browser_464199.js
+++ b/browser/components/sessionstore/test/browser_464199.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Components.utils.import("resource://gre/modules/ForgetAboutSite.jsm");
function waitForClearHistory(aCallback) {
let observer = {
- observe: function(aSubject, aTopic, aData) {
+ observe(aSubject, aTopic, aData) {
Services.obs.removeObserver(this, "browser:purge-domain-data");
setTimeout(aCallback, 0);
}
};
Services.obs.addObserver(observer, "browser:purge-domain-data", false);
}
function test() {
--- a/browser/components/sessionstore/test/browser_467409-backslashplosion.js
+++ b/browser/components/sessionstore/test/browser_467409-backslashplosion.js
@@ -21,17 +21,17 @@
const CRASH_STATE = {windows: [{tabs: [{entries: [{url: "about:mozilla", triggeringPrincipal_base64 }]}]}]};
const STATE = createEntries(CRASH_STATE);
const STATE2 = createEntries({windows: [{tabs: [STATE]}]});
const STATE3 = createEntries(JSON.stringify(CRASH_STATE));
function createEntries(sessionData) {
return {
entries: [{url: "about:sessionrestore", triggeringPrincipal_base64}],
- formdata: {id: {sessionData: sessionData}, url: "about:sessionrestore"}
+ formdata: {id: {sessionData}, url: "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);
--- a/browser/components/sessionstore/test/browser_491168.js
+++ b/browser/components/sessionstore/test/browser_491168.js
@@ -17,17 +17,17 @@ add_task(function* () {
// Load a new URI with a specific referrer.
let referrerURI = Services.io.newURI(REFERRER1);
browser.loadURI("http://example.org", referrerURI, null);
yield promiseBrowserLoaded(browser);
yield TabStateFlusher.flush(browser);
let tabState = JSON.parse(ss.getTabState(tab));
- is(tabState.entries[0].referrer, REFERRER1,
+ is(tabState.entries[0].referrer, REFERRER1,
"Referrer retrieved via getTabState matches referrer set via loadURI.");
tabState.entries[0].referrer = REFERRER2;
yield promiseTabState(tab, tabState);
yield checkDocumentReferrer(REFERRER2,
"document.referrer matches referrer set via setTabState.");
gBrowser.removeCurrentTab();
--- a/browser/components/sessionstore/test/browser_491577.js
+++ b/browser/components/sessionstore/test/browser_491577.js
@@ -68,18 +68,17 @@ function test() {
function countByTitle(aClosedWindowList, aTitle) {
return aClosedWindowList.filter(aData => aData.title == aTitle).length;
}
function testForError(aFunction) {
try {
aFunction();
return false;
- }
- catch (ex) {
+ } catch (ex) {
return ex.name == "NS_ERROR_ILLEGAL_VALUE";
}
}
// open a window and add the above closed window list
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
promiseWindowLoaded(newWin).then(() => {
gPrefService.setIntPref("browser.sessionstore.max_windows_undo",
--- a/browser/components/sessionstore/test/browser_500328.js
+++ b/browser/components/sessionstore/test/browser_500328.js
@@ -7,39 +7,38 @@ function checkState(tab) {
// from the popState event are as we expect them to be.
//
// We also add a node to the document's body when after going back and make
// sure it's still there after we go forward -- this is to test that the two
// history entries correspond to the same document.
let popStateCount = 0;
- tab.linkedBrowser.addEventListener('popstate', function(aEvent) {
+ tab.linkedBrowser.addEventListener("popstate", function(aEvent) {
let contentWindow = tab.linkedBrowser.contentWindow;
if (popStateCount == 0) {
popStateCount++;
- is(tab.linkedBrowser.contentWindow.testState, 'foo',
- 'testState after going back');
+ is(tab.linkedBrowser.contentWindow.testState, "foo",
+ "testState after going back");
ok(aEvent.state, "Event should have a state property.");
is(JSON.stringify(tab.linkedBrowser.contentWindow.history.state), JSON.stringify({obj1:1}),
"first popstate object.");
// Add a node with id "new-elem" to the document.
let doc = contentWindow.document;
ok(!doc.getElementById("new-elem"),
"doc shouldn't contain new-elem before we add it.");
let elem = doc.createElement("div");
elem.id = "new-elem";
doc.body.appendChild(elem);
tab.linkedBrowser.goForward();
- }
- else if (popStateCount == 1) {
+ } else if (popStateCount == 1) {
popStateCount++;
// When content fires a PopStateEvent and we observe it from a chrome event
// listener (as we do here, and, thankfully, nowhere else in the tree), the
// state object will be a cross-compartment wrapper to an object that was
// deserialized in the content scope. And in this case, since RegExps are
// not currently Xrayable (see bug 1014991), trying to pull |obj3| (a RegExp)
// off of an Xrayed Object won't work. So we need to waive.
ContentTask.spawn(tab.linkedBrowser, aEvent.state, function(state) {
@@ -59,17 +58,17 @@ function checkState(tab) {
gBrowser.removeTab(tab);
finish();
});
}
});
// Set some state in the page's window. When we go back(), the page should
// be retrieved from bfcache, and this state should still be there.
- tab.linkedBrowser.contentWindow.testState = 'foo';
+ tab.linkedBrowser.contentWindow.testState = "foo";
// Now go back. This should trigger the popstate event handler above.
tab.linkedBrowser.goBack();
}
function test() {
// Tests session restore functionality of history.pushState and
// history.replaceState(). (Bug 500328)
--- a/browser/components/sessionstore/test/browser_514751.js
+++ b/browser/components/sessionstore/test/browser_514751.js
@@ -14,18 +14,18 @@ function test() {
{ url: "about:mozilla", triggeringPrincipal_base64, title: "Mozilla" },
{}
]
}]
}]
};
var theWin = openDialog(location, "", "chrome,all,dialog=no");
- theWin.addEventListener("load", function () {
- executeSoon(function () {
+ theWin.addEventListener("load", function() {
+ executeSoon(function() {
var gotError = false;
try {
ss.setWindowState(theWin, JSON.stringify(state), true);
} catch (e) {
if (/NS_ERROR_MALFORMED_URI/.test(e))
gotError = true;
}
ok(!gotError, "Didn't get a malformed URI error.");
--- a/browser/components/sessionstore/test/browser_522545.js
+++ b/browser/components/sessionstore/test/browser_522545.js
@@ -140,17 +140,17 @@ function test() {
for (let i = 0; i < 25; i++)
uris.push("http://example.com/" + i);
// We're waiting for the first location change, which should indicate
// one of the tabs has loaded and the others haven't. So one should
// be in a non-userTypedValue case, while others should still have
// userTypedValue and userTypedClear set.
gBrowser.addTabsProgressListener({
- onLocationChange: function (aBrowser) {
+ onLocationChange(aBrowser) {
if (uris.indexOf(aBrowser.currentURI.spec) > -1) {
gBrowser.removeTabsProgressListener(this);
firstLocationChange();
}
}
});
function firstLocationChange() {
@@ -191,17 +191,17 @@ function test() {
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), {});
- executeSoon(function () {
+ 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
let newState = JSON.parse(ss.getBrowserState());
is(newState.windows[0].tabs[0].userTypedValue, "example.org",
--- a/browser/components/sessionstore/test/browser_524745.js
+++ b/browser/components/sessionstore/test/browser_524745.js
@@ -5,17 +5,17 @@
function test() {
/** Test for Bug 524745 **/
let uniqKey = "bug524745";
let uniqVal = Date.now().toString();
waitForExplicitFinish();
- whenNewWindowLoaded({ private: false }, function (window_B) {
+ whenNewWindowLoaded({ private: false }, function(window_B) {
waitForFocus(function() {
// Add identifying information to window_B
ss.setWindowValue(window_B, uniqKey, uniqVal);
let state = JSON.parse(ss.getBrowserState());
let selectedWindow = state.windows[state.selectedWindow - 1];
is(selectedWindow.extData && selectedWindow.extData[uniqKey], uniqVal,
"selectedWindow is window_B");
--- a/browser/components/sessionstore/test/browser_526613.js
+++ b/browser/components/sessionstore/test/browser_526613.js
@@ -52,18 +52,17 @@ function test() {
ss.setBrowserState(oldState);
} else {
info("waiting for the current window to become active");
setTimeout(pollMostRecentWindow, 0);
window.focus(); //XXX Why is this needed?
}
}
pollMostRecentWindow();
- }
- else {
+ } else {
browserWindowsCount(1);
ok(!window.closed, "Restoring the old state should have left this window open");
Services.obs.removeObserver(observer, "sessionstore-browser-state-restored");
finish();
}
}
Services.obs.addObserver(observer, "sessionstore-browser-state-restored", false);
--- a/browser/components/sessionstore/test/browser_580512.js
+++ b/browser/components/sessionstore/test/browser_580512.js
@@ -50,31 +50,31 @@ function checkSecondWin(win) {
function openWinWithCb(cb, argURIs, expectedURIs) {
if (!expectedURIs)
expectedURIs = argURIs;
var win = openDialog(getBrowserURL(), "_blank",
"chrome,all,dialog=no", argURIs.join("|"));
- win.addEventListener("load", function () {
+ win.addEventListener("load", function() {
info("the window loaded");
var expectedLoads = expectedURIs.length;
win.gBrowser.addTabsProgressListener({
- onStateChange: function (aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
+ onStateChange(aBrowser, aWebProgress, aRequest, aStateFlags, aStatus) {
if (aRequest &&
aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
expectedURIs.indexOf(aRequest.QueryInterface(Ci.nsIChannel).originalURI.spec) > -1 &&
--expectedLoads <= 0) {
win.gBrowser.removeTabsProgressListener(this);
info("all tabs loaded");
is(win.gBrowser.tabs.length, expectedURIs.length, "didn't load any unexpected tabs");
- executeSoon(function () {
+ executeSoon(function() {
cb(win);
});
}
}
});
}, {once: true});
}
--- a/browser/components/sessionstore/test/browser_586068-apptabs.js
+++ b/browser/components/sessionstore/test/browser_586068-apptabs.js
@@ -3,33 +3,33 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
requestLongerTimeout(2);
const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
add_task(function* test() {
Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
});
let state = { windows: [{ tabs: [
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
{ entries: [{ url: "http://example.org/#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#5", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#6", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#7", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
], selected: 5 }] };
let loadCount = 0;
let promiseRestoringTabs = new Promise(resolve => {
- gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
+ gProgressListener.setCallback(function(aBrowser, aNeedRestore, aRestoring, aRestored) {
loadCount++;
// We'll make sure that the loads we get come from pinned tabs or the
// the selected tab.
// get the tab
let tab;
for (let i = 0; i < window.gBrowser.tabs.length; i++) {
--- a/browser/components/sessionstore/test/browser_586068-apptabs_ondemand.js
+++ b/browser/components/sessionstore/test/browser_586068-apptabs_ondemand.js
@@ -4,33 +4,33 @@
const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
const PREF_RESTORE_PINNED_TABS_ON_DEMAND = "browser.sessionstore.restore_pinned_tabs_on_demand";
add_task(function* test() {
Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true);
Services.prefs.setBoolPref(PREF_RESTORE_PINNED_TABS_ON_DEMAND, true);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
Services.prefs.clearUserPref(PREF_RESTORE_PINNED_TABS_ON_DEMAND);
});
let state = { windows: [{ tabs: [
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], extData: { "uniq": r() }, pinned: true },
{ entries: [{ url: "http://example.org/#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#5", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#6", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#7", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
], selected: 5 }] };
let promiseRestoringTabs = new Promise(resolve => {
- gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
+ gProgressListener.setCallback(function(aBrowser, aNeedRestore, aRestoring, aRestored) {
// get the tab
let tab;
for (let i = 0; i < window.gBrowser.tabs.length; i++) {
if (!tab && window.gBrowser.tabs[i].linkedBrowser == aBrowser)
tab = window.gBrowser.tabs[i];
}
// Check that the load only comes from the selected tab.
--- a/browser/components/sessionstore/test/browser_586068-browser_state_interrupted.js
+++ b/browser/components/sessionstore/test/browser_586068-browser_state_interrupted.js
@@ -3,17 +3,17 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
requestLongerTimeout(2);
add_task(function* test() {
Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
});
// The first state will be loaded using setBrowserState, followed by the 2nd
// state also being loaded using setBrowserState, interrupting the first restore.
let state1 = { windows: [
{
tabs: [
@@ -58,17 +58,17 @@ add_task(function* test() {
// interruptedAfter will be set after the selected tab from each window have loaded.
let interruptedAfter = 0;
let loadedWindow1 = false;
let loadedWindow2 = false;
let numTabs = state2.windows[0].tabs.length + state2.windows[1].tabs.length;
let loadCount = 0;
let promiseRestoringTabs = new Promise(resolve => {
- gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
+ gProgressListener.setCallback(function(aBrowser, aNeedRestore, aRestoring, aRestored) {
loadCount++;
if (aBrowser.currentURI.spec == state1.windows[0].tabs[2].entries[0].url)
loadedWindow1 = true;
if (aBrowser.currentURI.spec == state1.windows[1].tabs[0].entries[0].url)
loadedWindow2 = true;
if (!interruptedAfter && loadedWindow1 && loadedWindow2) {
--- a/browser/components/sessionstore/test/browser_586068-cascade.js
+++ b/browser/components/sessionstore/test/browser_586068-cascade.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
add_task(function* test() {
Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
});
let state = { windows: [{ tabs: [
{ entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.com", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
@@ -25,17 +25,17 @@ add_task(function* test() {
[1, 3, 2],
[0, 3, 3],
[0, 2, 4],
[0, 1, 5]
];
let loadCount = 0;
let promiseRestoringTabs = new Promise(resolve => {
- gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
+ gProgressListener.setCallback(function(aBrowser, aNeedRestore, aRestoring, aRestored) {
loadCount++;
let expected = expectedCounts[loadCount - 1];
is(aNeedRestore, expected[0], "load " + loadCount + " - # tabs that need to be restored");
is(aRestoring, expected[1], "load " + loadCount + " - # tabs that are restoring");
is(aRestored, expected[2], "load " + loadCount + " - # tabs that has been restored");
if (loadCount == state.windows[0].tabs.length) {
--- a/browser/components/sessionstore/test/browser_586068-multi_window.js
+++ b/browser/components/sessionstore/test/browser_586068-multi_window.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
add_task(function* test() {
Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
});
// The first window will be put into the already open window and the second
// window will be opened with _openWindowWithState, which is the source of the problem.
let state = { windows: [
{
tabs: [
@@ -30,17 +30,17 @@ add_task(function* test() {
],
selected: 4
}
] };
let numTabs = state.windows[0].tabs.length + state.windows[1].tabs.length;
let loadCount = 0;
let promiseRestoringTabs = new Promise(resolve => {
- gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
+ gProgressListener.setCallback(function(aBrowser, aNeedRestore, aRestoring, aRestored) {
if (++loadCount == numTabs) {
// We don't actually care about load order in this test, just that they all
// do load.
is(loadCount, numTabs, "all tabs were restored");
is(aNeedRestore, 0, "there are no tabs left needing restore");
gProgressListener.unsetCallback();
resolve();
--- a/browser/components/sessionstore/test/browser_586068-reload.js
+++ b/browser/components/sessionstore/test/browser_586068-reload.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
add_task(function* test() {
Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
});
let state = { windows: [{ tabs: [
{ entries: [{ url: "http://example.org/#1", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#2", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#3", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org/#4", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
--- a/browser/components/sessionstore/test/browser_586068-select.js
+++ b/browser/components/sessionstore/test/browser_586068-select.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
add_task(function* test() {
Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, true);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
});
let state = { windows: [{ tabs: [
{ entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
{ entries: [{ url: "http://example.org", triggeringPrincipal_base64 }], extData: { "uniq": r() } },
@@ -26,17 +26,17 @@ add_task(function* test() {
[2, 1, 3],
[1, 1, 4],
[0, 1, 5]
];
let tabOrder = [0, 5, 1, 4, 3, 2];
let loadCount = 0;
let promiseRestoringTabs = new Promise(resolve => {
- gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
+ gProgressListener.setCallback(function(aBrowser, aNeedRestore, aRestoring, aRestored) {
loadCount++;
let expected = expectedCounts[loadCount - 1];
is(aNeedRestore, expected[0], "load " + loadCount + " - # tabs that need to be restored");
is(aRestoring, expected[1], "load " + loadCount + " - # tabs that are restoring");
is(aRestored, expected[2], "load " + loadCount + " - # tabs that has been restored");
if (loadCount < state.windows[0].tabs.length) {
--- a/browser/components/sessionstore/test/browser_586068-window_state.js
+++ b/browser/components/sessionstore/test/browser_586068-window_state.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
add_task(function* test() {
Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
});
// We'll use 2 states so that we can make sure calling setWindowState doesn't
// wipe out currently restoring data.
let state1 = { windows: [{ tabs: [
{ entries: [{ url: "http://example.com#1", triggeringPrincipal_base64 }] },
{ entries: [{ url: "http://example.com#2", triggeringPrincipal_base64 }] },
@@ -25,17 +25,17 @@ add_task(function* test() {
{ entries: [{ url: "http://example.org#3", triggeringPrincipal_base64 }] },
{ entries: [{ url: "http://example.org#4", triggeringPrincipal_base64 }] },
{ entries: [{ url: "http://example.org#5", triggeringPrincipal_base64 }] }
] }] };
let numTabs = state1.windows[0].tabs.length + state2.windows[0].tabs.length;
let loadCount = 0;
let promiseRestoringTabs = new Promise(resolve => {
- gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
+ gProgressListener.setCallback(function(aBrowser, aNeedRestore, aRestoring, aRestored) {
// When loadCount == 2, we'll also restore state2 into the window
if (++loadCount == 2) {
ss.setWindowState(window, JSON.stringify(state2), false);
}
if (loadCount < numTabs) {
return;
}
--- a/browser/components/sessionstore/test/browser_586068-window_state_override.js
+++ b/browser/components/sessionstore/test/browser_586068-window_state_override.js
@@ -1,17 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const PREF_RESTORE_ON_DEMAND = "browser.sessionstore.restore_on_demand";
add_task(function* test() {
Services.prefs.setBoolPref(PREF_RESTORE_ON_DEMAND, false);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(PREF_RESTORE_ON_DEMAND);
});
// We'll use 2 states so that we can make sure calling setWindowState doesn't
// wipe out currently restoring data.
let state1 = { windows: [{ tabs: [
{ entries: [{ url: "http://example.com#1", triggeringPrincipal_base64 }] },
{ entries: [{ url: "http://example.com#2", triggeringPrincipal_base64 }] },
@@ -25,17 +25,17 @@ add_task(function* test() {
{ entries: [{ url: "http://example.org#3", triggeringPrincipal_base64 }] },
{ entries: [{ url: "http://example.org#4", triggeringPrincipal_base64 }] },
{ entries: [{ url: "http://example.org#5", triggeringPrincipal_base64 }] }
] }] };
let numTabs = 2 + state2.windows[0].tabs.length;
let loadCount = 0;
let promiseRestoringTabs = new Promise(resolve => {
- gProgressListener.setCallback(function (aBrowser, aNeedRestore, aRestoring, aRestored) {
+ gProgressListener.setCallback(function(aBrowser, aNeedRestore, aRestoring, aRestored) {
// When loadCount == 2, we'll also restore state2 into the window
if (++loadCount == 2) {
executeSoon(() => ss.setWindowState(window, JSON.stringify(state2), true));
}
if (loadCount < numTabs) {
return;
}
--- a/browser/components/sessionstore/test/browser_588426.js
+++ b/browser/components/sessionstore/test/browser_588426.js
@@ -4,17 +4,17 @@
function test() {
let state = { windows: [{ tabs: [
{entries: [{url: "about:mozilla", triggeringPrincipal_base64}], hidden: true},
{entries: [{url: "about:rights", triggeringPrincipal_base64}], hidden: true}
] }] };
waitForExplicitFinish();
- newWindowWithState(state, function (win) {
+ newWindowWithState(state, function(win) {
registerCleanupFunction(() => BrowserTestUtils.closeWindow(win));
is(win.gBrowser.tabs.length, 2, "two tabs were restored");
is(win.gBrowser.visibleTabs.length, 1, "one tab is visible");
let tab = win.gBrowser.visibleTabs[0];
is(tab.linkedBrowser.currentURI.spec, "about:mozilla", "visible tab is about:mozilla");
@@ -22,17 +22,17 @@ function test() {
});
}
function newWindowWithState(state, callback) {
let opts = "chrome,all,dialog=no,height=800,width=800";
let win = window.openDialog(getBrowserURL(), "_blank", opts);
win.addEventListener("load", function() {
- executeSoon(function () {
+ executeSoon(function() {
win.addEventListener("SSWindowStateReady", function() {
promiseTabRestored(win.gBrowser.tabs[0]).then(() => callback(win));
}, {once: true});
ss.setWindowState(win, JSON.stringify(state), true);
});
}, {once: true});
}
--- a/browser/components/sessionstore/test/browser_589246.js
+++ b/browser/components/sessionstore/test/browser_589246.js
@@ -53,17 +53,17 @@ function checkNoWindowsGenerator(num) {
}
// The first test has 0 pinned tabs and 1 unpinned tab
tests.push({
pinned: false,
extra: false,
close: false,
checkWinLin: checkNoWindowsGenerator(1),
- checkOSX: function(aPreviousState, aCurState) {
+ checkOSX(aPreviousState, aCurState) {
is(aCurState, aPreviousState, "test #1: closed window state is unchanged");
}
});
// The second test has 1 pinned tab and 0 unpinned tabs.
tests.push({
pinned: true,
extra: false,
@@ -113,18 +113,17 @@ function test() {
gPrefService.setIntPref("browser.startup.page", 3);
runNextTestOrFinish();
}
function runNextTestOrFinish() {
if (tests.length) {
setupForTest(tests.shift())
- }
- else {
+ } else {
// some state is cleaned up at the end of each test, but not all
["browser.tabs.warnOnClose", "browser.startup.page"].forEach(function(p) {
if (gPrefService.prefHasUserValue(p))
gPrefService.clearUserPref(p);
});
ss.setBrowserState(stateBackup);
executeSoon(finish);
@@ -161,38 +160,36 @@ function onStateRestored(aSubject, aTopi
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no", "http://example.com");
newWin.addEventListener("load", function(aEvent) {
promiseBrowserLoaded(newWin.gBrowser.selectedBrowser).then(() => {
// pin this tab
if (shouldPinTab)
newWin.gBrowser.pinTab(newWin.gBrowser.selectedTab);
- newWin.addEventListener("unload", function () {
+ newWin.addEventListener("unload", function() {
onWindowUnloaded();
}, {once: true});
// Open a new tab as well. On Windows/Linux this will be restored when the
// new window is opened below (in onWindowUnloaded). On OS X we'll just
// restore the pinned tabs, leaving the unpinned tab in the closedWindowsData.
if (shouldOpenTabs) {
let newTab = newWin.gBrowser.addTab("about:config");
let newTab2 = newWin.gBrowser.addTab("about:buildconfig");
newTab.linkedBrowser.addEventListener("load", function() {
if (shouldCloseTab == "one") {
newWin.gBrowser.removeTab(newTab2);
- }
- else if (shouldCloseTab == "both") {
+ } else if (shouldCloseTab == "both") {
newWin.gBrowser.removeTab(newTab);
newWin.gBrowser.removeTab(newTab2);
}
newWin.BrowserTryToCloseWindow();
}, {capture: true, once: true});
- }
- else {
+ } else {
newWin.BrowserTryToCloseWindow();
}
});
}, {once: true});
}
// This will be called before the window is actually closed
function onLastWindowClosed(aSubject, aTopic, aData) {
@@ -209,17 +206,17 @@ function onWindowUnloaded() {
info("test #" + testNum + ": onWindowClosed");
ok(gotLastWindowClosedTopic, "test #" + testNum + ": browser-lastwindow-close-granted was notified prior");
let previousClosedWindowData = ss.getClosedWindowData();
// Now we want to open a new window
let newWin = openDialog(location, "_blank", "chrome,all,dialog=no", "about:mozilla");
newWin.addEventListener("load", function(aEvent) {
- newWin.gBrowser.selectedBrowser.addEventListener("load", function () {
+ newWin.gBrowser.selectedBrowser.addEventListener("load", function() {
// Good enough for checking the state
afterTestCallback(previousClosedWindowData, ss.getClosedWindowData());
afterTestCleanup(newWin);
}, {capture: true, once: true});
}, {once: true});
}
--- a/browser/components/sessionstore/test/browser_590268.js
+++ b/browser/components/sessionstore/test/browser_590268.js
@@ -82,18 +82,17 @@ function test() {
uniq2[actualUniq] = r();
ss.setTabValue(tab, "uniq2", uniq2[actualUniq]);
// Delete the value we have for "baz". This tests that deleteTabValue
// will delete "early access" values (c.f. bug 617175). If this doesn't throw
// then the test is successful.
try {
ss.deleteTabValue(tab, "baz");
- }
- catch (e) {
+ } catch (e) {
ok(false, "no error calling deleteTabValue - " + e);
}
// This will be used in the final comparison to make sure we checked the
// same number as we set.
uniq2Count++;
}
}
--- a/browser/components/sessionstore/test/browser_590563.js
+++ b/browser/components/sessionstore/test/browser_590563.js
@@ -11,24 +11,24 @@ function test() {
}]
};
let url = "about:sessionrestore";
let formdata = {id: {sessionData}, url};
let state = { windows: [{ tabs: [{ entries: [{url, triggeringPrincipal_base64}], formdata }] }] };
waitForExplicitFinish();
- newWindowWithState(state, function (win) {
+ newWindowWithState(state, function(win) {
registerCleanupFunction(() => BrowserTestUtils.closeWindow(win));
is(gBrowser.tabs.length, 1, "The total number of tabs should be 1");
is(gBrowser.visibleTabs.length, 1, "The total number of visible tabs should be 1");
- executeSoon(function () {
- waitForFocus(function () {
+ executeSoon(function() {
+ waitForFocus(function() {
middleClickTest(win);
finish();
}, win);
});
});
}
function middleClickTest(win) {
@@ -59,13 +59,13 @@ function newWindowWithState(state, callb
let tab = win.gBrowser.selectedTab;
// The form data will be restored before SSTabRestored, so we want to listen
// for that on the currently selected tab (it will be reused)
tab.addEventListener("SSTabRestored", function() {
callback(win);
}, {capture: true, once: true});
- executeSoon(function () {
+ executeSoon(function() {
ss.setWindowState(win, JSON.stringify(state), true);
});
}, {once: true});
}
--- a/browser/components/sessionstore/test/browser_595601-restore_hidden.js
+++ b/browser/components/sessionstore/test/browser_595601-restore_hidden.js
@@ -11,34 +11,34 @@ var state = {windows:[{tabs:[
{entries:[{url:"http://example.com#7", triggeringPrincipal_base64}], hidden: true},
{entries:[{url:"http://example.com#8", triggeringPrincipal_base64}], hidden: true}
]}]};
function test() {
waitForExplicitFinish();
requestLongerTimeout(2);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref("browser.sessionstore.restore_hidden_tabs");
});
// First stage: restoreHiddenTabs = true
// Second stage: restoreHiddenTabs = false
- test_loadTabs(true, function () {
+ test_loadTabs(true, function() {
test_loadTabs(false, finish);
});
}
function test_loadTabs(restoreHiddenTabs, callback) {
Services.prefs.setBoolPref("browser.sessionstore.restore_hidden_tabs", restoreHiddenTabs);
let expectedTabs = restoreHiddenTabs ? 8 : 4;
let firstProgress = true;
- newWindowWithState(state, function (win, needsRestore, isRestoring) {
+ newWindowWithState(state, function(win, needsRestore, isRestoring) {
if (firstProgress) {
firstProgress = false;
is(isRestoring, 3, "restoring 3 tabs concurrently");
} else {
ok(isRestoring < 4, "restoring max. 3 tabs concurrently");
}
// We're explicity checking for (isRestoring == 1) here because the test
@@ -51,42 +51,42 @@ function test_loadTabs(restoreHiddenTabs
TabsProgressListener.uninit();
executeSoon(callback);
}
});
}
var TabsProgressListener = {
- init: function (win) {
+ init(win) {
this.window = win;
Services.obs.addObserver(this, "sessionstore-debug-tab-restored", false);
},
- uninit: function () {
+ uninit() {
Services.obs.removeObserver(this, "sessionstore-debug-tab-restored");
delete this.window;
delete this.callback;
},
- setCallback: function (callback) {
+ setCallback(callback) {
this.callback = callback;
},
- observe: function (browser) {
+ observe(browser) {
TabsProgressListener.onRestored(browser);
},
- onRestored: function (browser) {
+ onRestored(browser) {
if (this.callback && browser.__SS_restoreState == TAB_STATE_RESTORING)
this.callback.apply(null, [this.window].concat(this.countTabs()));
},
- countTabs: function () {
+ countTabs() {
let needsRestore = 0, isRestoring = 0;
for (let i = 0; i < this.window.gBrowser.tabs.length; i++) {
let browser = this.window.gBrowser.tabs[i].linkedBrowser;
if (browser.__SS_restoreState == TAB_STATE_RESTORING)
isRestoring++;
else if (browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE)
needsRestore++;
--- a/browser/components/sessionstore/test/browser_599909.js
+++ b/browser/components/sessionstore/test/browser_599909.js
@@ -69,23 +69,22 @@ var gController = Cc["@mozilla.org/autoc
function checkAutocompleteResults(aExpected, aCallback) {
gController.input = {
timeout: 10,
textValue: "",
searches: ["unifiedcomplete"],
searchParam: "enable-actions",
popupOpen: false,
minResultsForPopup: 0,
- invalidate: function() {},
+ invalidate() {},
disableAutoComplete: false,
completeDefaultIndex: false,
get popup() { return this; },
- onSearchBegin: function() {},
- onSearchComplete: function ()
- {
+ onSearchBegin() {},
+ onSearchComplete() {
info("Found " + gController.matchCount + " matches.");
// Check to see the expected uris and titles match up (in any order)
for (let i = 0; i < gController.matchCount; i++) {
if (gController.getStyleAt(i).includes("heuristic")) {
info("Skip heuristic match");
continue;
}
let action = gURLBar.popup.input._parseActionUrl(gController.getValueAt(i));
@@ -99,19 +98,19 @@ function checkAutocompleteResults(aExpec
// Make sure there is no reported open page that is not open.
for (let entry in aExpected) {
ok(false, "'" + entry + "' not found in autocomplete.");
}
executeSoon(aCallback);
},
- setSelectedIndex: function() {},
+ setSelectedIndex() {},
get searchCount() { return this.searches.length; },
- getSearchAt: function(aIndex) {
+ getSearchAt(aIndex) {
return this.searches[aIndex];
},
QueryInterface: XPCOMUtils.generateQI([
Ci.nsIAutoCompleteInput,
Ci.nsIAutoCompletePopup,
])
};
--- a/browser/components/sessionstore/test/browser_600545.js
+++ b/browser/components/sessionstore/test/browser_600545.js
@@ -12,17 +12,17 @@ function test() {
testBug600545();
}
function testBug600545() {
// Set the pref to false to cause non-app tabs to be stripped out on a save
Services.prefs.setBoolPref("browser.sessionstore.resume_from_crash", false);
Services.prefs.setIntPref("browser.sessionstore.interval", 2000);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref("browser.sessionstore.resume_from_crash");
Services.prefs.clearUserPref("browser.sessionstore.interval");
});
// This tests the following use case: When multiple windows are open
// and browser.sessionstore.resume_from_crash preference is false,
// tab session data for non-active window is stripped for non-pinned
// tabs. This occurs after "sessionstore-state-write-complete"
@@ -46,17 +46,17 @@ function testBug600545() {
],
selected: 3
}
] };
waitForBrowserState(state, function() {
// Need to wait for SessionStore's saveState function to be called
// so that non-pinned tabs will be stripped from non-active window
- waitForSaveState(function () {
+ waitForSaveState(function() {
let expectedNumberOfTabs = getStateTabCount(state);
let retrievedState = JSON.parse(ss.getBrowserState());
let actualNumberOfTabs = getStateTabCount(retrievedState);
is(actualNumberOfTabs, expectedNumberOfTabs,
"Number of tabs in retreived session data, matches number of tabs set.");
done();
--- a/browser/components/sessionstore/test/browser_607016.js
+++ b/browser/components/sessionstore/test/browser_607016.js
@@ -22,18 +22,17 @@ add_task(function* () {
function* progressCallback() {
let curState = JSON.parse(ss.getBrowserState());
for (let i = 0; i < curState.windows[0].tabs.length; i++) {
let tabState = state.windows[0].tabs[i];
let tabCurState = curState.windows[0].tabs[i];
if (tabState.extData) {
is(tabCurState.extData["uniq"], tabState.extData["uniq"],
"sanity check that tab has correct extData");
- }
- else {
+ } else {
// We aren't expecting there to be any data on extData, but panorama
// may be setting something, so we need to make sure that if we do have
// data, we just don't have anything for "uniq".
ok(!("extData" in tabCurState) || !("uniq" in tabCurState.extData),
"sanity check that tab doesn't have extData or extData doesn't have 'uniq'");
}
}
@@ -59,18 +58,17 @@ add_task(function* () {
// remove the uniq value and make sure it's not there in the closed data
ss.deleteTabValue(gBrowser.tabs[4], "uniq");
tabState = JSON.parse(ss.getTabState(gBrowser.tabs[4]));
// Since Panorama might have put data in, first check if there is extData.
// If there is explicitly check that "uniq" isn't in it. Otherwise, we're ok
if ("extData" in tabState) {
ok(!("uniq" in tabState.extData),
"(deleting) uniq not in existing extData");
- }
- else {
+ } else {
ok(true, "(deleting) no data is stored in extData");
}
// set unique data on the tab that never had any set, make sure that's saved
let newUniq2 = r();
ss.setTabValue(gBrowser.tabs[5], "uniq", newUniq2);
tabState = JSON.parse(ss.getTabState(gBrowser.tabs[5]));
is(tabState.extData.uniq, newUniq2,
--- a/browser/components/sessionstore/test/browser_615394-SSWindowState_events.js
+++ b/browser/components/sessionstore/test/browser_615394-SSWindowState_events.js
@@ -69,18 +69,17 @@ function runNextTest() {
}
}
Promise.all(closeWinPromises).then(() => {
let currentTest = tests.shift();
info("prepping for " + currentTest.name);
waitForBrowserState(testState, currentTest);
});
- }
- else {
+ } else {
waitForBrowserState(stateBackup, finish);
}
}
/** ACTUAL TESTS **/
function test_setTabState() {
let tab = gBrowser.tabs[1];
--- a/browser/components/sessionstore/test/browser_618151.js
+++ b/browser/components/sessionstore/test/browser_618151.js
@@ -35,18 +35,17 @@ function runNextTest() {
}
}
Promise.all(closeWinPromises).then(() => {
let currentTest = tests.shift();
info("running " + currentTest.name);
waitForBrowserState(testState, currentTest);
});
- }
- else {
+ } else {
ss.setBrowserState(stateBackup);
executeSoon(finish);
}
}
function test_setup() {
function onSSTabRestored(aEvent) {
gBrowser.tabContainer.removeEventListener("SSTabRestored", onSSTabRestored);
--- a/browser/components/sessionstore/test/browser_628270.js
+++ b/browser/components/sessionstore/test/browser_628270.js
@@ -1,45 +1,45 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function test() {
- let assertNumberOfTabs = function (num, msg) {
+ let assertNumberOfTabs = function(num, msg) {
is(gBrowser.tabs.length, num, msg);
}
- let assertNumberOfVisibleTabs = function (num, msg) {
+ let assertNumberOfVisibleTabs = function(num, msg) {
is(gBrowser.visibleTabs.length, num, msg);
}
- let assertNumberOfPinnedTabs = function (num, msg) {
+ let assertNumberOfPinnedTabs = function(num, msg) {
is(gBrowser._numPinnedTabs, num, msg);
}
waitForExplicitFinish();
// check prerequisites
assertNumberOfTabs(1, "we start off with one tab");
// setup
let tab = gBrowser.addTab("about:mozilla");
- whenTabIsLoaded(tab, function () {
+ whenTabIsLoaded(tab, function() {
// hide the newly created tab
assertNumberOfVisibleTabs(2, "there are two visible tabs");
gBrowser.showOnlyTheseTabs([gBrowser.tabs[0]]);
assertNumberOfVisibleTabs(1, "there is one visible tab");
ok(tab.hidden, "newly created tab is now hidden");
// close and restore hidden tab
promiseRemoveTab(tab).then(() => {
tab = ss.undoCloseTab(window, 0);
// check that everything was restored correctly, clean up and finish
- whenTabIsLoaded(tab, function () {
+ whenTabIsLoaded(tab, function() {
is(tab.linkedBrowser.currentURI.spec, "about:mozilla", "restored tab has correct url");
gBrowser.removeTab(tab);
finish();
});
});
});
}
--- a/browser/components/sessionstore/test/browser_636279.js
+++ b/browser/components/sessionstore/test/browser_636279.js
@@ -12,28 +12,28 @@ var state = {windows:[{tabs:[
{entries:[{url:"http://example.com#2", triggeringPrincipal_base64}]},
{entries:[{url:"http://example.com#3", triggeringPrincipal_base64}]},
{entries:[{url:"http://example.com#4", triggeringPrincipal_base64}]},
]}]};
function test() {
waitForExplicitFinish();
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
TabsProgressListener.uninit();
ss.setBrowserState(stateBackup);
});
TabsProgressListener.init();
window.addEventListener("SSWindowStateReady", function() {
let firstProgress = true;
- TabsProgressListener.setCallback(function (needsRestore, isRestoring) {
+ TabsProgressListener.setCallback(function(needsRestore, isRestoring) {
if (firstProgress) {
firstProgress = false;
is(isRestoring, 3, "restoring 3 tabs concurrently");
} else {
ok(isRestoring <= 3, "restoring max. 2 tabs concurrently");
}
if (0 == needsRestore) {
@@ -65,35 +65,35 @@ function countTabs() {
needsRestore++;
}
}
return [needsRestore, isRestoring];
}
var TabsProgressListener = {
- init: function () {
+ init() {
Services.obs.addObserver(this, "sessionstore-debug-tab-restored", false);
},
- uninit: function () {
+ uninit() {
Services.obs.removeObserver(this, "sessionstore-debug-tab-restored");
this.unsetCallback();
},
- setCallback: function (callback) {
+ setCallback(callback) {
this.callback = callback;
},
- unsetCallback: function () {
+ unsetCallback() {
delete this.callback;
},
- observe: function (browser, topic, data) {
+ observe(browser, topic, data) {
TabsProgressListener.onRestored(browser);
},
- onRestored: function (browser) {
+ onRestored(browser) {
if (this.callback && browser.__SS_restoreState == TAB_STATE_RESTORING) {
this.callback.apply(null, countTabs());
}
}
}
--- a/browser/components/sessionstore/test/browser_644409-scratchpads.js
+++ b/browser/components/sessionstore/test/browser_644409-scratchpads.js
@@ -36,17 +36,17 @@ function test() {
}
function windowObserver(aSubject, aTopic, aData) {
if (aTopic == "domwindowopened") {
let win = aSubject.QueryInterface(Ci.nsIDOMWindow);
win.addEventListener("load", function() {
if (win.Scratchpad) {
win.Scratchpad.addObserver({
- onReady: function() {
+ onReady() {
win.Scratchpad.removeObserver(this);
let state = win.Scratchpad.getState();
BrowserTestUtils.closeWindow(win).then(() => {
addState(state);
});
},
});
--- a/browser/components/sessionstore/test/browser_645428.js
+++ b/browser/components/sessionstore/test/browser_645428.js
@@ -9,14 +9,14 @@ function test() {
function observe(subject, topic, data) {
if (NOTIFICATION == topic) {
finish();
ok(true, "TOPIC received");
}
}
Services.obs.addObserver(observe, NOTIFICATION, false);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.obs.removeObserver(observe, NOTIFICATION);
});
ss.setBrowserState(JSON.stringify({ windows: [] }));
}
--- a/browser/components/sessionstore/test/browser_659591.js
+++ b/browser/components/sessionstore/test/browser_659591.js
@@ -1,21 +1,21 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
function test() {
waitForExplicitFinish();
let eventReceived = false;
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
ok(eventReceived, "SSWindowClosing event received");
});
- newWindow(function (win) {
+ newWindow(function(win) {
win.addEventListener("SSWindowClosing", function() {
eventReceived = true;
}, {once: true});
BrowserTestUtils.closeWindow(win).then(() => {
waitForFocus(finish);
});
});
--- a/browser/components/sessionstore/test/browser_687710.js
+++ b/browser/components/sessionstore/test/browser_687710.js
@@ -33,16 +33,16 @@ var state = {windows:[{tabs:[{entries:[
url: "http://example.com",
triggeringPrincipal_base64,
}
]
}
]}]}]}
function test() {
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
ss.setBrowserState(stateBackup);
});
/* This test fails by hanging. */
ss.setBrowserState(JSON.stringify(state));
ok(true, "Didn't hang!");
}
--- a/browser/components/sessionstore/test/browser_687710_2.js
+++ b/browser/components/sessionstore/test/browser_687710_2.js
@@ -20,21 +20,20 @@ var state = {entries:[
url: "http://example.com?1#a",
triggeringPrincipal_base64,
children: [{ docIdentifier: 10,
url: "http://example.com?10#aa",
triggeringPrincipal_base64 }]
}
]};
-function test()
-{
+function test() {
waitForExplicitFinish();
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
ss.setBrowserState(stateBackup);
});
let tab = gBrowser.addTab("about:blank");
promiseTabState(tab, state).then(() => {
let history = tab.linkedBrowser.webNavigation.sessionHistory;
is(history.count, 2, "history.count");
@@ -43,31 +42,30 @@ function test()
compareEntries(i, j, history);
}
}
finish();
});
}
-function compareEntries(i, j, history)
-{
+function compareEntries(i, j, history) {
let e1 = history.getEntryAtIndex(i, false)
.QueryInterface(Ci.nsISHEntry)
.QueryInterface(Ci.nsISHContainer);
let e2 = history.getEntryAtIndex(j, false)
.QueryInterface(Ci.nsISHEntry)
.QueryInterface(Ci.nsISHContainer);
ok(e1.sharesDocumentWith(e2),
- i + ' should share doc with ' + j);
+ i + " should share doc with " + j);
is(e1.childCount, e2.childCount,
- 'Child count mismatch (' + i + ', ' + j + ')');
+ "Child count mismatch (" + i + ", " + j + ")");
for (let c = 0; c < e1.childCount; c++) {
let c1 = e1.GetChildAt(c);
let c2 = e2.GetChildAt(c);
ok(c1.sharesDocumentWith(c2),
- 'Cousins should share documents. (' + i + ', ' + j + ', ' + c + ')');
+ "Cousins should share documents. (" + i + ", " + j + ", " + c + ")");
}
}
--- a/browser/components/sessionstore/test/browser_694378.js
+++ b/browser/components/sessionstore/test/browser_694378.js
@@ -14,18 +14,17 @@ function test() {
],
selectedWindow: 2
};
let brokenStateString = JSON.stringify(brokenState);
let gotError = false;
try {
ss.setWindowState(window, brokenStateString, true);
- }
- catch (ex) {
+ } catch (ex) {
gotError = true;
info(ex);
}
ok(!gotError, "ss.setWindowState did not throw an error");
// Make sure that we reset the state. Use a full state just in case things get crazy.
let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank", triggeringPrincipal_base64 }] }]}]};
--- a/browser/components/sessionstore/test/browser_701377.js
+++ b/browser/components/sessionstore/test/browser_701377.js
@@ -4,17 +4,17 @@
var state = {windows:[{tabs:[
{entries:[{url:"http://example.com#1", triggeringPrincipal_base64}]},
{entries:[{url:"http://example.com#2", triggeringPrincipal_base64}], hidden: true}
]}]};
function test() {
waitForExplicitFinish();
- newWindowWithState(state, function (aWindow) {
+ newWindowWithState(state, function(aWindow) {
let tab = aWindow.gBrowser.tabs[1];
ok(tab.hidden, "the second tab is hidden");
let tabShown = false;
let tabShowCallback = () => tabShown = true;
tab.addEventListener("TabShow", tabShowCallback);
let tabState = ss.getTabState(tab);
--- a/browser/components/sessionstore/test/browser_705597.js
+++ b/browser/components/sessionstore/test/browser_705597.js
@@ -8,31 +8,31 @@ var tabState = {
children: [{url: "about:mozilla", triggeringPrincipal_base64}]}]
};
function test() {
waitForExplicitFinish();
requestLongerTimeout(2);
Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref("browser.sessionstore.interval");
});
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
promiseTabState(tab, tabState).then(() => {
let sessionHistory = browser.sessionHistory;
let entry = sessionHistory.getEntryAtIndex(0, false);
entry.QueryInterface(Ci.nsISHContainer);
- whenChildCount(entry, 1, function () {
- whenChildCount(entry, 2, function () {
+ whenChildCount(entry, 1, function() {
+ whenChildCount(entry, 2, function() {
promiseBrowserLoaded(browser).then(() => {
return TabStateFlusher.flush(browser);
}).then(() => {
let {entries} = JSON.parse(ss.getTabState(tab));
is(entries.length, 1, "tab has one history entry");
ok(!entries[0].children, "history entry has no subframes");
// Make sure that we reset the state.
--- a/browser/components/sessionstore/test/browser_707862.js
+++ b/browser/components/sessionstore/test/browser_707862.js
@@ -1,43 +1,43 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
var tabState = {
entries: [{
url: "about:robots",
triggeringPrincipal_base64,
- children: [{url: "about:mozilla", triggeringPrincipal_base64,}]}]
+ children: [{url: "about:mozilla", triggeringPrincipal_base64, }]}]
};
function test() {
waitForExplicitFinish();
requestLongerTimeout(2);
Services.prefs.setIntPref("browser.sessionstore.interval", 4000);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref("browser.sessionstore.interval");
});
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
promiseTabState(tab, tabState).then(() => {
let sessionHistory = browser.sessionHistory;
let entry = sessionHistory.getEntryAtIndex(0, false);
entry.QueryInterface(Ci.nsISHContainer);
- whenChildCount(entry, 1, function () {
- whenChildCount(entry, 2, function () {
+ whenChildCount(entry, 1, function() {
+ whenChildCount(entry, 2, function() {
promiseBrowserLoaded(browser).then(() => {
let sessionHistory = browser.sessionHistory;
let entry = sessionHistory.getEntryAtIndex(0, false);
- whenChildCount(entry, 0, function () {
+ whenChildCount(entry, 0, function() {
// Make sure that we reset the state.
let blankState = { windows: [{ tabs: [{ entries: [{ url: "about:blank",
triggeringPrincipal_base64 }] }]}]};
waitForBrowserState(blankState, finish);
});
});
// reload the browser to deprecate the subframes
--- a/browser/components/sessionstore/test/browser_739531.js
+++ b/browser/components/sessionstore/test/browser_739531.js
@@ -21,18 +21,17 @@ function test() {
// executeSoon to allow the JS to execute on the page
executeSoon(function() {
let tab2;
let caughtError = false;
try {
tab2 = ss.duplicateTab(window, tab);
- }
- catch (e) {
+ } catch (e) {
caughtError = true;
info(e);
}
is(gBrowser.tabs.length, 3, "there should be 3 tabs")
ok(!caughtError, "duplicateTab didn't throw");
--- a/browser/components/sessionstore/test/browser_739805.js
+++ b/browser/components/sessionstore/test/browser_739805.js
@@ -5,17 +5,17 @@ var url = "data:text/html;charset=utf-8,
var tabState = {
entries: [{ url, triggeringPrincipal_base64 }], formdata: { id: { "foo": "bar" }, url }
};
function test() {
waitForExplicitFinish();
Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
if (gBrowser.tabs.length > 1)
gBrowser.removeTab(gBrowser.tabs[1]);
Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
});
let tab = gBrowser.addTab("about:blank");
let browser = tab.linkedBrowser;
--- a/browser/components/sessionstore/test/browser_911547.js
+++ b/browser/components/sessionstore/test/browser_911547.js
@@ -41,12 +41,12 @@ add_task(function* test() {
// clean up
gBrowser.removeTab(tab);
});
// injects an inline script element (with a text body)
function injectInlineScript(browser, scriptText) {
let scriptElt = browser.contentDocument.createElement("script");
- scriptElt.type = 'text/javascript';
+ scriptElt.type = "text/javascript";
scriptElt.text = scriptText;
browser.contentDocument.body.appendChild(scriptElt);
}
--- a/browser/components/sessionstore/test/browser_async_remove_tab.js
+++ b/browser/components/sessionstore/test/browser_async_remove_tab.js
@@ -16,17 +16,17 @@ function* createTabWithRandomValue(url)
}
function isValueInClosedData(rval) {
return ss.getClosedTabData(window).includes(rval);
}
function restoreClosedTabWithValue(rval) {
let closedTabData = JSON.parse(ss.getClosedTabData(window));
- let index = closedTabData.findIndex(function (data) {
+ let index = closedTabData.findIndex(function(data) {
return (data.state.extData && data.state.extData.foobar) == rval;
});
if (index == -1) {
throw new Error("no closed tab found for given rval");
}
return ss.undoCloseTab(window, index);
@@ -51,17 +51,17 @@ function promiseNewLocationAndHistoryEnt
Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference
])
};
shistory.addSHistoryListener(listener);
/* Keep the weak shistory listener alive. */
- addEventListener("unload", function () {
+ addEventListener("unload", function() {
try {
shistory.removeSHistoryListener(listener);
} catch (e) { /* Will most likely fail. */ }
});
});
});
}
--- a/browser/components/sessionstore/test/browser_cleaner.js
+++ b/browser/components/sessionstore/test/browser_cleaner.js
@@ -19,17 +19,17 @@ const URL_TAB1 = "http://example.com/bro
const URL_TAB2 = "http://example.com/browser_cleaner.js?newtab2=" + Math.random();
const URL_NEWWIN = "http://example.com/browser_cleaner.js?newwin=" + Math.random();
function isRecent(stamp) {
is(typeof stamp, "number", "This is a timestamp");
return Date.now() - stamp <= 60000;
}
-function promiseCleanup () {
+function promiseCleanup() {
info("Cleaning up browser");
return promiseBrowserState(getClosedState());
}
function getClosedState() {
return Cu.cloneInto(CLOSED_STATE, {});
}
--- a/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_tabs.js
+++ b/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_tabs.js
@@ -69,17 +69,17 @@ add_task(function* test_closedObjectsCha
yield openAndCloseTab(win, "about:mozilla");
assertNotificationCount(1);
info("Opening and closing a second tab.");
yield openAndCloseTab(win, "about:mozilla");
assertNotificationCount(2);
info(`Changing the ${MAX_TABS_UNDO_PREF} pref.`);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(MAX_TABS_UNDO_PREF);
});
yield awaitNotification(() => Services.prefs.setIntPref(MAX_TABS_UNDO_PREF, 1));
assertNotificationCount(3);
info("Undoing close of remaining closed tab.");
let tab = SessionStore.undoCloseTab(win, 0);
yield promiseTabRestored(tab);
--- a/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_windows.js
+++ b/browser/components/sessionstore/test/browser_closed_objects_changed_notifications_windows.js
@@ -70,17 +70,17 @@ add_task(function* test_closedObjectsCha
info("Closing both windows.");
yield closeWindow(win);
assertNotificationCount(3);
yield closeWindow(win2);
assertNotificationCount(4);
info(`Changing the ${MAX_WINDOWS_UNDO_PREF} pref.`);
- registerCleanupFunction(function () {
+ registerCleanupFunction(function() {
Services.prefs.clearUserPref(MAX_WINDOWS_UNDO_PREF);
});
yield awaitNotification(() => Services.prefs.setIntPref(MAX_WINDOWS_UNDO_PREF, 1));
assertNotificationCount(5);
info("Forgetting a closed window.");
yield awaitNotification(() => SessionStore.forgetClosedWindow());
assertNotificationCount(6);
--- 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 = async function (params) {
+var testCookieCollection = 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_docshell_uuid_consistency.js
+++ b/browser/components/sessionstore/test/browser_docshell_uuid_consistency.js
@@ -1,10 +1,10 @@
// First test - open a tab and duplicate it, using session restore to restore the history into the new tab.
-add_task(function* duplicateTab () {
+add_task(function* duplicateTab() {
const TEST_URL = "data:text/html,foo";
let tab = gBrowser.addTab(TEST_URL);
yield BrowserTestUtils.browserLoaded(tab.linkedBrowser);
yield ContentTask.spawn(tab.linkedBrowser, null, function() {
let docshell = content.window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIWebNavigation)
.QueryInterface(Ci.nsIDocShell);
--- a/browser/components/sessionstore/test/browser_formdata.js
+++ b/browser/components/sessionstore/test/browser_formdata.js
@@ -175,17 +175,17 @@ add_task(function* test_design_mode() {
expected = "<h1>Mmozilla</h1><script>document.designMode='on'</script>";
is(html, expected, "editable document has been restored correctly");
// Cleanup.
gBrowser.removeTab(tab);
});
function getInputValue(browser, id) {
- return sendMessage(browser, "ss-test:getInputValue", {id: id});
+ return sendMessage(browser, "ss-test:getInputValue", {id});
}
function setInputValue(browser, data) {
return sendMessage(browser, "ss-test:setInputValue", data);
}
function getInnerHTML(browser) {
return sendMessage(browser, "ss-test:getInnerHTML", {selector: "body"});
--- a/browser/components/sessionstore/test/browser_formdata_xpath.js
+++ b/browser/components/sessionstore/test/browser_formdata_xpath.js
@@ -97,55 +97,55 @@ function isArrayOfNumbers(value) {
function isArrayOfStrings(value) {
return Array.isArray(value) && value.every(n => typeof(n) === "string");
}
function getFormValue(browser, xpath) {
let value = FIELDS[xpath];
if (typeof value == "string") {
- return getInputValue(browser, {xpath: xpath});
+ return getInputValue(browser, {xpath});
}
if (typeof value == "boolean") {
- return getInputChecked(browser, {xpath: xpath});
+ return getInputChecked(browser, {xpath});
}
if (typeof value == "number") {
- return getSelectedIndex(browser, {xpath: xpath});
+ return getSelectedIndex(browser, {xpath});
}
if (isArrayOfNumbers(value)) {
- return getMultipleSelected(browser, {xpath: xpath});
+ return getMultipleSelected(browser, {xpath});
}
if (isArrayOfStrings(value)) {
- return getFileNameArray(browser, {xpath: xpath});
+ return getFileNameArray(browser, {xpath});
}
throw new Error("unknown input type");
}
function setFormValue(browser, xpath) {
let value = FIELDS[xpath];
if (typeof value == "string") {
- return setInputValue(browser, {xpath: xpath, value: value});
+ return setInputValue(browser, {xpath, value});
}
if (typeof value == "boolean") {
- return setInputChecked(browser, {xpath: xpath, checked: value});
+ return setInputChecked(browser, {xpath, checked: value});
}
if (typeof value == "number") {
- return setSelectedIndex(browser, {xpath: xpath, index: value});
+ return setSelectedIndex(browser, {xpath, index: value});
}
if (isArrayOfNumbers(value)) {
- return setMultipleSelected(browser, {xpath: xpath, indices: value});
+ return setMultipleSelected(browser, {xpath, indices: value});
}
if (isArrayOfStrings(value)) {
- return setFileNameArray(browser, {xpath: xpath, names: value});
+ return setFileNameArray(browser, {xpath, names: value});
}
throw new Error("unknown input type");
}
--- a/browser/components/sessionstore/test/browser_frame_history.js
+++ b/browser/components/sessionstore/test/browser_frame_history.js
@@ -113,17 +113,17 @@ add_task(function*() {
let tab = gBrowser.addTab(testURL);
gBrowser.selectedTab = tab;
yield waitForLoadsInBrowser(tab.linkedBrowser, 1);
info("dynamic: Opening a page with an iframe containing three frames, 4 dynamic loads should take place");
let doc = tab.linkedBrowser.contentDocument;
let iframe = doc.createElement("iframe");
iframe.id = "iframe";
- iframe.src="browser_frame_history_index.html";
+ iframe.src = "browser_frame_history_index.html";
doc.body.appendChild(iframe);
yield waitForLoadsInBrowser(tab.linkedBrowser, 4);
let browser_b = tab.linkedBrowser.contentDocument.
getElementById("iframe").contentDocument.
getElementsByTagName("frame")[1];
let document_b = browser_b.contentDocument;
let links = document_b.getElementsByTagName("a");
--- a/browser/components/sessionstore/test/browser_global_store.js
+++ b/browser/components/sessionstore/test/browser_global_store.js
@@ -14,17 +14,17 @@ add_task(function* () {
const testState = {
windows: [
{
tabs: [
{ entries: [{ url: "about:blank", triggeringPrincipal_base64 }] },
]
}
],
- global: global
+ global
};
function testRestoredState() {
is(ss.getGlobalValue(key1), value1, "restored state has global value");
}
function testGlobalStore() {
is(ss.getGlobalValue(key2), "", "global value initially not set");
--- a/browser/components/sessionstore/test/browser_parentProcessRestoreHash.js
+++ b/browser/components/sessionstore/test/browser_parentProcessRestoreHash.js
@@ -8,46 +8,46 @@ const Cm = Components.manager;
const TESTCLASSID = "78742c04-3630-448c-9be3-6c5070f062de";
const TESTURL = "about:testpageforsessionrestore#foo";
let TestAboutPage = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
- getURIFlags: function(aURI) {
+ getURIFlags(aURI) {
// No CAN_ or MUST_LOAD_IN_CHILD means this loads in the parent:
return Ci.nsIAboutModule.ALLOW_SCRIPT |
Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT |
Ci.nsIAboutModule.HIDE_FROM_ABOUTABOUT;
},
- newChannel: function(aURI, aLoadInfo) {
+ newChannel(aURI, aLoadInfo) {
// about: page inception!
let newURI = Services.io.newURI(SELFCHROMEURL);
let channel = Services.io.newChannelFromURIWithLoadInfo(newURI,
aLoadInfo);
channel.originalURI = aURI;
return channel;
},
- createInstance: function(outer, iid) {
+ createInstance(outer, iid) {
if (outer != null) {
throw Cr.NS_ERROR_NO_AGGREGATION;
}
return this.QueryInterface(iid);
},
- register: function() {
+ register() {
Cm.QueryInterface(Ci.nsIComponentRegistrar).registerFactory(
Components.ID(TESTCLASSID), "Only here for a test",
"@mozilla.org/network/protocol/about;1?what=testpageforsessionrestore", this);
},
- unregister: function() {
+ unregister() {
Cm.QueryInterface(Ci.nsIComponentRegistrar).unregisterFactory(
Components.ID(TESTCLASSID), this);
}
};
/**
* Test that switching from a remote to a parent process browser
--- a/browser/components/sessionstore/test/browser_restore_cookies_noOriginAttributes.js
+++ b/browser/components/sessionstore/test/browser_restore_cookies_noOriginAttributes.js
@@ -19,17 +19,17 @@ const SESSION_DATA = JSON.stringify(
entries: [],
lastAccessed: 1463893009797,
hidden: false,
attributes: {},
image: null
}, {
entries: [{
url: "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
- triggeringPrincipal_base64: triggeringPrincipal_base64,
+ triggeringPrincipal_base64,
charset: "UTF-8",
ID: 0,
docshellID: 2,
originalURI: "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
docIdentifier: 0,
persist: true
}],
lastAccessed: 1463893009321,
@@ -72,17 +72,17 @@ const SESSION_DATA_OA = JSON.stringify(
entries: [],
lastAccessed: 1463893009797,
hidden: false,
attributes: {},
image: null
}, {
entries: [{
url: "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
- triggeringPrincipal_base64: triggeringPrincipal_base64,
+ triggeringPrincipal_base64,
charset: "UTF-8",
ID: 0,
docshellID: 2,
originalURI: "http://www.example.com/browser/browser/components/sessionstore/test/browser_1267910_page.html",
docIdentifier: 0,
persist: true
}],
lastAccessed: 1463893009321,
--- a/browser/components/sessionstore/test/browser_sessionHistory.js
+++ b/browser/components/sessionstore/test/browser_sessionHistory.js
@@ -179,17 +179,17 @@ add_task(function* test_pushstate_replac
// Check that we have a single shistory entry.
yield TabStateFlusher.flush(browser);
let {entries} = JSON.parse(ss.getTabState(tab));
is(entries.length, 1, "there is one shistory entry");
is(entries[0].url, "http://example.com/1", "url is correct");
yield ContentTask.spawn(browser, {}, function* () {
- content.window.history.pushState({}, "", 'test-entry/');
+ content.window.history.pushState({}, "", "test-entry/");
});
// Check that we have added the history entry.
yield TabStateFlusher.flush(browser);
({entries} = JSON.parse(ss.getTabState(tab)));
is(entries.length, 2, "there is another shistory entry");
is(entries[1].url, "http://example.com/test-entry/", "url is correct");
--- a/browser/components/sessionstore/test/browser_upgrade_backup.js
+++ b/browser/components/sessionstore/test/browser_upgrade_backup.js
@@ -32,17 +32,17 @@ var getUpgradeBackups = Task.async(funct
let iterator;
let backups = [];
let upgradeBackupPrefix = Paths.upgradeBackupPrefix;
try {
iterator = new OS.File.DirectoryIterator(Paths.backups);
// iterate over all files in the backup directory
- yield iterator.forEach(function (file) {
+ yield iterator.forEach(function(file) {
// check the upgradeBackupPrefix
if (file.path.startsWith(Paths.upgradeBackupPrefix)) {
// the file is a backup
backups.push(file.path);
}
}, this);
} finally {
if (iterator) {
@@ -114,17 +114,17 @@ add_task(function* test_upgrade_backup_r
is((yield OS.File.exists(Paths.upgradeBackup)), true, "upgrade backup file has been created");
// get currently existing backups and check their count
let newBackups = yield getUpgradeBackups();
is(newBackups.length, maxUpgradeBackups, "expected number of backups are present after removing old backups");
// find all backups that were created during the last call to `SessionFile.write("");`
// ie, filter out all the backups that have already been present before the call
- newBackups = newBackups.filter(function (backup) {
+ newBackups = newBackups.filter(function(backup) {
return backups.indexOf(backup) < 0;
});
// check that exactly one new backup was created
is(newBackups.length, 1, "one new backup was created that was not removed");
yield SessionFile.write(""); // Second call to write() should not trigger anything
--- a/browser/components/sessionstore/test/browser_windowRestore_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_windowRestore_perwindowpb.js
@@ -7,19 +7,19 @@
function test() {
waitForExplicitFinish();
// Purging the list of closed windows
forgetClosedWindows();
// Load a private window, then close it
// and verify it doesn't get remembered for restoring
- whenNewWindowLoaded({private: true}, function (win) {
+ whenNewWindowLoaded({private: true}, function(win) {
info("The private window got loaded");
win.addEventListener("SSWindowClosing", function() {
- executeSoon(function () {
+ executeSoon(function() {
is(ss.getClosedWindowCount(), 0,
"The private window should not have been stored");
});
}, {once: true});
BrowserTestUtils.closeWindow(win).then(finish);
});
}
--- a/browser/components/sessionstore/test/content-forms.js
+++ b/browser/components/sessionstore/test/content-forms.js
@@ -38,96 +38,96 @@ function queryElement(data) {
function dispatchUIEvent(input, type) {
let event = input.ownerDocument.createEvent("UIEvents");
event.initUIEvent(type, true, true, input.ownerGlobal, 0);
input.dispatchEvent(event);
}
function defineListener(type, cb) {
- addMessageListener("ss-test:" + type, function ({data}) {
+ addMessageListener("ss-test:" + type, function({data}) {
sendAsyncMessage("ss-test:" + type, cb(data));
});
}
-defineListener("sendKeyEvent", function (data) {
+defineListener("sendKeyEvent", function(data) {
let frame = content;
if (data.hasOwnProperty("frame")) {
frame = content.frames[data.frame];
}
let ifreq = frame.QueryInterface(Ci.nsIInterfaceRequestor);
let utils = ifreq.getInterface(Ci.nsIDOMWindowUtils);
let keyCode = data.key.charCodeAt(0);
let charCode = Ci.nsIDOMKeyEvent.DOM_VK_A + keyCode - "a".charCodeAt(0);
utils.sendKeyEvent("keydown", keyCode, charCode, null);
utils.sendKeyEvent("keypress", keyCode, charCode, null);
utils.sendKeyEvent("keyup", keyCode, charCode, null);
});
-defineListener("getInnerHTML", function (data) {
+defineListener("getInnerHTML", function(data) {
return queryElement(data).innerHTML;
});
-defineListener("getTextContent", function (data) {
+defineListener("getTextContent", function(data) {
return queryElement(data).textContent;
});
-defineListener("getInputValue", function (data) {
+defineListener("getInputValue", function(data) {
return queryElement(data).value;
});
-defineListener("setInputValue", function (data) {
+defineListener("setInputValue", function(data) {
let input = queryElement(data);
input.value = data.value;
dispatchUIEvent(input, "input");
});
-defineListener("getInputChecked", function (data) {
+defineListener("getInputChecked", function(data) {
return queryElement(data).checked;
});
-defineListener("setInputChecked", function (data) {
+defineListener("setInputChecked", function(data) {
let input = queryElement(data);
input.checked = data.checked;
dispatchUIEvent(input, "change");
});
-defineListener("getSelectedIndex", function (data) {
+defineListener("getSelectedIndex", function(data) {
return queryElement(data).selectedIndex;
});
-defineListener("setSelectedIndex", function (data) {
+defineListener("setSelectedIndex", function(data) {
let input = queryElement(data);
input.selectedIndex = data.index;
dispatchUIEvent(input, "change");
});
-defineListener("getMultipleSelected", function (data) {
+defineListener("getMultipleSelected", function(data) {
let input = queryElement(data);
return Array.map(input.options, (opt, idx) => idx)
.filter(idx => input.options[idx].selected);
});
-defineListener("setMultipleSelected", function (data) {
+defineListener("setMultipleSelected", function(data) {
let input = queryElement(data);
Array.forEach(input.options, (opt, idx) => opt.selected = data.indices.indexOf(idx) > -1);
dispatchUIEvent(input, "change");
});
-defineListener("getFileNameArray", function (data) {
+defineListener("getFileNameArray", function(data) {
return queryElement(data).mozGetFileNameArray();
});
-defineListener("setFileNameArray", function (data) {
+defineListener("setFileNameArray", function(data) {
let input = queryElement(data);
input.mozSetFileNameArray(data.names, data.names.length);
dispatchUIEvent(input, "input");
});
-defineListener("setFormElementValues", function (data) {
+defineListener("setFormElementValues", function(data) {
for (let elem of content.document.forms[0].elements) {
elem.value = data.value;
dispatchUIEvent(elem, "input");
}
});
--- a/browser/components/sessionstore/test/content.js
+++ b/browser/components/sessionstore/test/content.js
@@ -11,56 +11,56 @@ Cu.import("resource://gre/modules/XPCOMU
Cu.import("resource:///modules/sessionstore/FrameTree.jsm", this);
var gFrameTree = new FrameTree(this);
function executeSoon(callback) {
Services.tm.mainThread.dispatch(callback, Components.interfaces.nsIThread.DISPATCH_NORMAL);
}
gFrameTree.addObserver({
- onFrameTreeReset: function () {
+ onFrameTreeReset() {
sendAsyncMessage("ss-test:onFrameTreeReset");
},
- onFrameTreeCollected: function () {
+ onFrameTreeCollected() {
sendAsyncMessage("ss-test:onFrameTreeCollected");
}
});
var historyListener = {
- OnHistoryNewEntry: function () {
+ OnHistoryNewEntry() {
sendAsyncMessage("ss-test:OnHistoryNewEntry");
},
- OnHistoryGoBack: function () {
+ OnHistoryGoBack() {
sendAsyncMessage("ss-test:OnHistoryGoBack");
return true;
},
- OnHistoryGoForward: function () {
+ OnHistoryGoForward() {
sendAsyncMessage("ss-test:OnHistoryGoForward");
return true;
},
- OnHistoryGotoIndex: function () {
+ OnHistoryGotoIndex() {
sendAsyncMessage("ss-test:OnHistoryGotoIndex");
return true;
},
- OnHistoryPurge: function () {
+ OnHistoryPurge() {
sendAsyncMessage("ss-test:OnHistoryPurge");
return true;
},
- OnHistoryReload: function () {
+ OnHistoryReload() {
sendAsyncMessage("ss-test:OnHistoryReload");
return true;
},
- OnHistoryReplaceEntry: function () {
+ OnHistoryReplaceEntry() {
sendAsyncMessage("ss-test:OnHistoryReplaceEntry");
},
QueryInterface: XPCOMUtils.generateQI([
Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference
])
};
@@ -70,32 +70,32 @@ if (sessionHistory) {
sessionHistory.addSHistoryListener(historyListener);
}
/**
* This frame script is only loaded for sessionstore mochitests. It enables us
* to modify and query docShell data when running with multiple processes.
*/
-addEventListener("hashchange", function () {
+addEventListener("hashchange", function() {
sendAsyncMessage("ss-test:hashchange");
});
-addMessageListener("ss-test:purgeDomainData", function ({data: domain}) {
+addMessageListener("ss-test:purgeDomainData", function({data: domain}) {
Services.obs.notifyObservers(null, "browser:purge-domain-data", domain);
content.setTimeout(() => sendAsyncMessage("ss-test:purgeDomainData"));
});
-addMessageListener("ss-test:getStyleSheets", function (msg) {
+addMessageListener("ss-test:getStyleSheets", function(msg) {
let sheets = content.document.styleSheets;
let titles = Array.map(sheets, ss => [ss.title, ss.disabled]);
sendSyncMessage("ss-test:getStyleSheets", titles);
});
-addMessageListener("ss-test:enableStyleSheetsForSet", function (msg) {
+addMessageListener("ss-test:enableStyleSheetsForSet", function(msg) {
let sheets = content.document.styleSheets;
let change = false;
for (let i = 0; i < sheets.length; i++) {
if (sheets[i].disabled != (msg.data.indexOf(sheets[i].title) == -1)) {
change = true;
break;
}
}
@@ -113,68 +113,68 @@ addMessageListener("ss-test:enableStyleS
Services.obs.addObserver(observer, "style-sheet-applicable-state-changed", false);
content.document.enableStyleSheetsForSet(msg.data);
} else {
sendAsyncMessage("ss-test:enableStyleSheetsForSet");
}
});
-addMessageListener("ss-test:enableSubDocumentStyleSheetsForSet", function (msg) {
+addMessageListener("ss-test:enableSubDocumentStyleSheetsForSet", function(msg) {
let iframe = content.document.getElementById(msg.data.id);
iframe.contentDocument.enableStyleSheetsForSet(msg.data.set);
sendAsyncMessage("ss-test:enableSubDocumentStyleSheetsForSet");
});
-addMessageListener("ss-test:getAuthorStyleDisabled", function (msg) {
+addMessageListener("ss-test:getAuthorStyleDisabled", function(msg) {
let {authorStyleDisabled} =
docShell.contentViewer;
sendSyncMessage("ss-test:getAuthorStyleDisabled", authorStyleDisabled);
});
-addMessageListener("ss-test:setAuthorStyleDisabled", function (msg) {
+addMessageListener("ss-test:setAuthorStyleDisabled", function(msg) {
let markupDocumentViewer =
docShell.contentViewer;
markupDocumentViewer.authorStyleDisabled = msg.data;
sendSyncMessage("ss-test:setAuthorStyleDisabled");
});
-addMessageListener("ss-test:setUsePrivateBrowsing", function (msg) {
+addMessageListener("ss-test:setUsePrivateBrowsing", function(msg) {
let loadContext =
docShell.QueryInterface(Ci.nsILoadContext);
loadContext.usePrivateBrowsing = msg.data;
sendAsyncMessage("ss-test:setUsePrivateBrowsing");
});
-addMessageListener("ss-test:getScrollPosition", function (msg) {
+addMessageListener("ss-test:getScrollPosition", function(msg) {
let frame = content;
if (msg.data.hasOwnProperty("frame")) {
frame = content.frames[msg.data.frame];
}
let {scrollX: x, scrollY: y} = frame;
- sendAsyncMessage("ss-test:getScrollPosition", {x: x, y: y});
+ sendAsyncMessage("ss-test:getScrollPosition", {x, y});
});
-addMessageListener("ss-test:setScrollPosition", function (msg) {
+addMessageListener("ss-test:setScrollPosition", function(msg) {
let frame = content;
let {x, y} = msg.data;
if (msg.data.hasOwnProperty("frame")) {
frame = content.frames[msg.data.frame];
}
frame.scrollTo(x, y);
frame.addEventListener("scroll", function onScroll(event) {
if (frame.document == event.target) {
frame.removeEventListener("scroll", onScroll);
sendAsyncMessage("ss-test:setScrollPosition");
}
});
});
-addMessageListener("ss-test:createDynamicFrames", function ({data}) {
+addMessageListener("ss-test:createDynamicFrames", function({data}) {
function createIFrame(rows) {
let frames = content.document.getElementById(data.id);
frames.setAttribute("rows", rows);
let frame = content.document.createElement("frame");
frame.setAttribute("src", data.url);
frames.appendChild(frame);
}
@@ -195,28 +195,28 @@ addMessageListener("ss-test:createDynami
// means that it must not be included in the frame tree.
createIFrame("25%, 25%, 25%, 25%");
}
}, true);
sendAsyncMessage("ss-test:createDynamicFrames");
});
-addMessageListener("ss-test:removeLastFrame", function ({data}) {
+addMessageListener("ss-test:removeLastFrame", function({data}) {
let frames = content.document.getElementById(data.id);
frames.lastElementChild.remove();
sendAsyncMessage("ss-test:removeLastFrame");
});
-addMessageListener("ss-test:mapFrameTree", function (msg) {
+addMessageListener("ss-test:mapFrameTree", function(msg) {
let result = gFrameTree.map(frame => ({href: frame.location.href}));
sendAsyncMessage("ss-test:mapFrameTree", result);
});
-addMessageListener("ss-test:click", function ({data}) {
+addMessageListener("ss-test:click", function({data}) {
content.document.getElementById(data.id).click();
sendAsyncMessage("ss-test:click");
});
addEventListener("load", function(event) {
let subframe = event.target != content.document;
- sendAsyncMessage("ss-test:loadEvent", {subframe: subframe, url: event.target.documentURI});
+ sendAsyncMessage("ss-test:loadEvent", {subframe, url: event.target.documentURI});
}, true);
--- a/browser/components/sessionstore/test/head.js
+++ b/browser/components/sessionstore/test/head.js
@@ -36,23 +36,23 @@ const {TabState} = Cu.import("resource:/
const {TabStateFlusher} = Cu.import("resource:///modules/sessionstore/TabStateFlusher.jsm", {});
const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
// Some tests here assume that all restored tabs are loaded without waiting for
// the user to bring them to the foreground. We ensure this by resetting the
// related preference (see the "firefox.js" defaults file for details).
Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", false);
-registerCleanupFunction(function () {
+registerCleanupFunction(function() {
Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
});
// Obtain access to internals
Services.prefs.setBoolPref("browser.sessionstore.debug", true);
-registerCleanupFunction(function () {
+registerCleanupFunction(function() {
Services.prefs.clearUserPref("browser.sessionstore.debug");
});
// This kicks off the search service used on about:home and allows the
// session restore tests to be run standalone without triggering errors.
Cc["@mozilla.org/browser/clh;1"].getService(Ci.nsIBrowserHandler).defaultArgs;
@@ -90,18 +90,18 @@ function waitForBrowserState(aState, aSe
let expectedTabsRestored = 0;
let expectedWindows = aState.windows.length;
let windowsOpen = 1;
let listening = false;
let windowObserving = false;
let restoreHiddenTabs = Services.prefs.getBoolPref(
"browser.sessionstore.restore_hidden_tabs");
- aState.windows.forEach(function (winState) {
- winState.tabs.forEach(function (tabState) {
+ aState.windows.forEach(function(winState) {
+ winState.tabs.forEach(function(tabState) {
if (restoreHiddenTabs || !tabState.hidden)
expectedTabsRestored++;
});
});
// There must be only hidden tabs and restoreHiddenTabs = false. We still
// expect one of them to be restored because it gets shown automatically.
if (!expectedTabsRestored)
@@ -206,17 +206,17 @@ function waitForTopic(aTopic, aTimeout,
let observing = false;
function removeObserver() {
if (!observing)
return;
Services.obs.removeObserver(observer, aTopic);
observing = false;
}
- let timeout = setTimeout(function () {
+ let timeout = setTimeout(function() {
removeObserver();
aCallback(false);
}, aTimeout);
function observer(aSubject, aTopic, aData) {
removeObserver();
timeout = clearTimeout(timeout);
executeSoon(() => aCallback(true));
@@ -311,71 +311,71 @@ function* BrowserWindowIterator() {
yield currentWindow;
}
}
}
var gWebProgressListener = {
_callback: null,
- setCallback: function (aCallback) {
+ setCallback(aCallback) {
if (!this._callback) {
window.gBrowser.addTabsProgressListener(this);
}
this._callback = aCallback;
},
- unsetCallback: function () {
+ unsetCallback() {
if (this._callback) {
this._callback = null;
window.gBrowser.removeTabsProgressListener(this);
}
},
- onStateChange: function (aBrowser, aWebProgress, aRequest,
+ onStateChange(aBrowser, aWebProgress, aRequest,
aStateFlags, aStatus) {
if (aStateFlags & Ci.nsIWebProgressListener.STATE_STOP &&
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_NETWORK &&
aStateFlags & Ci.nsIWebProgressListener.STATE_IS_WINDOW) {
this._callback(aBrowser);
}
}
};
-registerCleanupFunction(function () {
+registerCleanupFunction(function() {
gWebProgressListener.unsetCallback();
});
var gProgressListener = {
_callback: null,
- setCallback: function (callback) {
+ setCallback(callback) {
Services.obs.addObserver(this, "sessionstore-debug-tab-restored", false);
this._callback = callback;
},
- unsetCallback: function () {
+ unsetCallback() {
if (this._callback) {
this._callback = null;
Services.obs.removeObserver(this, "sessionstore-debug-tab-restored");
}
},
- observe: function (browser, topic, data) {
+ observe(browser, topic, data) {
gProgressListener.onRestored(browser);
},
- onRestored: function (browser) {
+ onRestored(browser) {
if (browser.__SS_restoreState == TAB_STATE_RESTORING) {
let args = [browser].concat(gProgressListener._countTabs());
gProgressListener._callback.apply(gProgressListener, args);
}
},
- _countTabs: function () {
+ _countTabs() {
let needsRestore = 0, isRestoring = 0, wasRestored = 0;
for (let win of BrowserWindowIterator()) {
for (let i = 0; i < win.gBrowser.tabs.length; i++) {
let browser = win.gBrowser.tabs[i].linkedBrowser;
if (!browser.__SS_restoreState)
wasRestored++;
else if (browser.__SS_restoreState == TAB_STATE_RESTORING)
@@ -383,17 +383,17 @@ var gProgressListener = {
else if (browser.__SS_restoreState == TAB_STATE_NEEDS_RESTORE)
needsRestore++;
}
}
return [needsRestore, isRestoring, wasRestored];
}
};
-registerCleanupFunction(function () {
+registerCleanupFunction(function() {
gProgressListener.unsetCallback();
});
// Close all but our primary window.
function promiseAllButPrimaryWindowClosed() {
let windows = [];
for (let win of BrowserWindowIterator()) {
if (win != window) {
--- a/browser/components/sessionstore/test/unit/test_backup_once.js
+++ b/browser/components/sessionstore/test/unit/test_backup_once.js
@@ -40,19 +40,19 @@ add_task(function* init() {
});
var pathStore;
var pathBackup;
var decoder;
function promise_check_exist(path, shouldExist) {
return Task.spawn(function*() {
- do_print("Ensuring that " + path + (shouldExist?" exists":" does not exist"));
+ do_print("Ensuring that " + path + (shouldExist ? " exists" : " does not exist"));
if ((yield OS.File.exists(path)) != shouldExist) {
- throw new Error("File " + path + " should " + (shouldExist?"exist":"not exist"));
+ throw new Error("File " + path + " should " + (shouldExist ? "exist" : "not exist"));
}
});
}
function promise_check_contents(path, expect) {
return Task.spawn(function*() {
do_print("Checking whether " + path + " has the right contents");
let actual = yield OS.File.read(path, { encoding: "utf-8"});