Bug 1207491 - Part 16: Remove use of expression closure from browser/components/sessionstore/. r=Gijs
authorTooru Fujisawa <arai_a@mac.com>
Wed, 23 Sep 2015 18:36:23 +0900
changeset 264353 1679566f98dc874a31ac2aea4eff3a64a5a90288
parent 264352 e215e87f3960667b69225d7b44a59ab988170ada
child 264354 c0aed1d0eed67b0a3f3ecb11949de7ffb9386e6b
push id65606
push userarai_a@mac.com
push dateFri, 25 Sep 2015 08:14:49 +0000
treeherdermozilla-inbound@e4f5f909df68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1207491
milestone44.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 1207491 - Part 16: Remove use of expression closure from browser/components/sessionstore/. r=Gijs
browser/components/sessionstore/SessionStore.jsm
browser/components/sessionstore/test/browser_248970_b_perwindowpb.js
browser/components/sessionstore/test/browser_345898.js
browser/components/sessionstore/test/browser_350525.js
browser/components/sessionstore/test/browser_354894_perwindowpb.js
browser/components/sessionstore/test/browser_394759_purge.js
browser/components/sessionstore/test/browser_461634.js
browser/components/sessionstore/test/browser_464199.js
browser/components/sessionstore/test/browser_491577.js
browser/components/sessionstore/test/browser_588426.js
browser/components/sessionstore/test/browser_589246.js
browser/components/sessionstore/test/browser_590563.js
browser/components/sessionstore/test/browser_595601-restore_hidden.js
browser/components/sessionstore/test/browser_599909.js
browser/components/sessionstore/test/browser_659591.js
browser/components/sessionstore/test/browser_701377.js
browser/components/sessionstore/test/browser_705597.js
browser/components/sessionstore/test/browser_707862.js
--- a/browser/components/sessionstore/SessionStore.jsm
+++ b/browser/components/sessionstore/SessionStore.jsm
@@ -3307,18 +3307,18 @@ var SessionStoreInternal = {
   /**
    * whether the user wants to load any other page at startup
    * (except the homepage) - needed for determining whether to overwrite the current tabs
    * C.f.: nsBrowserContentHandler's defaultArgs implementation.
    * @returns bool
    */
   _isCmdLineEmpty: function ssi_isCmdLineEmpty(aWindow, aState) {
     var pinnedOnly = aState.windows &&
-                     aState.windows.every(function (win)
-                       win.tabs.every(function (tab) tab.pinned));
+                     aState.windows.every(win =>
+                       win.tabs.every(tab => tab.pinned));
 
     let hasFirstArgument = aWindow.arguments && aWindow.arguments[0];
     if (!pinnedOnly) {
       let defaultArgs = Cc["@mozilla.org/browser/clh;1"].
                         getService(Ci.nsIBrowserHandler).defaultArgs;
       if (aWindow.arguments &&
           aWindow.arguments[0] &&
           aWindow.arguments[0] == defaultArgs)
--- a/browser/components/sessionstore/test/browser_248970_b_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_248970_b_perwindowpb.js
@@ -49,32 +49,32 @@ function test() {
     let node = getElementByXPath(aTab, aQuery);
     if (typeof aValue == "string")
       node.value = aValue;
     else if (typeof aValue == "boolean")
       node.checked = aValue;
     else if (typeof aValue == "number")
       node.selectedIndex = aValue;
     else
-      Array.forEach(node.options, function(aOpt, aIx)
+      Array.forEach(node.options, (aOpt, aIx) =>
         (aOpt.selected = aValue.indexOf(aIx) > -1));
   }
 
   function compareFormValue(aTab, aQuery, aValue) {
     let node = getElementByXPath(aTab, aQuery);
     if (!node)
       return false;
     if (node instanceof Ci.nsIDOMHTMLInputElement)
       return aValue == (node.type == "checkbox" || node.type == "radio" ?
                        node.checked : node.value);
     if (node instanceof Ci.nsIDOMHTMLTextAreaElement)
       return aValue == node.value;
     if (!node.multiple)
       return aValue == node.selectedIndex;
-    return Array.every(node.options, function(aOpt, aIx)
+    return Array.every(node.options, (aOpt, aIx) =>
             (aValue.indexOf(aIx) > -1) == aOpt.selected);
   }
 
   //////////////////////////////////////////////////////////////////
   // Test (B) : Session data restoration between windows          //
   //////////////////////////////////////////////////////////////////
 
   let rootDir = getRootDirectory(gTestPath);
@@ -112,17 +112,17 @@ function test() {
       // public session, close tab: (A)
       aWin.gBrowser.removeTab(tab_A);
 
       // verify that closedTabCount increased
       ok(ss.getClosedTabCount(aWin) > count,
          "getClosedTabCount has increased after closing a tab");
 
       // verify tab: (A), in undo list
-      let tab_A_restored = test(function() ss.undoCloseTab(aWin, 0));
+      let tab_A_restored = test(() => ss.undoCloseTab(aWin, 0));
       ok(tab_A_restored, "a tab is in undo list");
       promiseTabRestored(tab_A_restored).then(() => {
         is(testURL, tab_A_restored.linkedBrowser.currentURI.spec,
            "it's the same tab that we expect");
         aWin.gBrowser.removeTab(tab_A_restored);
 
         whenNewWindowLoaded({ private: true }, function(aWin) {
           windowsToClose.push(aWin);
--- a/browser/components/sessionstore/test/browser_345898.js
+++ b/browser/components/sessionstore/test/browser_345898.js
@@ -12,33 +12,33 @@ function test() {
     }
     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(function() ss.getWindowState({})),
+  ok(test(() => ss.getWindowState({})),
      "Invalid window for getWindowState throws");
-  ok(test(function() ss.setWindowState({}, "", false)),
+  ok(test(() => ss.setWindowState({}, "", false)),
      "Invalid window for setWindowState throws");
-  ok(test(function() ss.getTabState({})),
+  ok(test(() => ss.getTabState({})),
      "Invalid tab for getTabState throws");
-  ok(test(function() ss.setTabState({}, "{}")),
+  ok(test(() => ss.setTabState({}, "{}")),
      "Invalid tab state for setTabState throws");
-  ok(test(function() ss.setTabState({}, JSON.stringify({ entries: [] }))),
+  ok(test(() => ss.setTabState({}, JSON.stringify({ entries: [] }))),
      "Invalid tab for setTabState throws");
-  ok(test(function() ss.duplicateTab({}, {})),
+  ok(test(() => ss.duplicateTab({}, {})),
      "Invalid tab for duplicateTab throws");
-  ok(test(function() ss.duplicateTab({}, gBrowser.selectedTab)),
+  ok(test(() => ss.duplicateTab({}, gBrowser.selectedTab)),
      "Invalid window for duplicateTab throws");
-  ok(test(function() ss.getClosedTabData({})),
+  ok(test(() => ss.getClosedTabData({})),
      "Invalid window for getClosedTabData throws");
-  ok(test(function() ss.undoCloseTab({}, 0)),
+  ok(test(() => ss.undoCloseTab({}, 0)),
      "Invalid window for undoCloseTab throws");
-  ok(test(function() ss.undoCloseTab(window, -1)),
+  ok(test(() => ss.undoCloseTab(window, -1)),
      "Invalid index for undoCloseTab throws");
-  ok(test(function() ss.getWindowValue({}, "")),
+  ok(test(() => ss.getWindowValue({}, "")),
      "Invalid window for getWindowValue throws");
-  ok(test(function() ss.setWindowValue({}, "", "")),
+  ok(test(() => ss.setWindowValue({}, "", "")),
      "Invalid window for setWindowValue throws");
 }
--- a/browser/components/sessionstore/test/browser_350525.js
+++ b/browser/components/sessionstore/test/browser_350525.js
@@ -13,52 +13,52 @@ add_task(function* () {
 
   ////////////////////////////
   // setWindowValue, et al. //
   ////////////////////////////
   let key = "Unique name: " + Date.now();
   let value = "Unique value: " + Math.random();
 
   // test adding
-  ok(test(function() ss.setWindowValue(window, key, value)), "set a window value");
+  ok(test(() => ss.setWindowValue(window, key, value)), "set a window value");
 
   // test retrieving
   is(ss.getWindowValue(window, key), value, "stored window value matches original");
 
   // test deleting
-  ok(test(function() ss.deleteWindowValue(window, key)), "delete the window value");
+  ok(test(() => ss.deleteWindowValue(window, key)), "delete the window value");
 
   // value should not exist post-delete
   is(ss.getWindowValue(window, key), "", "window value was deleted");
 
   // test deleting a non-existent value
-  ok(test(function() ss.deleteWindowValue(window, key)), "delete non-existent window value");
+  ok(test(() => ss.deleteWindowValue(window, key)), "delete non-existent window value");
 
   /////////////////////////
   // setTabValue, et al. //
   /////////////////////////
   key = "Unique name: " + Math.random();
   value = "Unique value: " + Date.now();
   let tab = gBrowser.addTab();
   tab.linkedBrowser.stop();
 
   // test adding
-  ok(test(function() ss.setTabValue(tab, key, value)), "store a tab value");
+  ok(test(() => ss.setTabValue(tab, key, value)), "store a tab value");
 
   // test retrieving
   is(ss.getTabValue(tab, key), value, "stored tab value match original");
 
   // test deleting
-  ok(test(function() ss.deleteTabValue(tab, key)), "delete the tab value");
+  ok(test(() => ss.deleteTabValue(tab, key)), "delete the tab value");
 
   // value should not exist post-delete
   is(ss.getTabValue(tab, key), "", "tab value was deleted");
 
   // test deleting a non-existent value
-  ok(test(function() ss.deleteTabValue(tab, key)), "delete non-existent tab value");
+  ok(test(() => ss.deleteTabValue(tab, key)), "delete non-existent tab value");
 
   // clean up
   yield promiseRemoveTab(tab);
 
   /////////////////////////////////////
   // getClosedTabCount, undoCloseTab //
   /////////////////////////////////////
 
@@ -80,17 +80,17 @@ add_task(function* () {
   // remove tab
   yield promiseRemoveTab(tab);
 
   // getClosedTabCount
   let newcount = ss.getClosedTabCount(window);
   ok(newcount > count, "after closing a tab, getClosedTabCount has been incremented");
 
   // undoCloseTab
-  tab = test(function() ss.undoCloseTab(window, 0));
+  tab = test(() => ss.undoCloseTab(window, 0));
   ok(tab, "undoCloseTab doesn't throw")
 
   yield promiseTabRestored(tab);
   is(tab.linkedBrowser.currentURI.spec, testURL, "correct tab was reopened");
 
   // clean up
   gBrowser.removeTab(tab);
 });
--- a/browser/components/sessionstore/test/browser_354894_perwindowpb.js
+++ b/browser/components/sessionstore/test/browser_354894_perwindowpb.js
@@ -431,17 +431,17 @@ function test() {
         ok(!newWin.closed, "First close attempt denied");
         if (!newWin.closed) {
           newWin.BrowserTryToCloseWindow();
           ok(newWin.closed, "Second close attempt granted");
         }
       }
 
       if (iteration < NOTIFICATIONS_EXPECTED - 1) {
-        executeSoon(function() testMacNotifications(nextFn, ++iteration));
+        executeSoon(() => testMacNotifications(nextFn, ++iteration));
       }
       else {
         executeSoon(nextFn);
       }
     });
   }
 
   // Execution starts here
--- a/browser/components/sessionstore/test/browser_394759_purge.js
+++ b/browser/components/sessionstore/test/browser_394759_purge.js
@@ -12,21 +12,23 @@ function waitForClearHistory(aCallback) 
     }
   };
   Services.obs.addObserver(observer, "browser:purge-domain-data", false);
 }
 
 function test() {
   waitForExplicitFinish();
   // utility functions
-  function countClosedTabsByTitle(aClosedTabList, aTitle)
-    aClosedTabList.filter(function (aData) aData.title == aTitle).length;
+  function countClosedTabsByTitle(aClosedTabList, aTitle) {
+    return aClosedTabList.filter(aData => aData.title == aTitle).length;
+  }
 
-  function countOpenTabsByTitle(aOpenTabList, aTitle)
-    aOpenTabList.filter(function (aData) aData.entries.some(function (aEntry) aEntry.title == aTitle)).length
+  function countOpenTabsByTitle(aOpenTabList, aTitle) {
+    return aOpenTabList.filter(aData => aData.entries.some(aEntry => aEntry.title == aTitle)).length;
+  }
 
   // backup old state
   let oldState = ss.getBrowserState();
   let oldState_wins = JSON.parse(oldState).windows.length;
   if (oldState_wins != 1)
     ok(false, "oldState in test_purge has " + oldState_wins + " windows instead of 1");
 
   // create a new state for testing
--- a/browser/components/sessionstore/test/browser_461634.js
+++ b/browser/components/sessionstore/test/browser_461634.js
@@ -11,18 +11,19 @@ function test() {
   let test_state = { windows: [{ "tabs": [{ "entries": [] }], _closedTabs: [
     { state: { entries: [{ url: "http://www.example.net/" }] }, title: FORGET },
     { state: { entries: [{ url: "http://www.example.net/" }] }, title: REMEMBER },
     { state: { entries: [{ url: "http://www.example.net/" }] }, title: FORGET },
     { state: { entries: [{ url: "http://www.example.net/" }] }, title: REMEMBER },
   ] }] };
   let remember_count = 2;
 
-  function countByTitle(aClosedTabList, aTitle)
-    aClosedTabList.filter(function(aData) aData.title == aTitle).length;
+  function countByTitle(aClosedTabList, aTitle) {
+    return aClosedTabList.filter(aData => aData.title == aTitle).length;
+  }
 
   function testForError(aFunction) {
     try {
       aFunction();
       return false;
     }
     catch (ex) {
       return ex.name == "NS_ERROR_ILLEGAL_VALUE";
@@ -41,21 +42,21 @@ function test() {
        "Closed tab list has the expected length");
     is(countByTitle(closedTabs, FORGET),
        test_state.windows[0]._closedTabs.length - remember_count,
        "The correct amout of tabs are to be forgotten");
     is(countByTitle(closedTabs, REMEMBER), remember_count,
        "Everything is set up.");
 
     // all of the following calls with illegal arguments should throw NS_ERROR_ILLEGAL_VALUE
-    ok(testForError(function() ss.forgetClosedTab({}, 0)),
+    ok(testForError(() => ss.forgetClosedTab({}, 0)),
        "Invalid window for forgetClosedTab throws");
-    ok(testForError(function() ss.forgetClosedTab(newWin, -1)),
+    ok(testForError(() => ss.forgetClosedTab(newWin, -1)),
        "Invalid tab for forgetClosedTab throws");
-    ok(testForError(function() ss.forgetClosedTab(newWin, test_state.windows[0]._closedTabs.length + 1)),
+    ok(testForError(() => ss.forgetClosedTab(newWin, test_state.windows[0]._closedTabs.length + 1)),
        "Invalid tab for forgetClosedTab throws");
 
     // Remove third tab, then first tab
     ss.forgetClosedTab(newWin, 2);
     ss.forgetClosedTab(newWin, null);
 
     closedTabs = JSON.parse(ss.getClosedTabData(newWin));
     is(closedTabs.length, remember_count,
--- a/browser/components/sessionstore/test/browser_464199.js
+++ b/browser/components/sessionstore/test/browser_464199.js
@@ -42,18 +42,19 @@ function test() {
     { state: { entries: [{ url: "http://www.example.org/form",
                            formdata: { id: { "url": "http://www.example.net/" } }
                          }] }, title: REMEMBER },
     { state: { entries: [{ url: "http://www.example.org/form" }],
                extData: { "setTabValue": "http://example.net:80" } }, title: REMEMBER }
   ] }] };
   let remember_count = 5;
 
-  function countByTitle(aClosedTabList, aTitle)
-    aClosedTabList.filter(function(aData) aData.title == aTitle).length;
+  function countByTitle(aClosedTabList, aTitle) {
+    return aClosedTabList.filter(aData => aData.title == aTitle).length;
+  }
 
   // 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",
                             test_state.windows[0]._closedTabs.length);
     ss.setWindowState(newWin, JSON.stringify(test_state), true);
 
--- a/browser/components/sessionstore/test/browser_491577.js
+++ b/browser/components/sessionstore/test/browser_491577.js
@@ -60,18 +60,19 @@ function test() {
             title: "title"
           }
         ]
       }
     ]
   };
   let remember_count = 1;
 
-  function countByTitle(aClosedWindowList, aTitle)
-    aClosedWindowList.filter(function(aData) aData.title == aTitle).length;
+  function countByTitle(aClosedWindowList, aTitle) {
+    return aClosedWindowList.filter(aData => aData.title == aTitle).length;
+  }
 
   function testForError(aFunction) {
     try {
       aFunction();
       return false;
     }
     catch (ex) {
       return ex.name == "NS_ERROR_ILLEGAL_VALUE";
@@ -90,19 +91,19 @@ function test() {
        "Closed window list has the expected length");
     is(countByTitle(closedWindows, FORGET),
        test_state._closedWindows.length - remember_count,
        "The correct amount of windows are to be forgotten");
     is(countByTitle(closedWindows, REMEMBER), remember_count,
        "Everything is set up.");
 
     // all of the following calls with illegal arguments should throw NS_ERROR_ILLEGAL_VALUE
-    ok(testForError(function() ss.forgetClosedWindow(-1)),
+    ok(testForError(() => ss.forgetClosedWindow(-1)),
        "Invalid window for forgetClosedWindow throws");
-    ok(testForError(function() ss.forgetClosedWindow(test_state._closedWindows.length + 1)),
+    ok(testForError(() => ss.forgetClosedWindow(test_state._closedWindows.length + 1)),
        "Invalid window for forgetClosedWindow throws");
 
     // Remove third window, then first window
     ss.forgetClosedWindow(2);
     ss.forgetClosedWindow(null);
 
     closedWindows = JSON.parse(ss.getClosedWindowData());
     is(closedWindows.length, remember_count,
--- a/browser/components/sessionstore/test/browser_588426.js
+++ b/browser/components/sessionstore/test/browser_588426.js
@@ -5,17 +5,17 @@ function test() {
   let state = { windows: [{ tabs: [
       {entries: [{url: "about:mozilla"}], hidden: true},
       {entries: [{url: "about:rights"}], hidden: true}
   ] }] };
 
   waitForExplicitFinish();
 
   newWindowWithState(state, function (win) {
-    registerCleanupFunction(function () win.close());
+    registerCleanupFunction(() => win.close());
 
     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");
 
     finish();
--- a/browser/components/sessionstore/test/browser_589246.js
+++ b/browser/components/sessionstore/test/browser_589246.js
@@ -35,17 +35,17 @@ var tests = [];
 function checkOSX34Generator(num) {
   return function(aPreviousState, aCurState) {
     // In here, we should have restored the pinned tab, so only the unpinned tab
     // should be in aCurState. So let's shape our expectations.
     let expectedState = JSON.parse(aPreviousState);
     expectedState[0].tabs.shift();
     // size attributes are stripped out in _prepDataForDeferredRestore in nsSessionStore.
     // This isn't the best approach, but neither is comparing JSON strings
-    WINDOW_ATTRIBUTES.forEach(function (attr) delete expectedState[0][attr]);
+    WINDOW_ATTRIBUTES.forEach(attr => delete expectedState[0][attr]);
 
     is(aCurState, JSON.stringify(expectedState),
        "test #" + num + ": closedWindowState is as expected");
   };
 }
 function checkNoWindowsGenerator(num) {
   return function(aPreviousState, aCurState) {
     is(aCurState, "[]", "test #" + num + ": there should be no closedWindowsLeft");
--- a/browser/components/sessionstore/test/browser_590563.js
+++ b/browser/components/sessionstore/test/browser_590563.js
@@ -12,17 +12,17 @@ function test() {
   };
   let url = "about:sessionrestore";
   let formdata = {id: {sessionData}, url};
   let state = { windows: [{ tabs: [{ entries: [{url}], formdata }] }] };
 
   waitForExplicitFinish();
 
   newWindowWithState(state, function (win) {
-    registerCleanupFunction(function () win.close());
+    registerCleanupFunction(() => win.close());
 
     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 () {
         middleClickTest(win);
         finish();
--- a/browser/components/sessionstore/test/browser_595601-restore_hidden.js
+++ b/browser/components/sessionstore/test/browser_595601-restore_hidden.js
@@ -96,17 +96,17 @@ var TabsProgressListener = {
   }
 }
 
 // ----------
 function newWindowWithState(state, callback) {
   let opts = "chrome,all,dialog=no,height=800,width=800";
   let win = window.openDialog(getBrowserURL(), "_blank", opts);
 
-  registerCleanupFunction(function () win.close());
+  registerCleanupFunction(() => win.close());
 
   whenWindowLoaded(win, function onWindowLoaded(aWin) {
     TabsProgressListener.init(aWin);
     TabsProgressListener.setCallback(callback);
 
     ss.setWindowState(aWin, JSON.stringify(state), true);
   });
 }
--- a/browser/components/sessionstore/test/browser_599909.js
+++ b/browser/components/sessionstore/test/browser_599909.js
@@ -96,17 +96,19 @@ function checkAutocompleteResults(aExpec
       for (let entry in aExpected) {
         ok(false, "'" + entry + "' not found in autocomplete.");
       }
 
       executeSoon(aCallback);
     },
     setSelectedIndex: function() {},
     get searchCount() { return this.searches.length; },
-    getSearchAt: function(aIndex) this.searches[aIndex],
+    getSearchAt: function(aIndex) {
+      return this.searches[aIndex];
+    },
     QueryInterface: XPCOMUtils.generateQI([
       Ci.nsIAutoCompleteInput,
       Ci.nsIAutoCompletePopup,
     ])
   };
 
   info("Searching open pages.");
   gController.startSearch(Services.prefs.getCharPref("browser.urlbar.restrict.openpage"));
--- a/browser/components/sessionstore/test/browser_659591.js
+++ b/browser/components/sessionstore/test/browser_659591.js
@@ -22,11 +22,11 @@ function test() {
 }
 
 function newWindow(callback) {
   let opts = "chrome,all,dialog=no,height=800,width=800";
   let win = window.openDialog(getBrowserURL(), "_blank", opts);
 
   win.addEventListener("load", function onLoad() {
     win.removeEventListener("load", onLoad, false);
-    executeSoon(function () callback(win));
+    executeSoon(() => callback(win));
   }, false);
 }
--- a/browser/components/sessionstore/test/browser_701377.js
+++ b/browser/components/sessionstore/test/browser_701377.js
@@ -9,17 +9,17 @@ var state = {windows:[{tabs:[
 function test() {
   waitForExplicitFinish();
 
   newWindowWithState(state, function (aWindow) {
     let tab = aWindow.gBrowser.tabs[1];
     ok(tab.hidden, "the second tab is hidden");
 
     let tabShown = false;
-    let tabShowCallback = function () tabShown = true;
+    let tabShowCallback = () => tabShown = true;
     tab.addEventListener("TabShow", tabShowCallback, false);
 
     let tabState = ss.getTabState(tab);
     ss.setTabState(tab, tabState);
 
     tab.removeEventListener("TabShow", tabShowCallback, false);
     ok(tab.hidden && !tabShown, "tab remains hidden");
 
@@ -27,15 +27,15 @@ function test() {
   });
 }
 
 // ----------
 function newWindowWithState(aState, aCallback) {
   let opts = "chrome,all,dialog=no,height=800,width=800";
   let win = window.openDialog(getBrowserURL(), "_blank", opts);
 
-  registerCleanupFunction(function () win.close());
+  registerCleanupFunction(() => win.close());
 
   whenWindowLoaded(win, function onWindowLoaded(aWin) {
     ss.setWindowState(aWin, JSON.stringify(aState), true);
-    executeSoon(function () aCallback(aWin));
+    executeSoon(() => aCallback(aWin));
   });
 }
--- a/browser/components/sessionstore/test/browser_705597.js
+++ b/browser/components/sessionstore/test/browser_705597.js
@@ -49,10 +49,10 @@ function test() {
     });
   });
 }
 
 function whenChildCount(aEntry, aChildCount, aCallback) {
   if (aEntry.childCount == aChildCount)
     aCallback();
   else
-    setTimeout(function () whenChildCount(aEntry, aChildCount, aCallback), 100);
+    setTimeout(() => whenChildCount(aEntry, aChildCount, aCallback), 100);
 }
--- a/browser/components/sessionstore/test/browser_707862.js
+++ b/browser/components/sessionstore/test/browser_707862.js
@@ -52,10 +52,10 @@ function test() {
   // let's add a dummy pass.
   ok(true, "Each test requires at least one pass, fail or todo so here is a pass.");
 }
 
 function whenChildCount(aEntry, aChildCount, aCallback) {
   if (aEntry.childCount == aChildCount)
     aCallback();
   else
-    setTimeout(function () whenChildCount(aEntry, aChildCount, aCallback), 100);
+    setTimeout(() => whenChildCount(aEntry, aChildCount, aCallback), 100);
 }