Bug 1639165 - Don't log messages forwarded from content processes when multiprocess browser toolbox is enabled. r=Honza.
authornchevobbe <nchevobbe@mozilla.com>
Fri, 05 Jun 2020 14:53:33 +0000
changeset 534150 ad832014f2d291af829bf3c0d1c646387efce805
parent 534149 fd256d1ad3419d1ddec19043f91578cbe7ae6085
child 534151 a63a27cde0b2dd0b7c17ec31de946d4c35e17463
push id37483
push userapavel@mozilla.com
push dateFri, 05 Jun 2020 21:40:11 +0000
treeherdermozilla-central@dadc7312128e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1639165
milestone79.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 1639165 - Don't log messages forwarded from content processes when multiprocess browser toolbox is enabled. r=Honza. We were getting duplicated nsIScriptError in the Browser Toolbox console and the Browser Console when the multiprocess pref is enabled, because error from content processes are forwarded to the main process. The previous patch of this queue added a isForwardedFromContentProcess flag to nsIScriptError, that we use in this patch to _not_ handle forwarded messages in multiprocess browser console and browser toolbox console. Differential Revision: https://phabricator.services.mozilla.com/D78231
devtools/client/webconsole/test/node/fixtures/stubs/cssMessage.js
devtools/client/webconsole/test/node/fixtures/stubs/pageError.js
devtools/client/webconsole/webconsole-ui.js
devtools/server/actors/webconsole.js
--- a/devtools/client/webconsole/test/node/fixtures/stubs/cssMessage.js
+++ b/devtools/client/webconsole/test/node/fixtures/stubs/cssMessage.js
@@ -33,17 +33,18 @@ rawPackets.set(`Unknown property ‘such-unknown-property’.  Declaration dropped.`, {
     "warning": true,
     "error": false,
     "info": false,
     "private": false,
     "stacktrace": null,
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "p",
-    "isPromiseRejection": false
+    "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`Error in parsing value for ‘padding-top’.  Declaration dropped.`, {
   "pageError": {
     "errorMessage": "Error in parsing value for ‘padding-top’.  Declaration dropped.",
     "errorMessageName": "",
@@ -58,17 +59,18 @@ rawPackets.set(`Error in parsing value for ‘padding-top’.  Declaration dropped.`, {
     "warning": true,
     "error": false,
     "info": false,
     "private": false,
     "stacktrace": null,
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "p",
-    "isPromiseRejection": false
+    "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false
   },
   "resourceType": "error-message"
 });
 
 
 const stubPackets = parsePacketsWithFronts(rawPackets);
 
 const stubPreparedMessages = new Map();
--- a/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js
+++ b/devtools/client/webconsole/test/node/fixtures/stubs/pageError.js
@@ -79,16 +79,17 @@ rawPackets.set(`ReferenceError: asdf is 
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "_grip": {
         "type": "object",
         "actor": "server0.conn4.child2/obj25",
         "class": "Error",
         "ownPropertyLength": 4,
         "extensible": true,
         "frozen": false,
@@ -160,16 +161,17 @@ rawPackets.set(`SyntaxError: redeclarati
           "line": 2,
           "column": 6
         }
       }
     ],
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "_grip": {
         "type": "object",
         "actor": "server0.conn4.child2/obj26",
         "class": "Error",
         "ownPropertyLength": 4,
         "extensible": true,
         "frozen": false,
@@ -245,16 +247,17 @@ rawPackets.set(`TypeError longString mes
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "_grip": {
         "type": "object",
         "actor": "server0.conn4.child2/obj29",
         "class": "Error",
         "ownPropertyLength": 4,
         "extensible": true,
         "frozen": false,
@@ -330,16 +333,17 @@ rawPackets.set(`throw string with URL`, 
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": "“https://evil.com/?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa“ is evil and “https://not-so-evil.com/?aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa“ is not good either",
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`throw ""`, {
   "pageError": {
@@ -387,16 +391,17 @@ rawPackets.set(`throw ""`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": "",
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`throw "tomato"`, {
   "pageError": {
@@ -444,16 +449,17 @@ rawPackets.set(`throw "tomato"`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": "tomato",
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`throw false`, {
   "pageError": {
@@ -501,16 +507,17 @@ rawPackets.set(`throw false`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": false,
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`throw 0`, {
   "pageError": {
@@ -558,16 +565,17 @@ rawPackets.set(`throw 0`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": 0,
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`throw null`, {
   "pageError": {
@@ -615,16 +623,17 @@ rawPackets.set(`throw null`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "type": "null"
     },
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
@@ -674,16 +683,17 @@ rawPackets.set(`throw undefined`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "type": "undefined"
     },
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
@@ -733,16 +743,17 @@ rawPackets.set(`throw Symbol`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "type": "symbol",
       "actor": "server0.conn4.child2/symbol38",
       "name": "potato"
     },
     "hasException": true
   },
   "resourceType": "error-message"
@@ -794,16 +805,17 @@ rawPackets.set(`throw Object`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "_grip": {
         "type": "object",
         "actor": "server0.conn4.child2/obj40",
         "class": "Object",
         "ownPropertyLength": 1,
         "extensible": true,
         "frozen": false,
@@ -877,16 +889,17 @@ rawPackets.set(`throw Error Object`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "_grip": {
         "type": "object",
         "actor": "server0.conn4.child2/obj42",
         "class": "Error",
         "ownPropertyLength": 4,
         "extensible": true,
         "frozen": false,
@@ -954,16 +967,17 @@ rawPackets.set(`throw Error Object with 
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": false,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "_grip": {
         "type": "object",
         "actor": "server0.conn4.child2/obj44",
         "class": "Error",
         "ownPropertyLength": 6,
         "extensible": true,
         "frozen": false,
@@ -1031,16 +1045,17 @@ rawPackets.set(`Promise reject ""`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": "",
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`Promise reject "tomato"`, {
   "pageError": {
@@ -1088,16 +1103,17 @@ rawPackets.set(`Promise reject "tomato"`
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": "tomato",
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`Promise reject false`, {
   "pageError": {
@@ -1145,16 +1161,17 @@ rawPackets.set(`Promise reject false`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": false,
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`Promise reject 0`, {
   "pageError": {
@@ -1202,16 +1219,17 @@ rawPackets.set(`Promise reject 0`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": 0,
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
 rawPackets.set(`Promise reject null`, {
   "pageError": {
@@ -1259,16 +1277,17 @@ rawPackets.set(`Promise reject null`, {
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "type": "null"
     },
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
@@ -1318,16 +1337,17 @@ rawPackets.set(`Promise reject undefined
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "type": "undefined"
     },
     "hasException": true
   },
   "resourceType": "error-message"
 });
 
@@ -1377,16 +1397,17 @@ rawPackets.set(`Promise reject Symbol`, 
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "type": "symbol",
       "actor": "server0.conn4.child2/symbol52",
       "name": "potato"
     },
     "hasException": true
   },
   "resourceType": "error-message"
@@ -1438,16 +1459,17 @@ rawPackets.set(`Promise reject Object`, 
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "_grip": {
         "type": "object",
         "actor": "server0.conn4.child2/obj54",
         "class": "Object",
         "ownPropertyLength": 1,
         "extensible": true,
         "frozen": false,
@@ -1521,16 +1543,17 @@ rawPackets.set(`Promise reject Error Obj
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "_grip": {
         "type": "object",
         "actor": "server0.conn4.child2/obj56",
         "class": "Error",
         "ownPropertyLength": 4,
         "extensible": true,
         "frozen": false,
@@ -1598,16 +1621,17 @@ rawPackets.set(`Promise reject Error Obj
         "functionName": null,
         "asyncCause": "MessageListener.receiveMessage"
       }
     ],
     "notes": null,
     "chromeContext": false,
     "cssSelectors": "",
     "isPromiseRejection": true,
+    "isForwardedFromContentProcess": false,
     "exception": {
       "_grip": {
         "type": "object",
         "actor": "server0.conn4.child2/obj58",
         "class": "Error",
         "ownPropertyLength": 6,
         "extensible": true,
         "frozen": false,
--- a/devtools/client/webconsole/webconsole-ui.js
+++ b/devtools/client/webconsole/webconsole-ui.js
@@ -60,16 +60,20 @@ class WebConsoleUI {
     this.hud = hud;
     this.hudId = this.hud.hudId;
     this.isBrowserConsole = this.hud.isBrowserConsole;
 
     this.isBrowserToolboxConsole =
       this.hud.currentTarget &&
       this.hud.currentTarget.isParentProcess &&
       !this.hud.currentTarget.isAddon;
+    this.fissionSupport = Services.prefs.getBoolPref(
+      constants.PREFS.FEATURES.BROWSER_TOOLBOX_FISSION
+    );
+
     this.window = this.hud.iframeWindow;
 
     this._onPanelSelected = this._onPanelSelected.bind(this);
     this._onChangeSplitConsoleState = this._onChangeSplitConsoleState.bind(
       this
     );
     this._onTargetAvailable = this._onTargetAvailable.bind(this);
     this._onTargetDestroyed = this._onTargetDestroyed.bind(this);
@@ -338,16 +342,25 @@ class WebConsoleUI {
         resourceWatcher.TYPES.ERROR_MESSAGE,
         resourceWatcher.TYPES.PLATFORM_MESSAGE,
       ],
       { onAvailable: this._onResourceAvailable }
     );
   }
 
   _onResourceAvailable({ resourceType, targetFront, resource }) {
+    // Ignore messages forwarded from content processes if we're in fission browser toolbox.
+    if (
+      resourceType === this.hud.resourceWatcher.TYPES.ERROR_MESSAGE &&
+      resource.pageError.isForwardedFromContentProcess &&
+      (this.isBrowserToolboxConsole || this.isBrowserConsole) &&
+      this.fissionSupport
+    ) {
+      return;
+    }
     this.wrapper.dispatchMessageAdd(resource);
   }
 
   /**
    * Called any time a new target is available.
    * i.e. it was already existing or has just been created.
    *
    * @private
@@ -365,21 +378,20 @@ class WebConsoleUI {
           targetType: targetFront.targetType,
         });
       }
     };
 
     // This is a top level target. It may update on process switches
     // when navigating to another domain.
     if (targetFront.isTopLevel) {
-      const fissionSupport = Services.prefs.getBoolPref(
-        constants.PREFS.FEATURES.BROWSER_TOOLBOX_FISSION
-      );
       const needContentProcessMessagesListener =
-        targetFront.isParentProcess && !targetFront.isAddon && !fissionSupport;
+        targetFront.isParentProcess &&
+        !targetFront.isAddon &&
+        !this.fissionSupport;
       this.proxy = new WebConsoleConnectionProxy(
         this,
         targetFront,
         needContentProcessMessagesListener
       );
       await this.proxy.connect();
       dispatchTargetAvailable();
       return;
--- a/devtools/server/actors/webconsole.js
+++ b/devtools/server/actors/webconsole.js
@@ -1716,16 +1716,17 @@ const WebConsoleActor = ActorClassWithSp
       error: !(pageError.flags & (pageError.warningFlag | pageError.infoFlag)),
       info: !!(pageError.flags & pageError.infoFlag),
       private: pageError.isFromPrivateWindow,
       stacktrace: stack,
       notes: notesArray,
       chromeContext: pageError.isFromChromeContext,
       cssSelectors: pageError.cssSelectors,
       isPromiseRejection: pageError.isPromiseRejection,
+      isForwardedFromContentProcess: pageError.isForwardedFromContentProcess,
     };
 
     // If the pageError does have an exception object, we want to return the grip for it,
     // but only if we do manage to get the grip, as we're checking the property on the
     // client to render things differently.
     if (pageError.hasException) {
       try {
         const obj = this.makeDebuggeeValue(pageError.exception, true);