Bug 1445772 - Don't worry about binding console methods to the console object draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Wed, 14 Mar 2018 14:33:47 -0700
changeset 767621 f2f27f62555d01b799a2df6e6cc4ec971c4bdd7d
parent 767347 80b4777a6421d8df4bb27ac23fb607c318a3006c
push id102653
push userbgrinstead@mozilla.com
push dateWed, 14 Mar 2018 21:33:55 +0000
bugs1445772
milestone61.0a1
Bug 1445772 - Don't worry about binding console methods to the console object This isn't needed since Console is an interface and not an object MozReview-Commit-ID: ZoIo2TS9QL
devtools/client/framework/connect/connect.js
devtools/client/framework/toolbox.js
devtools/client/shared/theme-switching.js
devtools/client/webide/content/newapp.js
devtools/client/webide/content/webide.js
devtools/client/webide/modules/app-manager.js
dom/tests/browser/test-console-api.html
js/src/jit-test/tests/wasm/spec/harness/index.js
services/common/kinto-http-client.js
services/common/kinto-offline-client.js
testing/web-platform/mozilla/tests/wasm/js/harness/index.js
--- a/devtools/client/framework/connect/connect.js
+++ b/devtools/client/framework/connect/connect.js
@@ -231,12 +231,12 @@ function openToolbox(form, chrome = fals
     isTabActor: isTabActor
   };
   TargetFactory.forRemoteTab(options).then((target) => {
     let hostType = Toolbox.HostType.WINDOW;
     gDevTools.showToolbox(target, tool, hostType).then((toolbox) => {
       toolbox.once("destroyed", function () {
         gClient.close();
       });
-    }, console.error.bind(console));
+    }, console.error);
     window.close();
-  }, console.error.bind(console));
+  }, console.error);
 }
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -560,17 +560,17 @@ Toolbox.prototype = {
       // so we don't have to explicitly wait for this in tests; ideally, all tests
       // will handle this on their own, but each have their own tear down function.
       if (flags.testing) {
         await performanceFrontConnection;
       }
 
       this.emit("ready");
       this._isOpenDeferred.resolve();
-    }.bind(this))().catch(console.error.bind(console));
+    }.bind(this))().catch(console.error);
   },
 
   /**
    * loading React modules when needed (to avoid performance penalties
    * during Firefox start up time).
    */
   get React() {
     return this.browserRequire("devtools/client/shared/vendor/react");
--- a/devtools/client/shared/theme-switching.js
+++ b/devtools/client/shared/theme-switching.js
@@ -130,17 +130,17 @@
 
       if (newThemeDef.onApply) {
         newThemeDef.onApply(window, oldTheme);
       }
 
       // Final notification for further theme-switching related logic.
       gDevTools.emit("theme-switched", window, newTheme, oldTheme);
       notifyWindow();
-    }, console.error.bind(console));
+    }, console.error);
   }
 
   function handlePrefChange() {
     switchTheme(Services.prefs.getCharPref("devtools.theme"));
   }
 
   if (documentElement.hasAttribute("force-theme")) {
     switchTheme(documentElement.getAttribute("force-theme"));
--- a/devtools/client/webide/content/newapp.js
+++ b/devtools/client/webide/content/newapp.js
@@ -14,21 +14,16 @@ const {getJSON} = require("devtools/clie
 
 ChromeUtils.defineModuleGetter(this, "ZipUtils", "resource://gre/modules/ZipUtils.jsm");
 ChromeUtils.defineModuleGetter(this, "Downloads", "resource://gre/modules/Downloads.jsm");
 
 const TEMPLATES_URL = "devtools.webide.templatesURL";
 
 var gTemplateList = null;
 
-// See bug 989619
-console.log = console.log.bind(console);
-console.warn = console.warn.bind(console);
-console.error = console.error.bind(console);
-
 window.addEventListener("load", function () {
   let projectNameNode = document.querySelector("#project-name");
   projectNameNode.addEventListener("input", canValidate, true);
   getTemplatesJSON();
 }, {capture: true, once: true});
 
 function getTemplatesJSON() {
   getJSON(TEMPLATES_URL).then(list => {
--- a/devtools/client/webide/content/webide.js
+++ b/devtools/client/webide/content/webide.js
@@ -36,21 +36,16 @@ const MIN_ZOOM = 0.6;
      writable: false
    });
  });
 
 // Download remote resources early
 getJSON("devtools.webide.templatesURL");
 getJSON("devtools.devices.url");
 
-// See bug 989619
-console.log = console.log.bind(console);
-console.warn = console.warn.bind(console);
-console.error = console.error.bind(console);
-
 window.addEventListener("load", function () {
   UI.init();
 }, {once: true});
 
 window.addEventListener("unload", function () {
   UI.destroy();
 }, {once: true});
 
--- a/devtools/client/webide/modules/app-manager.js
+++ b/devtools/client/webide/modules/app-manager.js
@@ -234,17 +234,17 @@ var AppManager = exports.AppManager = {
   },
 
   reloadTab: function () {
     if (this.selectedProject && this.selectedProject.type != "tab") {
       return Promise.reject("tried to reload non-tab project");
     }
     return this.getTarget().then(target => {
       target.activeTab.reload();
-    }, console.error.bind(console));
+    }, console.error);
   },
 
   getTarget: function () {
     if (this.selectedProject.type == "mainProcess") {
       // Fx >=39 exposes a ChromeActor to debug the main process
       if (this.connection.client.mainRoot.traits.allowChromeProcess) {
         return this.connection.client.getProcess()
                    .then(aResponse => {
--- a/dom/tests/browser/test-console-api.html
+++ b/dom/tests/browser/test-console-api.html
@@ -46,17 +46,17 @@
 
       function testGroups() {
         console.groupCollapsed("a", "group");
         console.group("b", "group");
         console.groupEnd();
       }
 
       function nativeCallback() {
-        new Promise(function(resolve, reject) { resolve(42); }).then(console.log.bind(console));
+        new Promise(function(resolve, reject) { resolve(42); }).then(console.log);
       }
 
       function timeStamp(val) {
         console.timeStamp(val);
       }
     </script>
   </head>
   <body>
--- a/js/src/jit-test/tests/wasm/spec/harness/index.js
+++ b/js/src/jit-test/tests/wasm/spec/harness/index.js
@@ -75,17 +75,17 @@ var registry = {};
 
 // Resets the registry between two different WPT tests.
 function reinitializeRegistry() {
     if (typeof WebAssembly === 'undefined')
         return;
 
     registry = {
         spectest: {
-            print: console.log.bind(console),
+            print: console.log,
             global: 666,
             table: new WebAssembly.Table({initial: 10, maximum: 20, element: 'anyfunc'}),
             memory: new WebAssembly.Memory({initial: 1, maximum: 2})
         }
     };
 }
 
 reinitializeRegistry();
--- a/services/common/kinto-http-client.js
+++ b/services/common/kinto-http-client.js
@@ -366,18 +366,18 @@ const SUPPORTED_PROTOCOL_VERSION = expor
 /**
  * High level HTTP client for the Kinto API.
  *
  * @example
  * const client = new KintoClient("https://kinto.dev.mozaws.net/v1");
  * client.bucket("default")
  *    .collection("my-blog")
  *    .createRecord({title: "First article"})
- *   .then(console.log.bind(console))
- *   .catch(console.error.bind(console));
+ *   .then(console.log)
+ *   .catch(console.error);
  */
 let KintoClientBase = (_dec = (0, _utils.nobatch)("This operation is not supported within a batch operation."), _dec2 = (0, _utils.nobatch)("This operation is not supported within a batch operation."), _dec3 = (0, _utils.nobatch)("This operation is not supported within a batch operation."), _dec4 = (0, _utils.nobatch)("This operation is not supported within a batch operation."), _dec5 = (0, _utils.nobatch)("Can't use batch within a batch!"), _dec6 = (0, _utils.capable)(["permissions_endpoint"]), _dec7 = (0, _utils.support)("1.4", "2.0"), (_class = class KintoClientBase {
   /**
    * Constructor.
    *
    * @param  {String}       remote  The remote URL.
    * @param  {Object}       [options={}]                  The options object.
    * @param  {Boolean}      [options.safe=true]           Adds concurrency headers to every requests.
--- a/services/common/kinto-offline-client.js
+++ b/services/common/kinto-offline-client.js
@@ -509,18 +509,18 @@ class IDB extends _base2.default {
    * @example
    * const db = new IDB("example");
    * db.execute(transaction => {
    *   transaction.create({id: 1, title: "foo"});
    *   transaction.update({id: 2, title: "bar"});
    *   transaction.delete(3);
    *   return "foo";
    * })
-   *   .catch(console.error.bind(console));
-   *   .then(console.log.bind(console)); // => "foo"
+   *   .catch(console.error);
+   *   .then(console.log); // => "foo"
    *
    * @override
    * @param  {Function} callback The operation description callback.
    * @param  {Object}   options  The options object.
    * @return {Promise}
    */
   async execute(callback, options = { preload: [] }) {
     // Transactions in IndexedDB are autocommited when a callback does not
--- a/testing/web-platform/mozilla/tests/wasm/js/harness/index.js
+++ b/testing/web-platform/mozilla/tests/wasm/js/harness/index.js
@@ -75,17 +75,17 @@ var registry = {};
 
 // Resets the registry between two different WPT tests.
 function reinitializeRegistry() {
     if (typeof WebAssembly === 'undefined')
         return;
 
     registry = {
         spectest: {
-            print: console.log.bind(console),
+            print: console.log,
             global: 666,
             table: new WebAssembly.Table({initial: 10, maximum: 20, element: 'anyfunc'}),
             memory: new WebAssembly.Memory({initial: 1, maximum: 2})
         }
     };
 }
 
 reinitializeRegistry();