Bug 1380449 - Do not clone when not in a Web Extension r=kmag
MozReview-Commit-ID: D1Ry7INxnYo
--- 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;
}