Commit f9181ba6 authored by Dave Tapuska's avatar Dave Tapuska Committed by Commit Bot

Change test to pass opener when creating the Remote frame test.

http://crrev.com/ece078e2 attempted to clean up some SameOrigin checks
and it was discovered that WebFrameTest.NavigateRemoteToLocalWithOpener
was creating an invalid state where the Remote Frame's opener was
set after creation time which caused the WindowAgentFactory to be
different. Expose the opener parameter for RemoteFrame in FrameTestHelpers
much like it is done for LocalFrames.

BUG=1031480

Change-Id: Iacb3b34489999bb855064490d9448cafe22da1cd
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1955654Reviewed-by: default avatarDaniel Cheng <dcheng@chromium.org>
Commit-Queue: Dave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722500}
parent 83b53b51
......@@ -9608,10 +9608,9 @@ TEST_F(WebFrameTest, NavigateRemoteToLocalWithOpener) {
// Create a popup with a remote frame and set its opener to the main frame.
frame_test_helpers::WebViewHelper popup_helper;
popup_helper.InitializeRemote(
nullptr, SecurityOrigin::CreateFromString("http://foo.com"));
popup_helper.InitializeRemoteWithOpener(
main_frame, nullptr, SecurityOrigin::CreateFromString("http://foo.com"));
WebRemoteFrame* popup_remote_frame = popup_helper.RemoteMainFrame();
popup_remote_frame->SetOpener(main_frame);
EXPECT_FALSE(main_frame->GetSecurityOrigin().CanAccess(
popup_remote_frame->GetSecurityOrigin()));
......
......@@ -398,6 +398,16 @@ WebViewImpl* WebViewHelper::InitializeAndLoad(
}
WebViewImpl* WebViewHelper::InitializeRemote(
TestWebRemoteFrameClient* client,
scoped_refptr<SecurityOrigin> security_origin,
TestWebViewClient* web_view_client,
TestWebWidgetClient* web_widget_client) {
return InitializeRemoteWithOpener(nullptr, client, security_origin,
web_view_client, web_widget_client);
}
WebViewImpl* WebViewHelper::InitializeRemoteWithOpener(
WebFrame* opener,
TestWebRemoteFrameClient* web_remote_frame_client,
scoped_refptr<SecurityOrigin> security_origin,
TestWebViewClient* web_view_client,
......@@ -412,7 +422,7 @@ WebViewImpl* WebViewHelper::InitializeRemote(
WebRemoteFrameImpl* frame = WebRemoteFrameImpl::CreateMainFrame(
web_view_, web_remote_frame_client,
InterfaceRegistry::GetEmptyInterfaceRegistry(),
web_remote_frame_client->GetAssociatedInterfaceProvider(), nullptr);
web_remote_frame_client->GetAssociatedInterfaceProvider(), opener);
web_remote_frame_client->Bind(frame,
std::move(owned_web_remote_frame_client));
if (!security_origin)
......
......@@ -348,14 +348,22 @@ class WebViewHelper : public ScopedMockOverlayScrollbars {
TestWebWidgetClient* = nullptr,
void (*update_settings_func)(WebSettings*) = nullptr);
// Creates and initializes the WebView with a main WebRemoteFrame. Passing
// nullptr as the SecurityOrigin results in a frame with a unique security
// origin.
// Same as InitializeRemoteWithOpener(), but always sets the opener to null.
WebViewImpl* InitializeRemote(TestWebRemoteFrameClient* = nullptr,
scoped_refptr<SecurityOrigin> = nullptr,
TestWebViewClient* = nullptr,
TestWebWidgetClient* = nullptr);
// Creates and initializes the WebView with a main WebRemoteFrame. Passing
// nullptr as the SecurityOrigin results in a frame with a unique security
// origin.
WebViewImpl* InitializeRemoteWithOpener(
WebFrame* opener,
TestWebRemoteFrameClient* = nullptr,
scoped_refptr<SecurityOrigin> = nullptr,
TestWebViewClient* = nullptr,
TestWebWidgetClient* = nullptr);
// Load the 'Ahem' font to this WebView.
// The 'Ahem' font is the only font whose font metrics is consistent across
// platforms, but it's not guaranteed to be available.
......
......@@ -327,14 +327,6 @@ bool SecurityOrigin::CanAccess(const SecurityOrigin* other,
return true;
}
// TODO(1027191): We need to exit early in this case, as it looks like we're
// not correctly persisting the `agent_cluster_id_` when swapping from a
// remote to local frame (see `WebFrameTest.NavigateRemoteToLocalWithOpener`).
if (IsOpaque() || other->IsOpaque()) {
detail = AccessResultDomainDetail::kDomainNotRelevant;
return nonce_if_opaque_ == other->nonce_if_opaque_;
}
bool can_access = IsSameOriginDomainWith(other, detail);
// Compare that the clusters are the same.
......
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