Bug 1399191 - Use an arrow function to avoid an undefined this value when calling namedTimer. r?markh draft
authorThom Chiovoloni <tchiovoloni@mozilla.com>
Tue, 12 Sep 2017 10:12:37 -0700
changeset 663125 736b9a1e1c810a29a65d818d2fc268112e18a774
parent 660284 89e526b3ec99f21c747eab839d832800884d5295
child 731106 697734faada98a17a94c434163e3502bd6da1b61
push id79335
push userbmo:tchiovoloni@mozilla.com
push dateTue, 12 Sep 2017 17:34:21 +0000
reviewersmarkh
bugs1399191
milestone57.0a1
Bug 1399191 - Use an arrow function to avoid an undefined this value when calling namedTimer. r?markh MozReview-Commit-ID: 2VwzGtAIYz7
services/sync/tps/extensions/tps/resource/tps.jsm
--- a/services/sync/tps/extensions/tps/resource/tps.jsm
+++ b/services/sync/tps/extensions/tps/resource/tps.jsm
@@ -321,28 +321,27 @@ var TPS = {
     for (let tab of tabs) {
       Logger.logInfo("executing action " + action.toUpperCase() +
                      " on tab " + JSON.stringify(tab));
       switch (action) {
         case ACTION_ADD:
           // When adding tabs, we keep track of how many tabs we're adding,
           // and wait until we've received that many onload events from our
           // new tabs before continuing
-          let that = this;
           let taburi = tab.uri;
-          BrowserTabs.Add(tab.uri, function() {
-            that._tabsFinished++;
+          BrowserTabs.Add(tab.uri, () => {
+            this._tabsFinished++;
             Logger.logInfo("tab for " + taburi + " finished loading");
-            if (that._tabsFinished == that._tabsAdded) {
+            if (this._tabsFinished == this._tabsAdded) {
               Logger.logInfo("all tabs loaded, continuing...");
 
               // Wait some time before continuing to be sure tabs can be synced,
               // otherwise we can get 'error locating tab' (bug 1383832).
-              CommonUtils.namedTimer(function() {
-                that.FinishAsyncOperation();
+              CommonUtils.namedTimer(() => {
+                this.FinishAsyncOperation();
               }, 2500, this, "postTabsOpening");
             }
           });
           break;
         case ACTION_VERIFY:
           Logger.AssertTrue(typeof(tab.profile) != "undefined",
             "profile must be defined when verifying tabs");
           Logger.AssertTrue(