Bug 1472653 - Update event to trigger devtools.network.onRequestFinished. r=Honza
authorTony Ross <antross@gmail.com>
Tue, 12 Feb 2019 13:43:50 +0000
changeset 458734 248b41426bf2
parent 458733 67ac511f5c6c
child 458735 3c4a149e6f90
push id35548
push useropoprus@mozilla.com
push dateWed, 13 Feb 2019 09:48:26 +0000
treeherdermozilla-central@93e37c529818 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersHonza
bugs1472653
milestone67.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 1472653 - Update event to trigger devtools.network.onRequestFinished. r=Honza Fire onRequestFinished after PAYLOAD_RECEIVED instead of REQUEST_ADDED. Ensures response data is available for a request before dispatching the event. Differential Revision: https://phabricator.services.mozilla.com/D19040
devtools/client/netmonitor/src/api.js
--- a/devtools/client/netmonitor/src/api.js
+++ b/devtools/client/netmonitor/src/api.js
@@ -38,31 +38,31 @@ function NetMonitorAPI() {
 
   // Configure store/state object.
   this.store = configureStore(this.connector, this.telemetry);
 
   // List of listeners for `devtools.network.onRequestFinished` WebExt API
   this._requestFinishedListeners = new Set();
 
   // Bind event handlers
-  this.onRequestAdded = this.onRequestAdded.bind(this);
+  this.onPayloadReady = this.onPayloadReady.bind(this);
   this.actions = bindActionCreators(Actions, this.store.dispatch);
 }
 
 NetMonitorAPI.prototype = {
   async connect(toolbox) {
     // Bail out if already connected.
     if (this.toolbox) {
       return;
     }
 
     this.toolbox = toolbox;
 
     // Register listener for new requests (utilized by WebExtension API).
-    this.on(EVENTS.REQUEST_ADDED, this.onRequestAdded);
+    this.on(EVENTS.PAYLOAD_READY, this.onPayloadReady);
 
     // Initialize connection to the backend. Pass `this` as the owner,
     // so this object can receive all emitted events.
     const connection = {
       tabConnection: {
         tabTarget: toolbox.target,
       },
       toolbox,
@@ -72,17 +72,17 @@ NetMonitorAPI.prototype = {
     await this.connectBackend(this.connector, connection, this.actions,
       this.store.getState);
   },
 
   /**
    * Clean up (unmount from DOM, remove listeners, disconnect).
    */
   async destroy() {
-    this.off(EVENTS.REQUEST_ADDED, this.onRequestAdded);
+    this.off(EVENTS.PAYLOAD_READY, this.onPayloadReady);
 
     await this.connector.disconnect();
 
     if (this.harExportConnector) {
       await this.harExportConnector.disconnect();
     }
   },
 
@@ -115,17 +115,17 @@ NetMonitorAPI.prototype = {
 
     return HarExporter.getHar(options);
   },
 
   /**
    * Support for `devtools.network.onRequestFinished`. A hook for
    * every finished HTTP request used by WebExtensions API.
    */
-  async onRequestAdded(requestId) {
+  async onPayloadReady(requestId) {
     if (!this._requestFinishedListeners.size) {
       return;
     }
 
     const { HarExporter } = require("devtools/client/netmonitor/src/har/har-exporter");
 
     const connector = await this.getHarExportConnector();
     const request = getDisplayedRequestById(this.store.getState(), requestId);