Bug 1520771 - Remove navPayload from will-navigate/navigate events. r=nchevobbe
authorAlexandre Poirot <poirot.alex@gmail.com>
Mon, 21 Jan 2019 15:19:32 +0000
changeset 454694 5bda17f8f936f89149ab5fbe76b63836cf053d06
parent 454693 11325875967aeff353c93e6cfc38fc614ce211b1
child 454695 1cccd0ed64c30ca3d7873620f3aac6afe09f82e2
push id35411
push usercsabou@mozilla.com
push dateTue, 22 Jan 2019 03:53:40 +0000
treeherdermozilla-central@ada22b635f8d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnchevobbe
bugs1520771
milestone66.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 1520771 - Remove navPayload from will-navigate/navigate events. r=nchevobbe It looks like a relic of the ancient times, probably specific to non-e10s codepath which degraded over time and there is still a couple of leftover here and there. For now the output wrapper was passing over the will-navigate event and make it so that it looked like a "cached" packet. Which it isn't. So instead, flag a meaningful "type" attribute and handle this packet directly in transformPacket. Differential Revision: https://phabricator.services.mozilla.com/D16871
devtools/client/framework/target.js
devtools/client/webconsole/utils/messages.js
devtools/client/webconsole/webconsole-output-wrapper.js
--- a/devtools/client/framework/target.js
+++ b/devtools/client/framework/target.js
@@ -637,23 +637,19 @@ class Target extends EventEmitter {
     if (!packet.isFrameSwitching || this.isWebExtension) {
       this._url = packet.url;
       this._title = packet.title;
     }
 
     // Send any stored event payload (DOMWindow or nsIRequest) for backwards
     // compatibility with non-remotable tools.
     if (packet.state == "start") {
-      event._navPayload = this._navRequest;
       this.emit("will-navigate", event);
-      this._navRequest = null;
     } else {
-      event._navPayload = this._navWindow;
       this.emit("navigate", event);
-      this._navWindow = null;
     }
   }
 
   /**
    * Setup listeners for remote debugging, updating existing ones as necessary.
    */
   _setupRemoteListeners() {
     this.client.addListener("closed", this.destroy);
--- a/devtools/client/webconsole/utils/messages.js
+++ b/devtools/client/webconsole/utils/messages.js
@@ -39,17 +39,17 @@ function transformPacket(packet) {
     packet = convertCachedPacket(packet);
   }
 
   switch (packet.type) {
     case "consoleAPICall": {
       return transformConsoleAPICallPacket(packet);
     }
 
-    case "navigationMessage": {
+    case "will-navigate": {
       return transformNavigationMessagePacket(packet);
     }
 
     case "logMessage": {
       return transformLogMessagePacket(packet);
     }
 
     case "pageError": {
@@ -189,24 +189,22 @@ function transformConsoleAPICallPacket(p
     userProvidedStyles: message.styles,
     prefix: message.prefix,
     private: message.private,
     executionPoint: message.executionPoint,
   });
 }
 
 function transformNavigationMessagePacket(packet) {
-  const { message } = packet;
+  const { url } = packet;
   return new ConsoleMessage({
     source: MESSAGE_SOURCE.CONSOLE_API,
     type: MESSAGE_TYPE.NAVIGATION_MARKER,
     level: MESSAGE_LEVEL.LOG,
-    messageText: l10n.getFormatStr("webconsole.navigated", [message.url]),
-    timeStamp: message.timeStamp,
-    private: message.private,
+    messageText: l10n.getFormatStr("webconsole.navigated", [url]),
   });
 }
 
 function transformLogMessagePacket(packet) {
   const {
     message,
     timeStamp,
   } = packet;
@@ -341,19 +339,16 @@ function convertCachedPacket(packet) {
   // transform them here.
   let convertPacket = {};
   if (packet._type === "ConsoleAPI") {
     convertPacket.message = packet;
     convertPacket.type = "consoleAPICall";
   } else if (packet._type === "PageError") {
     convertPacket.pageError = packet;
     convertPacket.type = "pageError";
-  } else if ("_navPayload" in packet) {
-    convertPacket.type = "navigationMessage";
-    convertPacket.message = packet;
   } else if (packet._type === "NetworkEvent") {
     convertPacket.networkEvent = packet;
     convertPacket.type = "networkEvent";
   } else if (packet._type === "LogMessage") {
     convertPacket = {
       ...packet,
       type: "logMessage",
     };
--- a/devtools/client/webconsole/webconsole-output-wrapper.js
+++ b/devtools/client/webconsole/webconsole-output-wrapper.js
@@ -478,18 +478,19 @@ WebConsoleOutputWrapper.prototype = {
   dispatchTabWillNavigate: function(packet) {
     const { ui } = store.getState();
 
     // For the browser console, we receive tab navigation
     // when the original top level window we attached to is closed,
     // but we don't want to reset console history and just switch to
     // the next available window.
     if (ui.persistLogs || this.hud.isBrowserConsole) {
-      // Add a _type to hit convertCachedPacket.
-      packet._type = true;
+      // Add a type in order for this event packet to be identified by
+      // utils/messages.js's `transformPacket`
+      packet.type = "will-navigate";
       this.dispatchMessageAdd(packet);
     } else {
       this.hud.webConsoleClient.clearNetworkRequests();
       this.dispatchMessagesClear();
       store.dispatch({
         type: Constants.WILL_NAVIGATE,
       });
     }