Merge m-c to inbound, a=merge
authorWes Kocher <wkocher@mozilla.com>
Wed, 01 Jun 2016 17:17:15 -0700
changeset 339045 199560989621a1fb7790aa9f44cfb07aea49a755
parent 339044 2b74c4db83cc5eadf6cd41679572185c35d61bf4 (current diff)
parent 338884 22047a4eea784c15026c77911c0bd6ea1b70fa68 (diff)
child 339046 24bd574ecbf0c8630290fc81f76e6a928d3ee8dd
push id6249
push userjlund@mozilla.com
push dateMon, 01 Aug 2016 13:59:36 +0000
treeherdermozilla-beta@bad9d4f5bf7e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmerge
milestone49.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Merge m-c to inbound, a=merge
--- a/browser/components/sessionstore/PrivacyFilter.jsm
+++ b/browser/components/sessionstore/PrivacyFilter.jsm
@@ -9,45 +9,33 @@ this.EXPORTED_SYMBOLS = ["PrivacyFilter"
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
 
 XPCOMUtils.defineLazyModuleGetter(this, "PrivacyLevel",
   "resource:///modules/sessionstore/PrivacyLevel.jsm");
 
 /**
- * Returns whether the current privacy level allows saving data for the given
- * |url|.
- *
- * @param url The URL we want to save data for.
- * @return bool
- */
-function checkPrivacyLevel(url) {
-  let isHttps = url.startsWith("https:");
-  return PrivacyLevel.canSave({isHttps});
-}
-
-/**
  * A module that provides methods to filter various kinds of data collected
  * from a tab by the current privacy level as set by the user.
  */
 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) {
     let retval = {};
 
     for (let host of Object.keys(data)) {
-      if (checkPrivacyLevel(host)) {
+      if (PrivacyLevel.check(host)) {
         retval[host] = data[host];
       }
     }
 
     return Object.keys(retval).length ? retval : null;
   },
 
   /**
@@ -57,17 +45,17 @@ this.PrivacyFilter = Object.freeze({
    *
    * @param data The form data as collected from a tab.
    * @return object
    */
   filterFormData: function (data) {
     // If the given form data object has an associated URL that we are not
     // allowed to store data for, bail out. We explicitly discard data for any
     // children as well even if storing data for those frames would be allowed.
-    if (data.url && !checkPrivacyLevel(data.url)) {
+    if (data.url && !PrivacyLevel.check(data.url)) {
       return;
     }
 
     let retval = {};
 
     for (let key of Object.keys(data)) {
       if (key === "children") {
         let recurse = child => this.filterFormData(child);
--- a/browser/components/sessionstore/PrivacyLevel.jsm
+++ b/browser/components/sessionstore/PrivacyLevel.jsm
@@ -4,20 +4,16 @@
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["PrivacyLevel"];
 
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
-XPCOMUtils.defineLazyServiceGetter(this, "gSessionStartup",
-  "@mozilla.org/browser/sessionstartup;1", "nsISessionStartup");
 
 const PREF = "browser.sessionstore.privacy_level";
 
 // The following constants represent the different possible privacy levels that
 // can be set by the user and that we need to consider when collecting text
 // data, and cookies.
 //
 // Collect data from all sites (http and https).
@@ -27,16 +23,27 @@ const PRIVACY_ENCRYPTED = 1;
 // Collect no data.
 const PRIVACY_FULL = 2;
 
 /**
  * The external API as exposed by this module.
  */
 var PrivacyLevel = Object.freeze({
   /**
+   * Returns whether the current privacy level allows saving data for the given
+   * |url|.
+   *
+   * @param url The URL we want to save data for.
+   * @return bool
+   */
+  check: function (url) {
+    return PrivacyLevel.canSave({ isHttps: url.startsWith("https:") });
+  },
+
+  /**
    * Checks whether we're allowed to save data for a specific site.
    *
    * @param {isHttps: boolean}
    *        An object that must have one property: 'isHttps'.
    *        'isHttps' tells whether the site us secure communication (HTTPS).
    * @return {bool} Whether we can save data for the specified site.
    */
   canSave: function ({isHttps}) {
--- a/browser/components/sessionstore/RunState.jsm
+++ b/browser/components/sessionstore/RunState.jsm
@@ -1,32 +1,28 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["RunState"];
 
-const Cu = Components.utils;
-
-Cu.import("resource://gre/modules/Services.jsm", this);
-
 const STATE_STOPPED = 0;
 const STATE_RUNNING = 1;
 const STATE_QUITTING = 2;
 const STATE_CLOSING = 3;
 const STATE_CLOSED = 4;
 
 // We're initially stopped.
 var state = STATE_STOPPED;
 
 /**
  * This module keeps track of SessionStore's current run state. We will
- * always start out at STATE_STOPPED. After the sessionw as read from disk and
+ * always start out at STATE_STOPPED. After the session was read from disk and
  * the initial browser window has loaded we switch to STATE_RUNNING. On the
  * first notice that a browser shutdown was granted we switch to STATE_QUITTING.
  */
 this.RunState = Object.freeze({
   // If we're stopped then SessionStore hasn't been initialized yet. As soon
   // as the session is read from disk and the initial browser window has loaded
   // the run state will change to STATE_RUNNING.
   get isStopped() {
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -2316,17 +2316,17 @@ var SessionStoreInternal = {
       this.saveStateDelayed();
     }
   },
 
   /**
    * Restores the session state stored in LastSession. This will attempt
    * to merge data into the current session. If a window was opened at startup
    * with pinned tab(s), then the remaining data from the previous session for
-   * that window will be opened into that winddow. Otherwise new windows will
+   * that window will be opened into that window. Otherwise new windows will
    * be opened.
    */
   restoreLastSession: function ssi_restoreLastSession() {
     // Use the public getter since it also checks PB mode
     if (!this.canRestoreLastSession) {
       throw Components.Exception("Last session can not be restored");
     }
 
@@ -2471,17 +2471,17 @@ var SessionStoreInternal = {
       for (let tab of window.gBrowser.tabs) {
         this.reviveCrashedTab(tab);
       }
     }
   },
 
   /**
    * Navigate the given |tab| by first collecting its current state and then
-   * either changing only the index of the currently shown shistory entry,
+   * either changing only the index of the currently shown history entry,
    * or restoring the exact same state again and passing the new URL to load
    * in |loadArguments|. Use this method to seamlessly switch between pages
    * loaded in the parent and pages loaded in the child process.
    *
    * This method might be called multiple times before it has finished
    * flushing the browser tab. If that occurs, the loadArguments from
    * the most recent call to navigateAndRestore will be used once the
    * flush has finished.
--- a/browser/components/sessionstore/TabAttributes.jsm
+++ b/browser/components/sessionstore/TabAttributes.jsm
@@ -1,16 +1,24 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["TabAttributes"];
 
+// We never want to directly read or write these attributes.
+// 'image' should not be accessed directly but handled by using the
+//         gBrowser.getIcon()/setIcon() methods.
+// 'muted' should not be accessed directly but handled by using the
+//         tab.linkedBrowser.audioMuted/toggleMuteAudio methods.
+// 'pending' is used internal by sessionstore and managed accordingly.
+const ATTRIBUTES_TO_SKIP = new Set(["image", "muted", "pending"]);
+
 // 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) {
     return TabAttributesInternal.persist(name);
   },
 
@@ -21,26 +29,18 @@ this.TabAttributes = Object.freeze({
   set: function (tab, data = {}) {
     TabAttributesInternal.set(tab, data);
   }
 });
 
 var TabAttributesInternal = {
   _attrs: new Set(),
 
-  // We never want to directly read or write those attributes.
-  // 'image' should not be accessed directly but handled by using the
-  //         gBrowser.getIcon()/setIcon() methods.
-  // 'muted' should not be accessed directly but handled by using the
-  //         tab.linkedBrowser.audioMuted/toggleMuteAudio methods.
-  // 'pending' is used internal by sessionstore and managed accordingly.
-  _skipAttrs: new Set(["image", "muted", "pending"]),
-
   persist: function (name) {
-    if (this._attrs.has(name) || this._skipAttrs.has(name)) {
+    if (this._attrs.has(name) || ATTRIBUTES_TO_SKIP.has(name)) {
       return false;
     }
 
     this._attrs.add(name);
     return true;
   },
 
   get: function (tab) {
@@ -58,15 +58,15 @@ var TabAttributesInternal = {
   set: function (tab, data = {}) {
     // Clear attributes.
     for (let name of this._attrs) {
       tab.removeAttribute(name);
     }
 
     // Set attributes.
     for (let name in data) {
-      if (!this._skipAttrs.has(name)) {
+      if (!ATTRIBUTES_TO_SKIP.has(name)) {
         tab.setAttribute(name, data[name]);
       }
     }
   }
 };
 
--- a/browser/components/sessionstore/TabState.jsm
+++ b/browser/components/sessionstore/TabState.jsm
@@ -4,29 +4,23 @@
 
 "use strict";
 
 this.EXPORTED_SYMBOLS = ["TabState"];
 
 const Cu = Components.utils;
 
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
-Cu.import("resource://gre/modules/Promise.jsm", this);
-Cu.import("resource://gre/modules/Task.jsm", this);
 
-XPCOMUtils.defineLazyModuleGetter(this, "console",
-  "resource://gre/modules/Console.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "PrivacyFilter",
   "resource:///modules/sessionstore/PrivacyFilter.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TabStateCache",
   "resource:///modules/sessionstore/TabStateCache.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "TabAttributes",
   "resource:///modules/sessionstore/TabAttributes.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Utils",
-  "resource:///modules/sessionstore/Utils.jsm");
 
 /**
  * Module that contains tab state collection methods.
  */
 this.TabState = Object.freeze({
   update: function (browser, data) {
     TabStateInternal.update(browser, data);
   },
@@ -158,17 +152,17 @@ var TabStateInternal = {
   copyFromCache(browser, tabData, options = {}) {
     let data = TabStateCache.get(browser);
     if (!data) {
       return;
     }
 
     // The caller may explicitly request to omit privacy checks.
     let includePrivateData = options && options.includePrivateData;
-    let isPinned = tabData.pinned || false;
+    let isPinned = !!tabData.pinned;
 
     for (let key of Object.keys(data)) {
       let value = data[key];
 
       // Filter sensitive data according to the current privacy level.
       if (!includePrivateData) {
         if (key === "storage") {
           value = PrivacyFilter.filterSessionStorageData(value);
--- a/browser/components/sessionstore/TabStateCache.jsm
+++ b/browser/components/sessionstore/TabStateCache.jsm
@@ -58,17 +58,17 @@ var TabStateCacheInternal = {
    */
   get: function (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 those have been changed.
+   * 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) {
     if (!data.storage) {