Bug 1451715 - Rename {get,set,delete}{Window,Global}Value to match {get,set,delete}CustomTabValue. r=dao
authorJason Chapin <jason@lab1337.com>
Tue, 25 Sep 2018 14:21:57 -0400
changeset 438356 51cd5f6c6fa3
parent 438355 a9a1d4e6193e
child 438357 184a229a8cc4
push id34717
push usershindli@mozilla.com
push dateWed, 26 Sep 2018 21:52:33 +0000
treeherdermozilla-central@7ac88abc3c57 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdao
bugs1451715
milestone64.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 1451715 - Rename {get,set,delete}{Window,Global}Value to match {get,set,delete}CustomTabValue. r=dao
browser/components/extensions/parent/ext-sessions.js
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/test/browser_345898.js
browser/components/sessionstore/test/browser_350525.js
browser/components/sessionstore/test/browser_394759_basic.js
browser/components/sessionstore/test/browser_394759_perwindowpb.js
browser/components/sessionstore/test/browser_465223.js
browser/components/sessionstore/test/browser_477657.js
browser/components/sessionstore/test/browser_524745.js
browser/components/sessionstore/test/browser_dying_cache.js
browser/components/sessionstore/test/browser_global_store.js
--- a/browser/components/extensions/parent/ext-sessions.js
+++ b/browser/components/extensions/parent/ext-sessions.js
@@ -177,36 +177,36 @@ this.sessions = class extends ExtensionA
 
           SessionStore.deleteCustomTabValue(tab, encodedKey);
         },
 
         setWindowValue(windowId, key, value) {
           let {win, encodedKey} =
             getWindowParams(extension.id, key, windowId, context);
 
-          SessionStore.setWindowValue(win, encodedKey, JSON.stringify(value));
+          SessionStore.setCustomWindowValue(win, encodedKey, JSON.stringify(value));
         },
 
         async getWindowValue(windowId, key) {
           let {win, encodedKey} =
             getWindowParams(extension.id, key, windowId, context);
 
-          let value = SessionStore.getWindowValue(win, encodedKey);
+          let value = SessionStore.getCustomWindowValue(win, encodedKey);
           if (value) {
             return JSON.parse(value);
           }
 
           return undefined;
         },
 
         removeWindowValue(windowId, key) {
           let {win, encodedKey} =
             getWindowParams(extension.id, key, windowId, context);
 
-          SessionStore.deleteWindowValue(win, encodedKey);
+          SessionStore.deleteCustomWindowValue(win, encodedKey);
         },
 
         onChanged: new EventManager({
           context,
           name: "sessions.onChanged",
           register: fire => {
             let observer = () => {
               fire.async();
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -295,26 +295,26 @@ var SessionStore = {
   undoCloseWindow: function ss_undoCloseWindow(aIndex) {
     return SessionStoreInternal.undoCloseWindow(aIndex);
   },
 
   forgetClosedWindow: function ss_forgetClosedWindow(aIndex) {
     return SessionStoreInternal.forgetClosedWindow(aIndex);
   },
 
-  getWindowValue: function ss_getWindowValue(aWindow, aKey) {
-    return SessionStoreInternal.getWindowValue(aWindow, aKey);
-  },
-
-  setWindowValue: function ss_setWindowValue(aWindow, aKey, aStringValue) {
-    SessionStoreInternal.setWindowValue(aWindow, aKey, aStringValue);
-  },
-
-  deleteWindowValue: function ss_deleteWindowValue(aWindow, aKey) {
-    SessionStoreInternal.deleteWindowValue(aWindow, aKey);
+  getCustomWindowValue(aWindow, aKey) {
+    return SessionStoreInternal.getCustomWindowValue(aWindow, aKey);
+  },
+
+  setCustomWindowValue(aWindow, aKey, aStringValue) {
+    SessionStoreInternal.setCustomWindowValue(aWindow, aKey, aStringValue);
+  },
+
+  deleteCustomWindowValue(aWindow, aKey) {
+    SessionStoreInternal.deleteCustomWindowValue(aWindow, aKey);
   },
 
   getCustomTabValue(aTab, aKey) {
     return SessionStoreInternal.getCustomTabValue(aTab, aKey);
   },
 
   setCustomTabValue(aTab, aKey, aStringValue) {
     SessionStoreInternal.setCustomTabValue(aTab, aKey, aStringValue);
@@ -323,26 +323,26 @@ var SessionStore = {
   deleteCustomTabValue(aTab, aKey) {
     SessionStoreInternal.deleteCustomTabValue(aTab, aKey);
   },
 
   getLazyTabValue(aTab, aKey) {
     return SessionStoreInternal.getLazyTabValue(aTab, aKey);
   },
 
-  getGlobalValue: function ss_getGlobalValue(aKey) {
-    return SessionStoreInternal.getGlobalValue(aKey);
-  },
-
-  setGlobalValue: function ss_setGlobalValue(aKey, aStringValue) {
-    SessionStoreInternal.setGlobalValue(aKey, aStringValue);
-  },
-
-  deleteGlobalValue: function ss_deleteGlobalValue(aKey) {
-    SessionStoreInternal.deleteGlobalValue(aKey);
+  getCustomGlobalValue(aKey) {
+    return SessionStoreInternal.getCustomGlobalValue(aKey);
+  },
+
+  setCustomGlobalValue(aKey, aStringValue) {
+    SessionStoreInternal.setCustomGlobalValue(aKey, aStringValue);
+  },
+
+  deleteCustomGlobalValue(aKey) {
+    SessionStoreInternal.deleteCustomGlobalValue(aKey);
   },
 
   persistTabAttribute: function ss_persistTabAttribute(aName) {
     SessionStoreInternal.persistTabAttribute(aName);
   },
 
   restoreLastSession: function ss_restoreLastSession() {
     SessionStoreInternal.restoreLastSession();
@@ -2602,46 +2602,46 @@ var SessionStoreInternal = {
     let winData = this._closedWindows[aIndex];
     this._removeClosedWindow(aIndex);
     this._saveableClosedWindowData.delete(winData);
 
     // Notify of changes to closed objects.
     this._notifyOfClosedObjectsChange();
   },
 
-  getWindowValue: function ssi_getWindowValue(aWindow, aKey) {
+  getCustomWindowValue(aWindow, aKey) {
     if ("__SSi" in aWindow) {
       let data = this._windows[aWindow.__SSi].extData || {};
       return data[aKey] || "";
     }
 
     if (DyingWindowCache.has(aWindow)) {
       let data = DyingWindowCache.get(aWindow).extData || {};
       return data[aKey] || "";
     }
 
     throw Components.Exception("Window is not tracked", Cr.NS_ERROR_INVALID_ARG);
   },
 
-  setWindowValue: function ssi_setWindowValue(aWindow, aKey, aStringValue) {
+  setCustomWindowValue(aWindow, aKey, aStringValue) {
     if (typeof aStringValue != "string") {
-      throw new TypeError("setWindowValue only accepts string values");
+      throw new TypeError("setCustomWindowValue only accepts string values");
     }
 
     if (!("__SSi" in aWindow)) {
       throw Components.Exception("Window is not tracked", Cr.NS_ERROR_INVALID_ARG);
     }
     if (!this._windows[aWindow.__SSi].extData) {
       this._windows[aWindow.__SSi].extData = {};
     }
     this._windows[aWindow.__SSi].extData[aKey] = aStringValue;
     this.saveStateDelayed(aWindow);
   },
 
-  deleteWindowValue: function ssi_deleteWindowValue(aWindow, aKey) {
+  deleteCustomWindowValue(aWindow, aKey) {
     if (aWindow.__SSi && this._windows[aWindow.__SSi].extData &&
         this._windows[aWindow.__SSi].extData[aKey])
       delete this._windows[aWindow.__SSi].extData[aKey];
     this.saveStateDelayed(aWindow);
   },
 
   getCustomTabValue(aTab, aKey) {
     return (TAB_CUSTOM_VALUES.get(aTab) || {})[aKey] || "";
@@ -2678,30 +2678,30 @@ var SessionStoreInternal = {
    *        The tabbrowser-tab the data is for.
    * @param aKey (string)
    *        The key which maps to the desired data.
    */
   getLazyTabValue(aTab, aKey) {
     return (TAB_LAZY_STATES.get(aTab) || {})[aKey];
   },
 
-  getGlobalValue: function ssi_getGlobalValue(aKey) {
+  getCustomGlobalValue(aKey) {
     return this._globalState.get(aKey);
   },
 
-  setGlobalValue: function ssi_setGlobalValue(aKey, aStringValue) {
+  setCustomGlobalValue(aKey, aStringValue) {
     if (typeof aStringValue != "string") {
-      throw new TypeError("setGlobalValue only accepts string values");
+      throw new TypeError("setCustomGlobalValue only accepts string values");
     }
 
     this._globalState.set(aKey, aStringValue);
     this.saveStateDelayed();
   },
 
-  deleteGlobalValue: function ssi_deleteGlobalValue(aKey) {
+  deleteCustomGlobalValue(aKey) {
     this._globalState.delete(aKey);
     this.saveStateDelayed();
   },
 
   persistTabAttribute: function ssi_persistTabAttribute(aName) {
     if (TabAttributes.persist(aName)) {
       this.saveStateDelayed();
     }
--- a/browser/components/sessionstore/test/browser_345898.js
+++ b/browser/components/sessionstore/test/browser_345898.js
@@ -31,15 +31,15 @@ function test() {
     /NS_ERROR_ILLEGAL_VALUE/,
     "Invalid window for getClosedTabData throws");
   Assert.throws(() => ss.undoCloseTab({}, 0),
     /NS_ERROR_ILLEGAL_VALUE/,
     "Invalid window for undoCloseTab throws");
   Assert.throws(() => ss.undoCloseTab(window, -1),
     /NS_ERROR_ILLEGAL_VALUE/,
     "Invalid index for undoCloseTab throws");
-  Assert.throws(() => ss.getWindowValue({}, ""),
+  Assert.throws(() => ss.getCustomWindowValue({}, ""),
     /NS_ERROR_ILLEGAL_VALUE/,
-    "Invalid window for getWindowValue throws");
-  Assert.throws(() => ss.setWindowValue({}, "", ""),
+    "Invalid window for getCustomWindowValue throws");
+  Assert.throws(() => ss.setCustomWindowValue({}, "", ""),
     /NS_ERROR_ILLEGAL_VALUE/,
-    "Invalid window for setWindowValue throws");
+    "Invalid window for setCustomWindowValue throws");
 }
--- a/browser/components/sessionstore/test/browser_350525.js
+++ b/browser/components/sessionstore/test/browser_350525.js
@@ -12,35 +12,35 @@ add_task(async function() {
   function test(aLambda) {
     try {
       return aLambda() || true;
     } catch (ex) { }
     return false;
   }
 
   /**
-   * setWindowValue, et al.
+   * setCustomWindowValue, et al.
    */
   let key = "Unique name: " + Date.now();
   let value = "Unique value: " + Math.random();
 
   // test adding
-  ok(test(() => ss.setWindowValue(window, key, value)), "set a window value");
+  ok(test(() => ss.setCustomWindowValue(window, key, value)), "set a window value");
 
   // test retrieving
-  is(ss.getWindowValue(window, key), value, "stored window value matches original");
+  is(ss.getCustomWindowValue(window, key), value, "stored window value matches original");
 
   // test deleting
-  ok(test(() => ss.deleteWindowValue(window, key)), "delete the window value");
+  ok(test(() => ss.deleteCustomWindowValue(window, key)), "delete the window value");
 
   // value should not exist post-delete
-  is(ss.getWindowValue(window, key), "", "window value was deleted");
+  is(ss.getCustomWindowValue(window, key), "", "window value was deleted");
 
   // test deleting a non-existent value
-  ok(test(() => ss.deleteWindowValue(window, key)), "delete non-existent window value");
+  ok(test(() => ss.deleteCustomWindowValue(window, key)), "delete non-existent window value");
 
   /**
    * setCustomTabValue, et al.
    */
   key = "Unique name: " + Math.random();
   value = "Unique value: " + Date.now();
   let tab = BrowserTestUtils.addTab(gBrowser);
   tab.linkedBrowser.stop();
--- a/browser/components/sessionstore/test/browser_394759_basic.js
+++ b/browser/components/sessionstore/test/browser_394759_basic.js
@@ -23,17 +23,17 @@ function test() {
 
   // Clear the list of closed windows.
   forgetClosedWindows();
 
   provideWindow(function onTestURLLoaded(newWin) {
     BrowserTestUtils.addTab(newWin.gBrowser).linkedBrowser.stop();
 
     // Mark the window with some unique data to be restored later on.
-    ss.setWindowValue(newWin, uniqueKey, uniqueValue);
+    ss.setCustomWindowValue(newWin, uniqueKey, uniqueValue);
     let [txt] = newWin.content.document.querySelectorAll("#txt");
     txt.value = uniqueText;
 
     let browser = newWin.gBrowser.selectedBrowser;
     setInputChecked(browser, {id: "chk", checked: true}).then(() => {
       BrowserTestUtils.closeWindow(newWin).then(() => {
         is(ss.getClosedWindowCount(), 1,
            "The closed window was added to Recently Closed Windows");
@@ -72,17 +72,17 @@ function test() {
              "The window correctly restored 2 tabs");
           is(newWin2.gBrowser.currentURI.spec, TEST_URL,
              "The window correctly restored the URL");
 
           let chk;
           [txt, chk] = newWin2.content.document.querySelectorAll("#txt, #chk");
           ok(txt.value == uniqueText && chk.checked,
              "The window correctly restored the form");
-          is(ss.getWindowValue(newWin2, uniqueKey), uniqueValue,
+          is(ss.getCustomWindowValue(newWin2, uniqueKey), uniqueValue,
              "The window correctly restored the data associated with it");
 
           // Clean up.
           BrowserTestUtils.closeWindow(newWin2).then(finish);
         }, true);
       });
     });
   }, TEST_URL);
--- a/browser/components/sessionstore/test/browser_394759_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_394759_perwindowpb.js
@@ -14,17 +14,17 @@ const TESTS = [
 ];
 
 function promiseTestOpenCloseWindow(aIsPrivate, aTest) {
   return (async function() {
     let win = await BrowserTestUtils.openNewBrowserWindow({ "private": aIsPrivate });
     BrowserTestUtils.loadURI(win.gBrowser.selectedBrowser, aTest.url);
     await promiseBrowserLoaded(win.gBrowser.selectedBrowser, true, aTest.url);
     // Mark the window with some unique data to be restored later on.
-    ss.setWindowValue(win, aTest.key, aTest.value);
+    ss.setCustomWindowValue(win, aTest.key, aTest.value);
     await TabStateFlusher.flushWindow(win);
     // Close.
     await BrowserTestUtils.closeWindow(win);
   })();
 }
 
 function promiseTestOnWindow(aIsPrivate, aValue) {
   return (async function() {
--- a/browser/components/sessionstore/test/browser_465223.js
+++ b/browser/components/sessionstore/test/browser_465223.js
@@ -8,34 +8,34 @@ add_task(async function test_clearWindow
   let uniqueKey1 = "bug 465223.1";
   let uniqueKey2 = "bug 465223.2";
   let uniqueValue1 = "unik" + Date.now();
   let uniqueValue2 = "pi != " + Math.random();
 
   // open a window and set a value on it
   let newWin = openDialog(location, "_blank", "chrome,all,dialog=no");
   await promiseWindowLoaded(newWin);
-  ss.setWindowValue(newWin, uniqueKey1, uniqueValue1);
+  ss.setCustomWindowValue(newWin, uniqueKey1, uniqueValue1);
 
   let newState = { windows: [{ tabs: [{ entries: [] }], extData: {} }] };
   newState.windows[0].extData[uniqueKey2] = uniqueValue2;
   await setWindowState(newWin, newState);
 
   is(newWin.gBrowser.tabs.length, 2,
     "original tab wasn't overwritten");
-  is(ss.getWindowValue(newWin, uniqueKey1), uniqueValue1,
+  is(ss.getCustomWindowValue(newWin, uniqueKey1), uniqueValue1,
     "window value wasn't overwritten when the tabs weren't");
-  is(ss.getWindowValue(newWin, uniqueKey2), uniqueValue2,
+  is(ss.getCustomWindowValue(newWin, uniqueKey2), uniqueValue2,
     "new window value was correctly added");
 
   newState.windows[0].extData[uniqueKey2] = uniqueValue1;
   await setWindowState(newWin, newState, true);
 
   is(newWin.gBrowser.tabs.length, 1,
     "original tabs were overwritten");
-  is(ss.getWindowValue(newWin, uniqueKey1), "",
+  is(ss.getCustomWindowValue(newWin, uniqueKey1), "",
     "window value was cleared");
-  is(ss.getWindowValue(newWin, uniqueKey2), uniqueValue1,
+  is(ss.getCustomWindowValue(newWin, uniqueKey2), uniqueValue1,
     "window value was correctly overwritten");
 
   // clean up
   await BrowserTestUtils.closeWindow(newWin);
 });
--- a/browser/components/sessionstore/test/browser_477657.js
+++ b/browser/components/sessionstore/test/browser_477657.js
@@ -13,25 +13,25 @@ add_task(async function test_sizemodeDef
       title: "About:",
     }],
     sizemode: "maximized",
   }] };
 
   let uniqueKey = "bug 477657";
   let uniqueValue = "unik" + Date.now();
 
-  ss.setWindowValue(newWin, uniqueKey, uniqueValue);
-  is(ss.getWindowValue(newWin, uniqueKey), uniqueValue,
+  ss.setCustomWindowValue(newWin, uniqueKey, uniqueValue);
+  is(ss.getCustomWindowValue(newWin, uniqueKey), uniqueValue,
      "window value was set before the window was overwritten");
 
   await setWindowState(newWin, newState, true);
   // use newWin.setTimeout(..., 0) to mirror sss_restoreWindowFeatures
   await new Promise(resolve => newWin.setTimeout(resolve, 0));
 
-  is(ss.getWindowValue(newWin, uniqueKey), "",
+  is(ss.getCustomWindowValue(newWin, uniqueKey), "",
     "window value was implicitly cleared");
 
   is(newWin.windowState, newWin.STATE_MAXIMIZED,
     "the window was maximized");
 
   is(JSON.parse(ss.getClosedTabData(newWin)).length, 1,
     "the closed tab was added before the window was overwritten");
   delete newState.windows[0]._closedTabs;
--- a/browser/components/sessionstore/test/browser_524745.js
+++ b/browser/components/sessionstore/test/browser_524745.js
@@ -8,17 +8,17 @@ function test() {
   let uniqKey = "bug524745";
   let uniqVal = Date.now().toString();
 
   waitForExplicitFinish();
 
   whenNewWindowLoaded({ private: false }, function(window_B) {
     waitForFocus(function() {
       // Add identifying information to window_B
-      ss.setWindowValue(window_B, uniqKey, uniqVal);
+      ss.setCustomWindowValue(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");
 
       // Now minimize window_B. The selected window shouldn't have the secret data
       window_B.minimize();
       waitForFocus(function() {
--- a/browser/components/sessionstore/test/browser_dying_cache.js
+++ b/browser/components/sessionstore/test/browser_dying_cache.js
@@ -19,46 +19,46 @@ add_task(async function test() {
   let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
   await promiseBrowserLoaded(tab.linkedBrowser);
   await TabStateFlusher.flush(tab.linkedBrowser);
   await promiseRemoveTabAndSessionState(win.gBrowser.tabs[0]);
 
   // Make sure our window is still tracked by sessionstore
   // and the window state is as expected.
   ok("__SSi" in win, "window is being tracked by sessionstore");
-  ss.setWindowValue(win, "foo", "bar");
+  ss.setCustomWindowValue(win, "foo", "bar");
   checkWindowState(win);
 
   // Close our window.
   await BrowserTestUtils.closeWindow(win);
 
   // SessionStore should no longer track our window
   // but it should still report the same state.
   ok(!("__SSi" in win), "sessionstore does no longer track our window");
   checkWindowState(win);
 
   // Make sure we're not allowed to modify state data.
   Assert.throws(() => ss.setWindowState(win, {}),
     /Window is not tracked/,
     "we're not allowed to modify state data anymore");
-  Assert.throws(() => ss.setWindowValue(win, "foo", "baz"),
+  Assert.throws(() => ss.setCustomWindowValue(win, "foo", "baz"),
     /Window is not tracked/,
     "we're not allowed to modify state data anymore");
 });
 
 function checkWindowState(window) {
   let {windows: [{tabs}]} = JSON.parse(ss.getWindowState(window));
   is(tabs.length, 1, "the window has a single tab");
   is(tabs[0].entries[0].url, "about:mozilla", "the tab is about:mozilla");
 
   is(ss.getClosedTabCount(window), 1, "the window has one closed tab");
   let [{state: {entries: [{url}]}}] = JSON.parse(ss.getClosedTabData(window));
   is(url, "about:robots", "the closed tab is about:robots");
 
-  is(ss.getWindowValue(window, "foo"), "bar", "correct extData value");
+  is(ss.getCustomWindowValue(window, "foo"), "bar", "correct extData value");
 }
 
 function shouldThrow(f) {
   try {
     f();
   } catch (e) {
     return true;
   }
--- a/browser/components/sessionstore/test/browser_global_store.js
+++ b/browser/components/sessionstore/test/browser_global_store.js
@@ -18,28 +18,28 @@ add_task(async function() {
           { entries: [{ url: "about:blank", triggeringPrincipal_base64 }] },
         ],
       },
     ],
     global,
   };
 
   function testRestoredState() {
-    is(ss.getGlobalValue(key1), value1, "restored state has global value");
+    is(ss.getCustomGlobalValue(key1), value1, "restored state has global value");
   }
 
   function testGlobalStore() {
-    is(ss.getGlobalValue(key2), "", "global value initially not set");
+    is(ss.getCustomGlobalValue(key2), "", "global value initially not set");
 
-    ss.setGlobalValue(key2, value1);
-    is(ss.getGlobalValue(key2), value1, "retreived value matches stored");
+    ss.setCustomGlobalValue(key2, value1);
+    is(ss.getCustomGlobalValue(key2), value1, "retreived value matches stored");
 
-    ss.setGlobalValue(key2, value2);
-    is(ss.getGlobalValue(key2), value2, "previously stored value was overwritten");
+    ss.setCustomGlobalValue(key2, value2);
+    is(ss.getCustomGlobalValue(key2), value2, "previously stored value was overwritten");
 
-    ss.deleteGlobalValue(key2);
-    is(ss.getGlobalValue(key2), "", "global value was deleted");
+    ss.deleteCustomGlobalValue(key2);
+    is(ss.getCustomGlobalValue(key2), "", "global value was deleted");
   }
 
   await promiseBrowserState(testState);
   testRestoredState();
   testGlobalStore();
 });