New issue
Advanced search Search tips

Issue 694547 link

Starred by 5 users

Issue metadata

Status: Fixed
Owner: ----
Closed: Jun 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: ----
Type: ----

Blocked on:
issue 702384



Sign in to add a comment

Intercept requests over devtools protocol in headless Chrome

Reported by fastest...@gmail.com, Feb 21 2017

Issue description

As mentioned in the headless-dev group: https://groups.google.com/a/chromium.org/d/msg/headless-dev/uht9BW6suA8/Vanh_n9RDgAJ

I'd like to be able to intercept and reply to requests via the Chrome Devtools Protocol. While writing my own C++ library is possible, I would prefer to use the Node.js library I'm already using rather than learn C++ and the Chromium internals.

Being able to intercept and reply to requests would allow us to make our tests more predictable by ensuring that all third-party calls and responses are predictable and don't actually hit third-party servers.

 
Cc: dgozman@chromium.org pfeldman@chromium.org
Status: Available (was: Unconfirmed)
+DevTools folks to gauge if this causes allergic reactions :)
Does the webRequest API work for you? I think you can redirect to data url with whatever content is requried.
https://developer.chrome.com/extensions/webRequest
That was an option I looked into but I wasn't sure how redirecting to a data uri will affect CORS, iFrame origin, and how it could work for non-200 statuses.
Did you consider running the browser against proxy for the testing purposes?
Yeah what we're debating doing in the near-term is running headless chrome with something like: "--allow-running-insecure-content --reduce-security-for-testing --proxy-server 127.0.0.1:8800". But we haven't figured out how much the broken SSL will affect us, especially when it comes to HSTS-preloaded sites.
Blockedon: 702384
Components: Internals>Headless
Status: Fixed (was: Available)
This is now available.
Project Member

Comment 9 by bugdroid1@chromium.org, Aug 25 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285

commit 241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285
Author: Nathan Bruer <allada@chromium.org>
Date: Fri Aug 25 15:40:12 2017

[Devtools] Request interception will now forwards based on patterns.

Changed protocol to now use pattern matching to forward only requests
that match a pattern provided over protocol instead of all requests.
This should increase the stalled speed a bit.

R=dgozman,caseq,pfeldman
BUG= 752617 , 702384 , 694547 

Change-Id: I4df44475023c9d275bb6818f4270620945d0c7bd
Reviewed-on: https://chromium-review.googlesource.com/602483
Commit-Queue: Blaise Bruer <allada@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#497419}
[modify] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/content/browser/devtools/devtools_url_request_interceptor.cc
[modify] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/content/browser/devtools/devtools_url_request_interceptor.h
[modify] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/content/browser/devtools/protocol/network_handler.cc
[modify] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/content/browser/devtools/protocol/network_handler.h
[modify] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/content/public/test/test_browser_context.cc
[modify] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/content/public/test/test_browser_context.h
[add] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/network/request-interception-patterns-expected.txt
[add] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/network/request-interception-patterns.js
[add] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/network/resources/small-test-1.txt
[add] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/third_party/WebKit/LayoutTests/http/tests/inspector-protocol/network/resources/small-test-2.txt
[modify] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/third_party/WebKit/Source/core/inspector/browser_protocol.json
[modify] https://crrev.com/241c6b4df3f4c0b93d783ed2b5b8b448e4e2d285/third_party/WebKit/Source/devtools/front_end/sdk/NetworkManager.js

Sign in to add a comment