Bug 1555057 Comment 17 Edit History

Note: The actual edited comment in the bug view page will always show the original commenter’s name and original timestamp.

Since Bug 1604618 is fixed we can also make progress with this report.

Instructions for anyone interested in implementing this new feature.

1) The backend needs to use the new API to see whether a request has been blocked by an extension.
This should be done in `_onComplete` method within `NetworkResponseListener`
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/server/actors/network-monitor/network-response-listener.js#505

You might also see the a test file from the original bug
https://phabricator.services.mozilla.com/D57537#change-1UJmrASHGTxx

```
    let id;
    let reason;

    try {
      let properties = this.request.QueryInterface(Ci.nsIPropertyBag);
      id = properties.getProperty("cancelledByExtension");
      reason = this.request.loadInfo.requestBlockingReason;
    } catch (err) {
      // "cancelledByExtension" doesn't have to be available.
    }
```

We need to pass the data to `addResponseContent`

```
    this.httpActivity.owner.addResponseContent(response, {
      discardResponseBody: this.httpActivity.discardResponseBody,
      truncated: this.truncated,
      blockedReason: reason,
      blockingExtension: id,
    });
```

2) The `addResponseContent` needs to be updated to adopt the two new arguments
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/server/actors/network-monitor/network-event.js#504

Both arguments need to be emitted with all the other arguments.

3) Both argument types needs to be added to packet type definition
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/shared/specs/network-event.js#143-152

reason == number
extension id == string

4) The client side needs to read both arguments here
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/client/netmonitor/src/connector/firefox-data-provider.js#418-424

```
      case "responseContent":
        this.pushRequestToQueue(actor, {
          contentSize: networkInfo.response.bodySize,
          transferredSize: networkInfo.response.transferredSize,
          mimeType: networkInfo.response.content.mimeType,
          blockingExtension: packet.blockingExtension,
          blockedReason: packet.blockedReason,
        });
```

5) Rendering should happen in RequestListColumnTransferredSize
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/client/netmonitor/src/components/request-list/RequestListColumnTransferredSize.js#47

The two new props should be in `this.props`

    const {
      blockedReason,
      blockingExtension,
    } = this.props.item;

And the rendering logic needs to be updated to show the Extension ID

6) The `UPDATED_TRANSFERRED_PROPS` array needs to also have `responseContent` so, the column is rerendered when we send the packet from the backend.

7) Finally, `UPDATE_PROPS` array needs to also contain both new arguments   "blockedReason" and  "blockingExtension" 
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/client/netmonitor/src/constants.js#159

8) This also needs a test. You can take an inspiration from:
https://phabricator.services.mozilla.com/D57537#change-1UJmrASHGTxx

Honza
Since Bug 1604618 is fixed we can also make progress with this report.

Instructions for anyone interested in implementing this new feature.

1) The backend needs to use the new API to see whether a request has been blocked by an extension.
This should be done in `_onComplete` method within `NetworkResponseListener`
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/server/actors/network-monitor/network-response-listener.js#505

You might also see the a test file from the original bug
https://phabricator.services.mozilla.com/D57537#change-1UJmrASHGTxx

```
    let id;
    let reason;

    try {
      let properties = this.request.QueryInterface(Ci.nsIPropertyBag);
      id = properties.getProperty("cancelledByExtension");
      reason = this.request.loadInfo.requestBlockingReason;
    } catch (err) {
      // "cancelledByExtension" doesn't have to be available.
    }
```

We need to pass the data to `addResponseContent`

```
    this.httpActivity.owner.addResponseContent(response, {
      discardResponseBody: this.httpActivity.discardResponseBody,
      truncated: this.truncated,
      blockedReason: reason,
      blockingExtension: id,
    });
```

2) The `addResponseContent` needs to be updated to adopt the two new arguments
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/server/actors/network-monitor/network-event.js#504

Both arguments need to be emitted with all the other arguments.

3) Both argument types needs to be added to packet type definition
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/shared/specs/network-event.js#143-152

reason == number
extension id == string

4) The client side needs to read both arguments here
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/client/netmonitor/src/connector/firefox-data-provider.js#418-424

```
      case "responseContent":
        this.pushRequestToQueue(actor, {
          contentSize: networkInfo.response.bodySize,
          transferredSize: networkInfo.response.transferredSize,
          mimeType: networkInfo.response.content.mimeType,
          blockingExtension: packet.blockingExtension,
          blockedReason: packet.blockedReason,
        });
```

5) Rendering should happen in RequestListColumnTransferredSize
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/client/netmonitor/src/components/request-list/RequestListColumnTransferredSize.js#47

The two new props should be in `this.props`

    const {
      blockedReason,
      blockingExtension,
    } = this.props.item;

And the rendering logic needs to be updated to show the Extension ID
The column should render `Blocked by <ext-id>`

6) The `UPDATED_TRANSFERRED_PROPS` array needs to also have `responseContent` so, the column is rerendered when we send the packet from the backend.

7) Finally, `UPDATE_PROPS` array needs to also contain both new arguments   "blockedReason" and  "blockingExtension" 
https://searchfox.org/mozilla-central/rev/9e45d74b956be046e5021a746b0c8912f1c27318/devtools/client/netmonitor/src/constants.js#159

8) This also needs a test. You can take an inspiration from:
https://phabricator.services.mozilla.com/D57537#change-1UJmrASHGTxx

Honza

Back to Bug 1555057 Comment 17