Add a `:block <url>` command which matches Netmonitor's "Block URL" context menu entry
Categories
(DevTools :: Console, enhancement, P5)
Tracking
(firefox80 fixed)
Tracking | Status | |
---|---|---|
firefox80 | --- | fixed |
People
(Reporter: nchevobbe, Assigned: samarsault, NeedInfo)
References
Details
(Keywords: dev-doc-complete)
Attachments
(2 files)
Bug 1151368 added a Block URL
context menu entry, which appears when right-clicking a network message.
But this means you have to already done at least one request to the URL in order to be able to block it.
In the console, we could have a :block <url>
(later :block <domain>
, …) that does the same thing, except you can do it without having already done a request to the said URL.
We would also have an :unblock <url>
command, and we also could have a :block --list
(or/and :block -l
) to have the list of all the blocked URLs.
Reporter | ||
Comment 2•6 years ago
|
||
I don't think so, there probably be multiple parts between the client, the server, how commands work, … which would make it a bit difficult for a first patch.
Comment 4•6 years ago
|
||
A nice to have, P5 to make it available interested contributors. The better UI for this will be the request blocking feature in Network monitor.
Reporter | ||
Updated•6 years ago
|
Reporter | ||
Comment 6•5 years ago
•
|
||
Hello Samarjeet, thanks for helping!
The bug is now yours :)
The first thing to do would be to add these new commands in devtools/server/actors/webconsole/commands.js#7
Then we need to "register" them, like we do here for the :help
command devtools/server/actors/webconsole/utils.js#514-519.
This is where we're going to call the actual code to block the URL, and return an object that will indicate to the client that something happened.
In order to block/unblock URLS, we need to call the WebConsoleActor's method devtools/server/actors/webconsole.js#1875-1913 . So from the registerOriginal
method, we'd call owner.consoleActor.blockRequest(filter)
(and similarly for unblock
).
In the webconsole, when the user calls :block myurl.*
, we may want to indicate the URL was indeed blocked by putting a message like: Requests to "myurl.*" are now blocked.
.
This will be done in devtools/client/webconsole/actions/input.js#133, by dispatch a messagesAdd
call with the right message.
Then at some point, we'll have to update the netmonitor UI, but let's talk about it when the commands are working.
Let me know if you have any questions :)
Yeah, I'm done with all the other stuff you mentioned. The blocking/unblocking works however the netmonitor UI is not toggled automatically when I do this. Also, the url does not show in the UI.
Reporter | ||
Comment 8•5 years ago
|
||
I don't think we should switch to the netmonitor UI, but yeah, it should be reflected in the UI if the user try to display it.
Would you mind pushing your WIP patch to phabricator so we can test it and advise what we need to do now? :)
Assignee | ||
Comment 10•5 years ago
|
||
Also, I think it would be helpful if we could add a popup listing the blocked urls as we type ":unblock ."
Reporter | ||
Comment 11•5 years ago
|
||
(In reply to Samarjeet from comment #10)
Also, I think it would be helpful if we could add a popup listing the blocked urls as we type ":unblock ."
yes, that would be great. It's probably blocked on Bug 1482811 though, but somebody is working on this, and we should have support for autocompletion on any command (so we could autocomplete on :unblock
:) )
Assignee | ||
Comment 12•5 years ago
|
||
Comment 13•5 years ago
|
||
Comment 14•5 years ago
|
||
Backed out for devtools failures with getBlockedUrls
backout: https://hg.mozilla.org/integration/autoland/rev/6c793c062ea509611a6529038300559ac18c2f9b
failure log: https://treeherder.mozilla.org/logviewer.html#/jobs?job_id=302713118&repo=autoland&lineNumber=3029
[task 2020-05-18T10:01:10.728Z] 10:01:10 INFO - Buffered messages finished
[task 2020-05-18T10:01:10.732Z] 10:01:10 INFO - TEST-UNEXPECTED-FAIL | devtools/client/framework/test/browser_ignore_toolbox_network_requests.js | A promise chain failed to handle a rejection: Connection closed, pending request to server0.conn8.child2/consoleActor3, type getBlockedUrls failed
[task 2020-05-18T10:01:10.732Z] 10:01:10 INFO -
[task 2020-05-18T10:01:10.732Z] 10:01:10 INFO - Request stack:
[task 2020-05-18T10:01:10.733Z] 10:01:10 INFO - request@resource://devtools/shared/protocol/Front.js:256:14
[task 2020-05-18T10:01:10.733Z] 10:01:10 INFO - generateRequestMethods/</frontProto[name]@resource://devtools/shared/protocol/Front/FrontClassWithSpec.js:47:19
[task 2020-05-18T10:01:10.733Z] 10:01:10 INFO - getBlockedUrls@resource://devtools/client/netmonitor/src/connector/firefox-connector.js:349:33
[task 2020-05-18T10:01:10.734Z] 10:01:10 INFO - getBlockedUrls@resource://devtools/client/netmonitor/src/connector/index.js:100:27
[task 2020-05-18T10:01:10.734Z] 10:01:10 INFO - componentDidMount@resource://devtools/client/netmonitor/src/components/App.js:65:50
[task 2020-05-18T10:01:10.734Z] 10:01:10 INFO - commitLifeCycles@resource://devtools/client/shared/vendor/react-dom.js:12949:22
[task 2020-05-18T10:01:10.734Z] 10:01:10 INFO - commitAllLifeCycles@resource://devtools/client/shared/vendor/react-dom.js:14174:23
[task 2020-05-18T10:01:10.734Z] 10:01:10 INFO - commitRoot@resource://devtools/client/shared/vendor/react-dom.js:14380:28
[task 2020-05-18T10:01:10.735Z] 10:01:10 INFO - completeRoot/<@resource://devtools/client/shared/vendor/react-dom.js:15731:15
[task 2020-05-18T10:01:10.735Z] 10:01:10 INFO - unstable_runWithPriority@resource://devtools/client/shared/vendor/react.js:617:12
[task 2020-05-18T10:01:10.735Z] 10:01:10 INFO - completeRoot@resource://devtools/client/shared/vendor/react-dom.js:15730:27
[task 2020-05-18T10:01:10.736Z] 10:01:10 INFO - performWorkOnRoot@resource://devtools/client/shared/vendor/react-dom.js:15659:21
[task 2020-05-18T10:01:10.736Z] 10:01:10 INFO - performWork@resource://devtools/client/shared/vendor/react-dom.js:15567:24
[task 2020-05-18T10:01:10.736Z] 10:01:10 INFO - performSyncWork@resource://devtools/client/shared/vendor/react-dom.js:15541:14
[task 2020-05-18T10:01:10.737Z] 10:01:10 INFO - requestWork@resource://devtools/client/shared/vendor/react-dom.js:15410:5
[task 2020-05-18T10:01:10.737Z] 10:01:10 INFO - scheduleWork@resource://devtools/client/shared/vendor/react-dom.js:15224:16
[task 2020-05-18T10:01:10.737Z] 10:01:10 INFO - scheduleRootUpdate@resource://devtools/client/shared/vendor/react-dom.js:15865:15
[task 2020-05-18T10:01:10.738Z] 10:01:10 INFO - updateContainerAtExpirationTime@resource://devtools/client/shared/vendor/react-dom.js:15881:10
[task 2020-05-18T10:01:10.738Z] 10:01:10 INFO - updateContainer@resource://devtools/client/shared/vendor/react-dom.js:15908:10
[task 2020-05-18T10:01:10.738Z] 10:01:10 INFO - ReactRoot.prototype.render@resource://devtools/client/shared/vendor/react-dom.js:16133:18
[task 2020-05-18T10:01:10.738Z] 10:01:10 INFO - legacyRenderSubtreeIntoContainer/<@resource://devtools/client/shared/vendor/react-dom.js:16242:14
[task 2020-05-18T10:01:10.739Z] 10:01:10 INFO - unbatchedUpdates@resource://devtools/client/shared/vendor/react-dom.js:15772:10
[task 2020-05-18T10:01:10.739Z] 10:01:10 INFO - legacyRenderSubtreeIntoContainer@resource://devtools/client/shared/vendor/react-dom.js:16238:21
[task 2020-05-18T10:01:10.739Z] 10:01:10 INFO - render@resource://devtools/client/shared/vendor/react-dom.js:16289:12
[task 2020-05-18T10:01:10.739Z] 10:01:10 INFO - bootstrap@resource://devtools/client/netmonitor/src/app.js:77:11
[task 2020-05-18T10:01:10.740Z] 10:01:10 INFO - open@resource://devtools/client/netmonitor/panel.js:20:15
[task 2020-05-18T10:01:10.740Z] 10:01:10 INFO - asynconLoad@resource://devtools/client/framework/toolbox.js:2532:27
[task 2020-05-18T10:01:10.740Z] 10:01:10 INFO - - stack: destroy@resource://devtools/shared/protocol/Front.js:77:23
[task 2020-05-18T10:01:10.741Z] 10:01:10 INFO - destroy@resource://devtools/client/fronts/webconsole.js:608:18
[task 2020-05-18T10:01:10.741Z] 10:01:10 INFO - _destroyTarget@resource://devtools/client/fronts/targets/target-mixin.js:549:15
[task 2020-05-18T10:01:10.741Z] 10:01:10 INFO - destroy@resource://devtools/client/fronts/targets/target-mixin.js:534:12
[task 2020-05-18T10:01:10.742Z] 10:01:10 INFO - destroy@resource://devtools/client/fronts/targets/browsing-context.js:135:27
[task 2020-05-18T10:01:10.742Z] 10:01:10 INFO - _destroyToolbox/onceDestroyed</<@resource://devtools/client/framework/toolbox.js:3824:32
[task 2020-05-18T10:01:10.742Z] 10:01:10 INFO - promise callback_destroyToolbox/onceDestroyed<@resource://devtools/client/framework/toolbox.js:3789:12
[task 2020-05-18T10:01:10.742Z] 10:01:10 INFO - _destroyToolbox@resource://devtools/client/framework/toolbox.js:3785:27
[task 2020-05-18T10:01:10.743Z] 10:01:10 INFO - destroy@resource://devtools/client/framework/toolbox.js:3651:10
[task 2020-05-18T10:01:10.744Z] 10:01:10 INFO - @chrome://mochitests/content/browser/devtools/client/framework/test/browser_ignore_toolbox_network_requests.js:31:17
[task 2020-05-18T10:01:10.745Z] 10:01:10 INFO - Async*Tester_execTest/<@chrome://mochikit/content/browser-test.js:1064:34
[task 2020-05-18T10:01:10.745Z] 10:01:10 INFO - Tester_execTest@chrome://mochikit/content/browser-test.js:1104:11
[task 2020-05-18T10:01:10.746Z] 10:01:10 INFO - nextTest/<@chrome://mochikit/content/browser-test.js:927:14
[task 2020-05-18T10:01:10.747Z] 10:01:10 INFO - SimpleTest.waitForFocus/waitForFocusInner/focusedOrLoaded/<@chrome://mochikit/content/tests/SimpleTest/SimpleTest.js:918:23
[task 2020-05-18T10:01:10.747Z] 10:01:10 INFO - Rejection date: Mon May 18 2020 10:01:10 GMT+0000 (Coordinated Universal Time) - false == true - JS frame :: resource://testing-common/PromiseTestUtils.jsm :: assertNoUncaughtRejections :: line 265
Comment 15•5 years ago
|
||
Comment 16•5 years ago
|
||
Comment 17•5 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/d0d2d8dd2428
https://hg.mozilla.org/mozilla-central/rev/4f0e61814a27
Updated•5 years ago
|
Comment 18•5 years ago
|
||
Added :block
and :unblock
to the Web Console helpers list. Also added a note about them to the Blocking specific URLs section of the Network Monitor request list article.
Description
•