Open ankur22 opened 1 year ago
Researching about how to block a blacklist through CDP
That's a good find, could be useful in the future!
I found the Fetch domain, which probably would allows us to implement the "hosts" functionality with an already launched browser
We use fetch already so we should be able to fit that in quite easily.
Brief summary
Try to run
examples/hosts.js
and it should not be able to navigate totest.k6.io
since thehosts
option has been used so thattest.k6.io
resolves to127.0.0.254
. This is the expected behaviour when working with this example file.If we change the script so that it
connect
s to an already browser instance, then the browser will resolve to the actualtest.k6.io
ip address, and not to127.0.0.254
, which is the incorrect behaviour for this example file.The reason the behaviour is incorrect when testing on an already running browser instance, is because the k6
hosts
option ink6-browser
uses Chromium's--host-resolver-rules
in the background to resolve hosts to a given IP. If the browser is already running then how can we inject this rule?xk6-browser version
48ee41a59e0f0561dbcae39b91dc6fba338422a4
OS
NA
Chrome version
Version 110.0.5481.177 (Official Build) (arm64)
Docker version and image (if applicable)
NA
Steps to reproduce the problem
examples/hosts.js
file toconnect
to the running browser instance from the previous step.examples/hosts.js
file.Expected behaviour
The test should pass since
test.k6.io
resolves to127.0.0.254
.Actual behaviour
The test fails since it resolves to the actual IP address of
test.k6.io
.