Bug 1380449 - Do not clone when not in a Web Extension draft
authorJulien Wajsberg <felash@gmail.com>
Thu, 20 Jul 2017 16:06:15 +0200
changeset 618933 034c385cda29ec129a33ea58d62e58789a384da5
parent 618757 44121dbcac6a9d3ff18ed087a09b3205e5a04db1
child 640236 79a406c98512371941cf0bbd08135a37e0be9b63
push id71510
push userbmo:felash@gmail.com
push dateTue, 01 Aug 2017 09:19:23 +0000
bugs1380449
milestone56.0a1
Bug 1380449 - Do not clone when not in a Web Extension
toolkit/components/processsingleton/ContentProcessSingleton.js
--- a/toolkit/components/processsingleton/ContentProcessSingleton.js
+++ b/toolkit/components/processsingleton/ContentProcessSingleton.js
@@ -11,16 +11,18 @@ Cu.import("resource://gre/modules/Servic
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 XPCOMUtils.defineLazyServiceGetter(this, "cpmm",
                                    "@mozilla.org/childprocessmessagemanager;1",
                                    "nsIMessageSender");
 
 XPCOMUtils.defineLazyModuleGetter(this, "TelemetryController",
                                   "resource://gre/modules/TelemetryController.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "E10SUtils",
+                                  "resource:///modules/E10SUtils.jsm");
 
 /*
  * The message manager has an upper limit on message sizes that it can
  * reliably forward to the parent so we limit the size of console log event
  * messages that we forward here. The web console is local and receives the
  * full console message, but addons subscribed to console event messages
  * in the parent receive the truncated version. Due to fragmentation,
  * messages as small as 1MB have resulted in IPC allocation failures on
@@ -74,21 +76,28 @@ ContentProcessSingleton.prototype = {
       // When the sum of argument sizes reaches MSG_MGR_CONSOLE_MAX_SIZE,
       // replace all arguments with "<truncated>".
       let totalArgLength = 0;
 
       // Walk through the arguments, checking the type and size.
       for (let arg of consoleMsg.arguments) {
         if ((typeof arg == "object" || typeof arg == "function") &&
             arg !== null) {
-          try {
-            // If the argument is clonable, then send it as-is. If
-            // cloning fails, fall back to the unavailable string.
-            arg = Cu.cloneInto(arg, {});
-          } catch (e) {
+          if (Services.appinfo.remoteType === E10SUtils.EXTENSION_REMOTE_TYPE) {
+            // For OOP extensions: we want the developer to be able to see the
+            // logs in the Browser Console. When the Addon Toolbox will be more
+            // prominent we can revisit.
+            try {
+              // If the argument is clonable, then send it as-is. If
+              // cloning fails, fall back to the unavailable string.
+              arg = Cu.cloneInto(arg, {});
+            } catch (e) {
+              arg = unavailString;
+            }
+          } else {
             arg = unavailString;
           }
           totalArgLength += unavailStringLength;
         } else if (typeof arg == "string") {
           totalArgLength += arg.length * 2; // 2-bytes per char
         } else {
           totalArgLength += MSG_MGR_CONSOLE_VAR_SIZE;
         }