Bug 889158 part 1 - Fix chrome and tests to not use arrow functions with arguments. r=Waldo
authorJan de Mooij <jdemooij@mozilla.com>
Sat, 22 Aug 2015 13:49:11 +0200 (2015-08-22)
changeset 258923 a7b04b9e4f17de3f5010b6cc53032517efbfa570
parent 258922 6eaeb32125f4ce179182e8742e0cb43c6251ebc8
child 258924 dab1cbe3f0ed35e16496ba28bb62e297c81c1881
push id29263
push userryanvm@gmail.com
push dateSun, 23 Aug 2015 21:18:49 +0000 (2015-08-23)
treeherdermozilla-central@4ccdd06e51d7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs889158
milestone43.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 889158 part 1 - Fix chrome and tests to not use arrow functions with arguments. r=Waldo
addon-sdk/source/test/context-menu/test-helper.js
addon-sdk/source/test/event/helpers.js
browser/base/content/test/general/head.js
browser/components/places/tests/browser/browser_library_commands.js
browser/components/places/tests/browser/head.js
toolkit/components/places/tests/bookmarks/test_bookmarks_notifications.js
toolkit/components/places/tests/bookmarks/test_keywords.js
toolkit/components/places/tests/unit/test_keywords.js
toolkit/devtools/event-emitter.js
--- a/addon-sdk/source/test/context-menu/test-helper.js
+++ b/addon-sdk/source/test/context-menu/test-helper.js
@@ -25,17 +25,17 @@ const TEST_DOC_URL = module.uri.replace(
 // This makes it easier to run tests by handling things like opening the menu,
 // opening new windows, making assertions, etc.  Methods on |test| can be called
 // on instances of this class.  Don't forget to call done() to end the test!
 // WARNING: This looks up items in popups by comparing labels, so don't give two
 // items the same label.
 function TestHelper(assert, done) {
   // Methods on the wrapped test can be called on this object.
   for (var prop in assert)
-    this[prop] = () => assert[prop].apply(assert, arguments);
+    this[prop] = (...args) => assert[prop].apply(assert, args);
   this.assert = assert;
   this.end = done;
   this.loaders = [];
   this.browserWindow = getMostRecentBrowserWindow();
   this.overflowThreshValue = require("sdk/preferences/service").
                              get(OVERFLOW_THRESH_PREF, OVERFLOW_THRESH_DEFAULT);
   this.done = this.done.bind(this);
 }
--- a/addon-sdk/source/test/event/helpers.js
+++ b/addon-sdk/source/test/event/helpers.js
@@ -21,17 +21,17 @@ const { defer } = require("sdk/core/prom
  *    A string representing the event type to waiting for.
  * @param {Boolean} [capture]
  *    If `true`, `capture` indicates that the user wishes to initiate capture.
  *
  * @returns {Promise}
  *    A promise resolved once the delay given is passed, or the object
  *    receives the event specified
  */
-const wait = (target, type, capture) => {
+const wait = function(target, type, capture) {
   let { promise, resolve, reject } = defer();
 
   if (!arguments.length) {
     setImmediate(resolve);
   }
   else if (typeof(target) === "number") {
     setTimeout(resolve, target);
   }
@@ -100,9 +100,9 @@ exports.ignoreNew = scenario(function(ou
 exports.FIFO = scenario(function(target, expected, actual) {
   on(target, "data", function($) actual.push($ + "#1"));
   on(target, "data", function($) actual.push($ + "#2"));
   on(target, "data", function($) actual.push($ + "#3"));
 
   return expected.reduce(function(result, value) {
     return result.concat(value + "#1", value + "#2", value + "#3");
   }, []);
-});
\ No newline at end of file
+});
--- a/browser/base/content/test/general/head.js
+++ b/browser/base/content/test/general/head.js
@@ -553,18 +553,18 @@ let FullZoomHelper = {
 
   BACK: 0,
   FORWARD: 1,
   navigate: function navigate(direction) {
     return new Promise(resolve => {
       let didPs = false;
       let didZoom = false;
 
-      gBrowser.addEventListener("pageshow", function (event) {
-        gBrowser.removeEventListener("pageshow", arguments.callee, true);
+      gBrowser.addEventListener("pageshow", function listener(event) {
+        gBrowser.removeEventListener("pageshow", listener, true);
         didPs = true;
         if (didZoom)
           resolve();
       }, true);
 
       if (direction == this.BACK)
         gBrowser.goBack();
       else if (direction == this.FORWARD)
@@ -713,19 +713,19 @@ function assertWebRTCIndicatorStatus(exp
     is(menu && !menu.hidden, !!expected, "WebRTC menu should be " + expectedState);
   }
 
   if (!("nsISystemStatusBar" in Ci)) {
     if (!expected) {
       let win = Services.wm.getMostRecentWindow("Browser:WebRTCGlobalIndicator");
       if (win) {
         yield new Promise((resolve, reject) => {
-          win.addEventListener("unload", (e) => {
+          win.addEventListener("unload", function listener(e) {
             if (e.target == win.document) {
-              win.removeEventListener("unload", arguments.callee);
+              win.removeEventListener("unload", listener);
               resolve();
             }
           }, false);
         });
       }
     }
     let indicator = Services.wm.getEnumerator("Browser:WebRTCGlobalIndicator");
     let hasWindow = indicator.hasMoreElements();
--- a/browser/components/places/tests/browser/browser_library_commands.js
+++ b/browser/components/places/tests/browser/browser_library_commands.js
@@ -55,17 +55,17 @@ add_task(function* test_date_container()
      "Copy command is enabled");
   ok(!PO._places.controller.isCommandEnabled("cmd_cut"),
      "Cut command is disabled");
   ok(PO._places.controller.isCommandEnabled("cmd_delete"),
      "Delete command is enabled");
 
   // Execute the delete command and check visit has been removed.
   let promiseURIRemoved = promiseHistoryNotification("onDeleteURI",
-                                                     () => TEST_URI.equals(arguments[0]));
+                                                     v => TEST_URI.equals(v));
   PO._places.controller.doCommand("cmd_delete");
   yield promiseURIRemoved;
 
   // Test live update of "History" query.
   is(historyNode.childCount, 0, "History node has no more children");
 
   historyNode.containerOpen = false;
 
@@ -120,17 +120,17 @@ add_task(function* test_query_on_toolbar
      "Copy command is enabled");
   ok(PO._places.controller.isCommandEnabled("cmd_cut"),
      "Cut command is enabled");
   ok(PO._places.controller.isCommandEnabled("cmd_delete"),
      "Delete command is enabled");
 
   // Execute the delete command and check bookmark has been removed.
   let promiseItemRemoved = promiseBookmarksNotification("onItemRemoved",
-                                                        () => query.guid == arguments[5]);
+                                                        (...args) => query.guid == args[5]);
   PO._places.controller.doCommand("cmd_delete");
   yield promiseItemRemoved;
 
   is((yield PlacesUtils.bookmarks.fetch(query.guid)), null,
      "Query node bookmark has been correctly removed");
 
   toolbarNode.containerOpen = false;
 
--- a/browser/components/places/tests/browser/head.js
+++ b/browser/components/places/tests/browser/head.js
@@ -165,23 +165,23 @@ function promiseBookmarksNotification(no
   info(`promiseBookmarksNotification: waiting for ${notification}`);
   return new Promise((resolve, reject) => {
     let proxifiedObserver = new Proxy({}, {
       get: (target, name) => {
         if (name == "QueryInterface")
           return XPCOMUtils.generateQI([ Ci.nsINavBookmarkObserver ]);
         info(`promiseBookmarksNotification: got ${name} notification`);
         if (name == notification)
-          return () => {
-            if (conditionFn.apply(this, arguments)) {
+          return (...args) => {
+            if (conditionFn.apply(this, args)) {
               clearTimeout(timeout);
               PlacesUtils.bookmarks.removeObserver(proxifiedObserver, false);
               executeSoon(resolve);
             } else {
-              info(`promiseBookmarksNotification: skip cause condition doesn't apply to ${JSON.stringify(arguments)}`);
+              info(`promiseBookmarksNotification: skip cause condition doesn't apply to ${JSON.stringify(args)}`);
             }
           }
         return () => {};
       }
     });
     PlacesUtils.bookmarks.addObserver(proxifiedObserver, false);
     let timeout = setTimeout(() => {
       PlacesUtils.bookmarks.removeObserver(proxifiedObserver, false);
@@ -193,18 +193,18 @@ function promiseBookmarksNotification(no
 function promiseHistoryNotification(notification, conditionFn) {
   info(`Waiting for ${notification}`);
   return new Promise((resolve, reject) => {
     let proxifiedObserver = new Proxy({}, {
       get: (target, name) => {
         if (name == "QueryInterface")
           return XPCOMUtils.generateQI([ Ci.nsINavHistoryObserver ]);
         if (name == notification)
-          return () => {
-            if (conditionFn.apply(this, arguments)) {
+          return (...args) => {
+            if (conditionFn.apply(this, args)) {
               clearTimeout(timeout);
               PlacesUtils.history.removeObserver(proxifiedObserver, false);
               executeSoon(resolve);
             }
           }
         return () => {};
       }
     });
--- a/toolkit/components/places/tests/bookmarks/test_bookmarks_notifications.js
+++ b/toolkit/components/places/tests/bookmarks/test_bookmarks_notifications.js
@@ -425,18 +425,18 @@ function expectNotifications() {
     get(target, name) {
       if (name == "check") {
         PlacesUtils.bookmarks.removeObserver(observer);
         return expectedNotifications =>
           Assert.deepEqual(notifications, expectedNotifications);
       }
 
       if (name.startsWith("onItem")) {
-        return () => {
-          let args = Array.from(arguments, arg => {
+        return (...origArgs) => {
+          let args = Array.from(origArgs, arg => {
             if (arg && arg instanceof Ci.nsIURI)
               return new URL(arg.spec);
             if (arg && typeof(arg) == "number" && arg >= Date.now() * 1000)
               return new Date(parseInt(arg/1000));
             return arg;
           });
           notifications.push({ name: name, arguments: args });
         }
--- a/toolkit/components/places/tests/bookmarks/test_keywords.js
+++ b/toolkit/components/places/tests/bookmarks/test_keywords.js
@@ -39,17 +39,17 @@ function expectNotifications() {
     get(target, name) {
       if (name == "check") {
         PlacesUtils.bookmarks.removeObserver(observer);
         return expectedNotifications =>
           Assert.deepEqual(notifications, expectedNotifications);
       }
 
       if (name.startsWith("onItemChanged")) {
-        return (id, prop, isAnno, val, lastMod, itemType, parentId, guid, parentGuid, oldVal) => {
+        return function(id, prop, isAnno, val, lastMod, itemType, parentId, guid, parentGuid, oldVal) {
           if (prop != "keyword")
             return;
           let args = Array.from(arguments, arg => {
             if (arg && arg instanceof Ci.nsIURI)
               return new URL(arg.spec);
             if (arg && typeof(arg) == "number" && arg >= Date.now() * 1000)
               return new Date(parseInt(arg/1000));
             return arg;
--- a/toolkit/components/places/tests/unit/test_keywords.js
+++ b/toolkit/components/places/tests/unit/test_keywords.js
@@ -51,17 +51,17 @@ function expectBookmarkNotifications() {
     get(target, name) {
       if (name == "check") {
         PlacesUtils.bookmarks.removeObserver(observer);
         return expectedNotifications =>
           Assert.deepEqual(notifications, expectedNotifications);
       }
 
       if (name.startsWith("onItemChanged")) {
-        return (itemId, property) => {
+        return function(itemId, property) {
           if (property != "keyword")
             return;
           let args = Array.from(arguments, arg => {
             if (arg && arg instanceof Ci.nsIURI)
               return new URL(arg.spec);
             if (arg && typeof(arg) == "number" && arg >= Date.now() * 1000)
               return new Date(parseInt(arg/1000));
             return arg;
--- a/toolkit/devtools/event-emitter.js
+++ b/toolkit/devtools/event-emitter.js
@@ -81,20 +81,20 @@ EventEmitter.prototype = {
    *        A promise which is resolved when the event next happens. The
    *        resolution value of the promise is the first event argument. If
    *        you need access to second or subsequent event arguments (it's rare
    *        that this is needed) then use aListener
    */
   once: function EventEmitter_once(aEvent, aListener) {
     let deferred = promise.defer();
 
-    let handler = (aEvent, aFirstArg) => {
+    let handler = (aEvent, aFirstArg, ...aRest) => {
       this.off(aEvent, handler);
       if (aListener) {
-        aListener.apply(null, arguments);
+        aListener.apply(null, [aEvent, aFirstArg, ...aRest]);
       }
       deferred.resolve(aFirstArg);
     };
 
     handler._originalListener = aListener;
     this.on(aEvent, handler);
 
     return deferred.promise;