Commit 2371b2ac authored by Andrey Lushnikov's avatar Andrey Lushnikov Committed by Commit Bot

DevTools: force-create execution contexts for mixed content iframes

This patch starts creating execution contexts for iframes that didn't
commit initial successful loading. This is a common situation for
iframes which navigation was blocked due to mixed content.

R=dgozman
BUG=854051

Change-Id: Ia1c39af39c1c99f20e69abfae48579ac1bc09021
Reviewed-on: https://chromium-review.googlesource.com/1102154
Commit-Queue: Andrey Lushnikov <lushnikov@chromium.org>
Reviewed-by: default avatarDmitry Gozman <dgozman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#568341}
parent 69309ed8
Tests that execution contexts are reported for iframes that don't have src attribute.
{
method : Runtime.executionContextCreated
params : {
context : {
auxData : {
frameId : <string>
isDefault : true
}
id : <number>
name :
origin : http://devtools.test:8000
}
}
}
{
method : Runtime.executionContextCreated
params : {
context : {
auxData : {
frameId : <string>
isDefault : true
}
id : <number>
name :
origin : http://devtools.test:8000
}
}
}
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(
`Tests that execution contexts are reported for iframes that don't have src attribute.`);
await page.navigate('http://devtools.test:8000/inspector-protocol/resources/iframe-no-src.html');
dp.Runtime.onExecutionContextCreated(event => {
testRunner.log(event);
});
await dp.Runtime.enable();
testRunner.completeTest();
})
Tests that execution contexts are reported for frames that were blocked due to mixed content when runtime is enabled *before* navigation.
{
method : Runtime.executionContextCreated
params : {
context : {
auxData : {
frameId : <string>
isDefault : true
}
id : <number>
name :
origin : https://devtools.test:8443
}
}
}
{
method : Runtime.executionContextCreated
params : {
context : {
auxData : {
frameId : <string>
isDefault : true
}
id : <number>
name :
origin : https://devtools.test:8443
}
}
}
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(
`Tests that execution contexts are reported for frames that were blocked due to mixed content when runtime is enabled *before* navigation.`);
await dp.Runtime.enable();
dp.Runtime.onExecutionContextCreated(event => {
testRunner.log(event);
});
await page.navigate('https://devtools.test:8443/inspector-protocol/resources/mixed-content.html');
testRunner.completeTest();
})
Tests that execution contexts are reported for frames that were blocked due to mixed content when Runtime is enabled *after* navigation.
{
method : Runtime.executionContextCreated
params : {
context : {
auxData : {
frameId : <string>
isDefault : true
}
id : <number>
name :
origin : https://devtools.test:8443
}
}
}
{
method : Runtime.executionContextCreated
params : {
context : {
auxData : {
frameId : <string>
isDefault : true
}
id : <number>
name :
origin : https://devtools.test:8443
}
}
}
(async function(testRunner) {
const {page, session, dp} = await testRunner.startBlank(
`Tests that execution contexts are reported for frames that were blocked due to mixed content when Runtime is enabled *after* navigation.`);
await page.navigate('https://devtools.test:8443/inspector-protocol/resources/mixed-content.html');
dp.Runtime.onExecutionContextCreated(event => {
testRunner.log(event);
});
await dp.Runtime.enable();
testRunner.completeTest();
})
<iframe src='http://devtools.test:8000/inspector-protocol/resources/iframe.html'></iframe>
...@@ -1398,6 +1398,17 @@ void FrameLoader::ClientDroppedNavigation() { ...@@ -1398,6 +1398,17 @@ void FrameLoader::ClientDroppedNavigation() {
return; return;
DetachProvisionalDocumentLoader(provisional_document_loader_); DetachProvisionalDocumentLoader(provisional_document_loader_);
// Forcibly instantiate WindowProxy for initial frame document.
// This is only required when frame navigation is aborted, e.g. due to
// mixed content.
// TODO(lushnikov): this should be done in Init for initial empty doc, but
// that breaks extensions abusing SetForceMainWorldInitialization setting
// and relying on the number of created window proxies.
Settings* settings = frame_->GetSettings();
if (settings && settings->GetForceMainWorldInitialization()) {
// Forcibly instantiate WindowProxy.
frame_->GetScriptController().WindowProxy(DOMWrapperWorld::MainWorld());
}
} }
void FrameLoader::StartLoad(FrameLoadRequest& frame_load_request, void FrameLoader::StartLoad(FrameLoadRequest& frame_load_request,
......
...@@ -618,9 +618,9 @@ void Page::SettingsChanged(SettingsDelegate::ChangeType change_type) { ...@@ -618,9 +618,9 @@ void Page::SettingsChanged(SettingsDelegate::ChangeType change_type) {
if (!frame->IsLocalFrame()) if (!frame->IsLocalFrame())
continue; continue;
LocalFrame* local_frame = ToLocalFrame(frame); LocalFrame* local_frame = ToLocalFrame(frame);
if (local_frame->Loader() if (!local_frame->Loader()
.StateMachine() .StateMachine()
->CommittedFirstRealDocumentLoad()) { ->CreatingInitialEmptyDocument()) {
// Forcibly instantiate WindowProxy. // Forcibly instantiate WindowProxy.
local_frame->GetScriptController().WindowProxy( local_frame->GetScriptController().WindowProxy(
DOMWrapperWorld::MainWorld()); DOMWrapperWorld::MainWorld());
......
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