Commit 6b141b1d authored by Andrey Kosyakov's avatar Andrey Kosyakov Committed by Commit Bot

DevTools: make interception respect cross-process frame boundaries

Use appropriate (pending) RenderFrameHost when choosing associated
RenderFrameDevToolsAgentHost in WillCreateURLLoaderFactory().

Change-Id: If72a7e056cea3f8a35f98564d9d3aed3e46f6e65
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1636684
Commit-Queue: Andrey Kosyakov <caseq@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665226}
parent 7e8ac7a2
......@@ -253,7 +253,7 @@ bool WillCreateURLLoaderFactory(
// Within the target, the agents added earlier are closer to network.
DevToolsAgentHostImpl* frame_agent_host =
RenderFrameDevToolsAgentHost::GetFor(rfh->frame_tree_node());
RenderFrameDevToolsAgentHost::GetFor(rfh);
RenderProcessHost* rph = rfh->GetProcess();
const base::UnguessableToken& frame_token = rfh->GetDevToolsFrameToken();
......
......@@ -120,6 +120,14 @@ DevToolsAgentHostImpl* RenderFrameDevToolsAgentHost::GetFor(
return FindAgentHost(frame_tree_node);
}
// static
DevToolsAgentHostImpl* RenderFrameDevToolsAgentHost::GetFor(
RenderFrameHostImpl* rfh) {
return ShouldCreateDevToolsForHost(rfh)
? FindAgentHost(rfh->frame_tree_node())
: GetFor(rfh->frame_tree_node());
}
scoped_refptr<DevToolsAgentHost> RenderFrameDevToolsAgentHost::GetOrCreateFor(
FrameTreeNode* frame_tree_node) {
frame_tree_node = GetFrameTreeNodeAncestor(frame_tree_node);
......
......@@ -45,6 +45,12 @@ class CONTENT_EXPORT RenderFrameDevToolsAgentHost
// Returns appropriate agent host for given frame tree node, traversing
// up to local root as needed.
static DevToolsAgentHostImpl* GetFor(FrameTreeNode* frame_tree_node);
// Returns appropriate agent host for given render frame host, traversing
// up to local root as needed. This will have an effect different from
// calling the above overload as GetFor(rfh->frame_tree_node()) when
// given RFH is a pending local root.
static DevToolsAgentHostImpl* GetFor(RenderFrameHostImpl* rfh);
// Similar to GetFor(), but creates a host if it doesn't exist yet.
static scoped_refptr<DevToolsAgentHost> GetOrCreateFor(
FrameTreeNode* frame_tree_node);
......
......@@ -6,13 +6,16 @@ crbug.com/922725 http/tests/media/autoplay/document-user-activation-cross-origin
crbug.com/910979 http/tests/html/validation-bubble-oopif-clip.html [ Failure ]
# These started failing when network service was enabled by default.
crbug.com/933880 external/wpt/FileAPI/url/cross-global-revoke.sub.html [ Failure ]
crbug.com/933880 external/wpt/FileAPI/url/url-with-fetch.any.html [ Failure ]
crbug.com/933880 external/wpt/FileAPI/url/url-with-xhr.any.html [ Failure ]
crbug.com/933880 external/wpt/service-workers/service-worker/request-end-to-end.https.html [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/interception-take-stream.js [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/raw-headers-for-protected-document.js [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/raw-headers-for-websocket.js [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/security-info-on-response.js [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/xhr-interception-auth-fail.js [ Failure ]
crbug.com/933880 http/tests/misc/redirect-to-about-blank.html [ Timeout ]
crbug.com/933880 external/wpt/FileAPI/url/cross-global-revoke.sub.html [ Failure ]
crbug.com/933880 external/wpt/FileAPI/url/url-with-fetch.any.html [ Failure ]
crbug.com/933880 external/wpt/FileAPI/url/url-with-xhr.any.html [ Failure ]
crbug.com/933880 external/wpt/service-workers/service-worker/request-end-to-end.https.html [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/interception-take-stream.js [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/raw-headers-for-protected-document.js [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/raw-headers-for-websocket.js [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/security-info-on-response.js [ Failure ]
crbug.com/933880 http/tests/inspector-protocol/network/xhr-interception-auth-fail.js [ Failure ]
crbug.com/933880 http/tests/misc/redirect-to-about-blank.html [ Timeout ]
# Test is for OOPIF-specific behavior.
Bug(none) http/tests/inspector-protocol/fetch/fetch-oopif.js [ Skip ]
Tests fetch interceptor respects cross-frame boundaries of out-of-process iframes.
Loading in-process iframe (script should be present)
Request to http://127.0.0.1:8000/inspector-protocol/fetch/resources/frame-with-subresource.html, type: Document
Request to http://127.0.0.1:8000/inspector-protocol/resources/dummy.js, type: Script
Loading out-of-process iframe (script should be absent)
Request to http://devtools.oopif-a.test:8000/inspector-protocol/fetch/resources/frame-with-subresource.html, type: Document
Loading out-of-process iframe with interception (script should be present)
Request to http://devtools.oopif-a.test:8000/inspector-protocol/fetch/resources/frame-with-subresource.html, type: Document
[subframe] Request to http://devtools.oopif-a.test:8000/inspector-protocol/resources/dummy.js, type: Script
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(
`Tests fetch interceptor respects cross-frame boundaries of out-of-process iframes.`);
const FetchHelper = await testRunner.loadScript('resources/fetch-test.js');
const helper = new FetchHelper(testRunner, dp);
await helper.enable();
helper.onRequest().continueRequest();
session.evaluate(`
function addFrame(url) {
const frame = document.createElement('iframe');
frame.src = url;
const promise = new Promise(fulfill => frame.addEventListener('load', fulfill));
document.body.appendChild(frame);
return promise;
}
`);
testRunner.log('\nLoading in-process iframe (script should be present)');
await session.evaluateAsync(`addFrame('${testRunner.url('resources/frame-with-subresource.html')}')`);
testRunner.log('\nLoading out-of-process iframe (script should be absent)');
await session.evaluateAsync(`addFrame('http://devtools.oopif-a.test:8000/inspector-protocol/fetch/resources/frame-with-subresource.html')`);
testRunner.log('\nLoading out-of-process iframe with interception (script should be present)');
await dp.Target.setAutoAttach({autoAttach: true, waitForDebuggerOnStart: true, flatten: true});
dp.Target.onAttachedToTarget(async event => {
const dp1 = session.createChild(event.params.sessionId).protocol;
const subframeFetcher = new FetchHelper(testRunner, dp1);
subframeFetcher.setLogPrefix("[subframe] ");
await subframeFetcher.enable();
subframeFetcher.onRequest().continueRequest({});
dp1.Runtime.runIfWaitingForDebugger();
});
await session.evaluateAsync(`addFrame('http://devtools.oopif-a.test:8000/inspector-protocol/fetch/resources/frame-with-subresource.html')`);
testRunner.completeTest();
})
<html>
<body>
<script src="/inspector-protocol/resources/dummy.js"></script>
</body>
</html>
\ No newline at end of file
<body>Hello World!</body>
<body>Hello World!
<img src="image.png"></img>
</body>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment