Closed Bug 1546394 Opened 5 years ago Closed 4 years ago

Add a `:block <url>` command which matches Netmonitor's "Block URL" context menu entry


(DevTools :: Console, enhancement, P5)



(firefox80 fixed)

Firefox 80
Tracking Status
firefox80 --- fixed


(Reporter: nchevobbe, Assigned: samarsault, NeedInfo)



(Keywords: dev-doc-complete)


(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.

Nicolas, could this be good first bug?

Flags: needinfo?(nchevobbe)

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.

Flags: needinfo?(nchevobbe)

How does that sound Harald?

Flags: needinfo?(hkirschner)

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.

Flags: needinfo?(hkirschner)
Priority: P3 → P5

I would like to work on this.

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 :)

Assignee: nobody → thelehhman

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.

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? :)

Also, I think it would be helpful if we could add a popup listing the blocked urls as we type ":unblock ."

(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 :) )

Pushed by
Adds :block <url> command similar to netmonitor r=nchevobbe
Netmonitor load blockedurls r=nchevobbe,bomsy

Backed out for devtools failures with getBlockedUrls



failure log:

[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
[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

Flags: needinfo?(thelehhman)
Pushed by
Adds :block <url> command similar to netmonitor r=nchevobbe
Netmonitor load blockedurls r=nchevobbe,bomsy,devtools-backward-compat-reviewers
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → Firefox 80

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.

You need to log in before you can comment on or make changes to this bug.