Bug 906375 - Bind all the methods in Console.jsm's console object. r=mratcliffe
authorDave Camp <dcamp@mozilla.com>
Fri, 16 Aug 2013 16:45:05 -0700
changeset 143038 dad9e49344924a015c5a44af9f3988111460c910
parent 143037 df040913f3c44d910ae13c909767643e6796a5ea
child 143039 8e4324426c1a7cc75e7f39e177c080924f411951
push id32605
push userphilringnalda@gmail.com
push dateMon, 19 Aug 2013 00:51:46 +0000
treeherdermozilla-inbound@7f882e063eaf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmratcliffe
bugs906375
milestone26.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 906375 - Bind all the methods in Console.jsm's console object. r=mratcliffe
toolkit/devtools/Console.jsm
--- a/toolkit/devtools/Console.jsm
+++ b/toolkit/devtools/Console.jsm
@@ -581,16 +581,24 @@ function sendConsoleAPIMessage(aLevel, a
  *        A console API instance object
  */
 function ConsoleAPI(aConsoleOptions = {}) {
   // Normalize console options to set default values
   // in order to avoid runtime checks on each console method call.
   this.dump = aConsoleOptions.dump || dump;
   this.prefix = aConsoleOptions.prefix || "";
   this.maxLogLevel = aConsoleOptions.maxLogLevel || "all";
+
+  // Bind all the functions to this object.
+  for (let prop in this) {
+    let desc = Object.getOwnPropertyDescriptor(this, prop);
+    if (typeof(desc.value) === "function") {
+      this[prop] = desc.value.bind(this);
+    }
+  }
 }
 
 ConsoleAPI.prototype = {
   debug: createMultiLineDumper("debug"),
   log: createDumper("log"),
   info: createDumper("info"),
   warn: createDumper("warn"),
   error: createMultiLineDumper("error"),