Bug 1276884 - fix nits in TabAttributes.jsm and TabState.jsm. r=ttaubert
authorMike de Boer <mdeboer@mozilla.com>
Wed, 01 Jun 2016 14:48:18 +0200
changeset 340895 5ca8ea4f429a8415335cccbf3c00a57ffd0ca93e
parent 340894 52e0f82a635e435f226bcabd6924b71c90b8e86e
child 340896 08084e9e30d23d2154b0e994a6e2733633c381fb
push id1183
push userraliiev@mozilla.com
push dateMon, 05 Sep 2016 20:01:49 +0000
treeherdermozilla-release@3148731bed45 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersttaubert
bugs1276884
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
Bug 1276884 - fix nits in TabAttributes.jsm and TabState.jsm. r=ttaubert
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/TabAttributes.jsm
browser/components/sessionstore/TabState.jsm
browser/components/sessionstore/TabStateCache.jsm
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -2313,17 +2313,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");
     }
 
@@ -2468,17 +2468,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) {