You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am testing this simple example that uses Fetch.failRequest to block an url. To test it, launch a chrome using the flags --remote-debugging-port=9222 https://example.com, then run the example script.
Now try clicking the More information... link while holding CTRL to make it open in a new tab. The new tab loads the url when it should be blocked, if you press F5, the url is correctly blocked. Fetch.requestPaused is being triggered for the stylesheets and js files, but not for the main request.
waitForDebuggerOnStart on Target.setAutoAttach doesn't seem to be doing anything since I am not having to send Runtime.runIfWaitingForDebugger.
In the title i meant Fetch.enable
How can I make the Fetch.failRequest work on new tabs for the initial request?
Example
constCDP=require('chrome-remote-interface');asyncfunctionstart(){constclient=awaitCDP();const{ Target }=client;Target.setDiscoverTargets({discover: true});Target.setAutoAttach({autoAttach: true,waitForDebuggerOnStart: true,flatten: true});Target.attachedToTarget(async(params)=>{console.log('attached',params);client.send('Fetch.enable',{patterns: [{urlPattern: "https://www.iana.org/*"}]// url to block},params.sessionId)});Target.targetCreated(async(params)=>{// without this attachedToTarget doesn't triggerif(params.targetInfo.type!='page')return;console.log("created",params);Target.attachToTarget({targetId: params.targetInfo.targetId,flatten: true})});client.on('event',(message)=>{if(message.method=='Fetch.requestPaused'){console.log('blocking',message);client.send('Fetch.failRequest',{requestId: message.params.requestId,errorReason: 'BlockedByResponse'},message.sessionId)}});}start();
The text was updated successfully, but these errors were encountered:
Environment
Is the client running in a container? NO
Description
I am testing this simple example that uses
Fetch.failRequest
to block an url. To test it, launch a chrome using the flags--remote-debugging-port=9222 https://example.com
, then run the example script.Now try clicking the More information... link while holding
CTRL
to make it open in a new tab. The new tab loads the url when it should be blocked, if you press F5, the url is correctly blocked.Fetch.requestPaused
is being triggered for the stylesheets and js files, but not for the main request.waitForDebuggerOnStart
onTarget.setAutoAttach
doesn't seem to be doing anything since I am not having to sendRuntime.runIfWaitingForDebugger
.In the title i meant
Fetch.enable
How can I make the
Fetch.failRequest
work on new tabs for the initial request?Example
The text was updated successfully, but these errors were encountered: