Add support network response override for any request in the netmonitor
Categories
(DevTools :: Netmonitor, enhancement)
Tracking
(relnote-firefox ?, firefox137 fixed)
People
(Reporter: bomsy, Assigned: jdescottes)
References
(Blocks 1 open bug)
Details
(Keywords: dev-doc-needed)
Attachments
(7 files, 5 obsolete files)
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review | |
48 bytes,
text/x-phabricator-request
|
Details | Review |
Currently we can't local override html files as this is disabled for those.
This is because the current approach for local overrides crashes for html files.
Linking to comment which might be useful when fixing https://phabricator.services.mozilla.com/D163600#anchor-inline-931473
Assignee | ||
Comment 1•8 months ago
|
||
Note that Channel's setResponseOverride added in Bug 1900375 should allow you to override any resource.
The downside at the moment is that the netmonitor will fail to get the response updates for the request.
Although we might be able to fix that when the override is created from devtools.
Assignee | ||
Comment 2•8 months ago
•
|
||
Note that in some cases (eg https://stuff.overengineer.dev/mozilla/testcases/devtools-script-override-sri/) the HTML does not contain any script, so we can't override it from the debugger because we can't see it in the source tree.
Assignee | ||
Comment 3•7 months ago
|
||
Trying to consider what a minimal effort solution could be done here, I would propose to:
- add a resource (or events) to monitor overridden URLs
- update the debugger frontend to use this resource to maintain
mutableOverrideSources
- add a isOverridden flag on network events
- update netmonitor UI to show network requests with isOverridden slightly differently (eg same dot icon as in the debugger + maybe say "overridden" in the transferred column)
- add a context menu item in the network monitor to set and clear an override
- finally, lift the restriction in the debugger UI to only set an override on non-HTML sources
Alex, how does that sound to you as a first step here to unlock the feature?
Comment 4•7 months ago
|
||
I'm only wondering about the two first bullet points. The word "resource" sounds weird as resources are typically created and managed by the server, whereas here it sounds like a frontend-only thing.
This rather reminds me the pattern used for DOM Mutation Breakpoints, where we need to share them between Inspector and Debugger.
For that we have a "toolbox" store in order to share the dom-mutation-breakpoints reducer between many panels:
https://searchfox.org/mozilla-central/source/devtools/client/framework/reducers/dom-mutation-breakpoints.js
This data is being used by the frontend over these:
https://searchfox.org/mozilla-central/source/devtools/client/debugger/src/components/SecondaryPanes/DOMMutationBreakpoints.js#146
https://searchfox.org/mozilla-central/source/devtools/client/inspector/markup/markup.js#435
(this really should be used selectors so that we easily know where this is being used...)
I imagine we could follow the same technique in order to share the currently overriden sources in React codebases of Debugger and Netmonitor.
The debugger already registers the two distinct stores:
https://searchfox.org/mozilla-central/rev/de46cd99a7d1634058b511a3f546a970763e5048/devtools/client/debugger/src/utils/bootstrap.js#91-97
(The inspector does weird things as it's not yet full react)
I imagine we would have to tweak that over there for making it word for the Netmonitor:
https://searchfox.org/mozilla-central/rev/de46cd99a7d1634058b511a3f546a970763e5048/devtools/client/netmonitor/src/app.js#76
Otherwise the overall plan sounds good to me. As soon we are confident that we can't set an override which would cause the request to disappear from the netmonitor, it all sounds good. Otherwise, if we aren't, we should prioritize having a panel showing the overrides.
Assignee | ||
Comment 5•7 months ago
|
||
(In reply to Alexandre Poirot [:ochameau] from comment #4)
I'm only wondering about the two first bullet points. The word "resource" sounds weird as resources are typically created and managed by the server, whereas here it sounds like a frontend-only thing.
Ah interesting, it felt really more natural for me to design it as a server-owned resource.
In practice the overrides are owned by the server:
- the source of truth for the list of overrides is the NetworkObserver's #overrides map
- the command to set / remove an override routes it to the network front: https://searchfox.org/mozilla-central/rev/de46cd99a7d1634058b511a3f546a970763e5048/devtools/client/debugger/src/client/firefox/commands.js#448-465, and then the corresponding actor calls the necessary API on its NetworkObserver
But I guess it's the same for DOM Mutation breakpoints, they must be at some point sent to the server and persisted there. So in this context "frontend-only" probably means "something that can only be set / updated by the devtools frontend", which is true at the moment.
The thing I like with the resource approach here, is that we make it clear that the source of truth for the information is the server. The frontend can consume it as it wants via watchResources, and update it via commands. There is no dependency on react/reducers/actions/etc, just watcher + commands, which feels like a simpler architecture. I think it's also more future proof. If we ever want to share the overrides between toolboxes for instance.
I'm OK with skipping the resource bit and instead having a shared reducer for this, given that it's similar to mutation breakpoints.
I would still be curious to discuss about using resources for things which are frontend driven but stored on the server. It still sounds very compelling to me to use the commands + resource pattern to handle them consistently with the rest of the codebase.
Assignee | ||
Comment 6•6 months ago
|
||
Assignee | ||
Comment 7•6 months ago
|
||
Depends on D219229
Updated•6 months ago
|
Comment 8•6 months ago
|
||
Comment on attachment 9419235 [details]
Bug 1849920 - [devtools] Move the network overrides to a shared toolbox reducer
Revision D219235 was moved to bug 1914657. Setting attachment 9419235 [details] to obsolete.
Assignee | ||
Comment 9•2 months ago
|
||
Depends on D219220
Assignee | ||
Comment 10•2 months ago
|
||
Depends on D232349
Assignee | ||
Comment 11•2 months ago
|
||
Depends on D232349
Assignee | ||
Comment 12•2 months ago
|
||
Depends on D232350
Assignee | ||
Updated•1 month ago
|
Assignee | ||
Comment 13•1 month ago
|
||
The individual input selectors of reselect selectors should be as close as possible to the
data used by the selector, so that we can efficiently memoize the selector.
Since this selector returns an object which will always fail shallow comparisons it's important to
make sure we memoize efficiently.
Assignee | ||
Comment 14•1 month ago
|
||
Depends on D234517
Update input selectors to memoize selector functions more efficiently.
Assignee | ||
Comment 15•1 month ago
|
||
Depends on D234519
Assignee | ||
Comment 16•1 month ago
|
||
Depends on D234519
Comment 17•1 month ago
|
||
Comment on attachment 9459928 [details]
Bug 1849920 - [devtools] Fix memoization issues for netmonitor getColumns selector
Revision D234517 was moved to bug 1943339. Setting attachment 9459928 [details] to obsolete.
Comment 18•1 month ago
|
||
Comment on attachment 9459931 [details]
Bug 1849920 - [devtools] Update netmonitor requests selectors to improve memoization
Revision D234519 was moved to bug 1943339. Setting attachment 9459931 [details] to obsolete.
Comment 19•1 month ago
|
||
Comment on attachment 9460238 [details]
Bug 1849920 - [devtools] Improve request selectors to avoid rebuilding filters for each request
Revision D234704 was moved to bug 1943339. Setting attachment 9460238 [details] to obsolete.
Comment 20•1 month ago
|
||
Comment on attachment 9459934 [details]
Bug 1849920 - [devtools] Avoid unnecessary renders due to blockedUrls prop
Revision D234521 was moved to bug 1943339. Setting attachment 9459934 [details] to obsolete.
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•1 month ago
|
Updated•29 days ago
|
Updated•29 days ago
|
Updated•29 days ago
|
Updated•29 days ago
|
Assignee | ||
Comment 21•29 days ago
|
||
Depends on D233302
Assignee | ||
Comment 22•29 days ago
|
||
Depends on D235540
Comment 23•16 days ago
|
||
Comment 24•16 days ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d76ca7f0f8b9
https://hg.mozilla.org/mozilla-central/rev/00353ba2d76d
https://hg.mozilla.org/mozilla-central/rev/5cf978e01585
https://hg.mozilla.org/mozilla-central/rev/ffc748fee434
https://hg.mozilla.org/mozilla-central/rev/fa63c9600a64
https://hg.mozilla.org/mozilla-central/rev/bcec102004cd
https://hg.mozilla.org/mozilla-central/rev/e9742b2e36d9
Comment 26•5 days ago
|
||
As far as I can see, this change not just allows local overrides for HTML files but also adds a UI to the Netmonitor for all kinds of overrides. And this new feature is not behind a pref. Julian, is that correct?
If so, I think this should be mentioned in the developer release notes as well as the Firefox release notes for 137.
Sebastian
Assignee | ||
Comment 27•5 days ago
|
||
Yes to all questions. And good point, we should definitely add it to the release notes. FWIW I just added user docs via Bug 1948304 and I'm planning a blog post on fxdx.dev to publish in time for 137 release.
Assignee | ||
Updated•5 days ago
|
Comment 28•5 days ago
|
||
Fantastic! So let's add the required flags and comments, so it's not missed.
Release Note Request (optional, but appreciated)
[Why is this notable]: Allows local overrides from within the Netmonitor.
[Affects Firefox for Android]: no
[Suggested wording]: The Netmonitor now allows to override network request responses with local files.
[Links (documentation, blog post, etc)]: TBD, see Julian's comment above.
Sebastian
Comment 29•3 days ago
|
||
Julian, do you mean the Network panel in Developer tools when you say Netmonitor? Should there be a screenshot of the feature? Thanks
Assignee | ||
Comment 30•3 days ago
|
||
(In reply to Pascal Chevrel:pascalc from comment #29)
Julian, do you mean the Network panel in Developer tools when you say Netmonitor? Should there be a screenshot of the feature? Thanks
Yes sorry I meant the Network panel (we call it netmonitor in the codebase).
There are a few screenshots at https://firefox-source-docs.mozilla.org/devtools-user/network_monitor/network_overrides/index.html which we could reuse?
Maybe the first one.
Comment 31•3 days ago
|
||
Added with a screenshot and this wording:
The Network panel now allows overriding network request responses with local files.
I can add a link to the blog post when available, just ping me in this bug.
I am keeping the relnote flag open until we ship the feature to the release channel
Thanks!
Description
•