Open Bug 1572223 Opened 5 years ago Updated 2 years ago

Requests to custom protocols should appear in network panel

Categories

(WebExtensions :: Experiments, enhancement, P3)

enhancement

Tracking

(Not tracked)

People

(Reporter: irakli, Unassigned)

References

(Blocks 1 open bug, )

Details

At the moment requests to protocols that are registered via [experimental protocol API] (https://bugzilla.mozilla.org/show_bug.cgi?id=libdweb-protocol) do not appear in networking. They should just like other requests.

:honza I remember we chatted about this during last all hands, if I recall correctly it was supposed to be relatively easy to fix but sadly I do not remember any details. Could you please remind me what do we need to do to make requests to custom nsIProtocolHandler appear in the network panel ?

Thanks

Flags: needinfo?(odvarko)

Hey Irakli!

Some pointers to the code base.

  1. The entire DevTools backend implementation for the Network panel is in this dir:
    https://searchfox.org/mozilla-central/source/devtools/server/actors/network-monitor

  2. The backend is listening to standard HTTP requests, and proper listeners are registered here:
    https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#228-253

We mostly use HTTP-* observer notifications

  • http-on-examine-response
  • http-on-examine-cached-response
  • http-on-modify-request
  • http-on-failed-opening-request

But, there is also notification from workers:

  • service-worker-synthesized-response

If you have specific notification about a request you could add a new listener here.

  1. We are also using nsIHttpActivityDistributor to track HTTP activity.
    The observer for this activity is added here:
    https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#229

  2. When a new HTTP request is noticed, we create an "activity object" that is used to track the request and collect all data related to it.

https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#591

We are storing all these activity objects in a map where key is the nsIHttpChannel
There is a helper _findActivityObject that can be used to get an activity object for specific channel
https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#729

  1. So, for example, when new HTTP request is created we call _createNetworkEvent, which produces that activity object (if it doesn't exist yet)
    https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#719-726

This method also sends RDP packet to the client, so the new request appears in the Network panel

httpActivity.owner = this.owner.onNetworkEvent(event);
httpActivity.owner.addRequestHeaders(headers, extraStringData);
httpActivity.owner.addRequestCookies(cookies);
  • add request headers and sent it to the client
  • add request cookies headers and sent it to the client

https://searchfox.org/mozilla-central/rev/9ae20497229225cb3fa729a787791f424ff8087b/devtools/server/actors/network-monitor/network-observer.js#696-703

  1. There are other various helpers in the network-monitor directory used to track response bodies, JS stack-trace, etc.

  2. The goal here should be to hook into new events and plugin into the existing architecture.

Something like as follows:

  • hook to new listeners/observers
  • track when a new request appears
  • create new activity object
  • send custom data to the client (network panel).
  • New API might be introduced in httpActivity.owner (see comment #5) - this would also mean to introduce new RDP packets, but this is very simple. For example this patch [1] sends a new 'isRacing' flag from the backend to the client.

[1] https://github.com/mozilla/gecko-dev/commit/67808459acd383c95ea1c69c6cf69a55d719d0d0#diff-a116b5da4eba595e56d7b90a04bd3915

Honza

Flags: needinfo?(odvarko)
Priority: -- → P3
Severity: normal normal → S3 S3
You need to log in before you can comment on or make changes to this bug.