Commit 04a0ec29 authored by Nasko Oskov's avatar Nasko Oskov Committed by Commit Bot

Alter the WebUIReuseInSubframe test to avoid being flaky.

Unfortunately, the WebUIReuseInSubframe test is running into issues with
the memory allocator returning separate instances of WebUI objects at
the exact same memory address. This means that even though we have
different instances of the object, which is what the test aims to assert
it isn't possible to use pointer inequality as the assertion.
I've modified the test to use the RenderFrameHost global routing id
since one cannot have the same WebUI instance be owned by more than
one RenderFrameHost instance.

Bug: 713313, 1002276
Change-Id: Iea036b5cd10962c75f86a5b25d9f655012caf686
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1886292Reviewed-by: default avatarAaron Colwell <acolwell@chromium.org>
Commit-Queue: Nasko Oskov <nasko@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710440}
parent a5aa5e1c
......@@ -347,6 +347,8 @@ IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUIReuseInSubframe) {
scoped_refptr<SiteInstance> initial_site_instance =
child->current_frame_host()->GetSiteInstance();
WebUI* initial_web_ui = child->current_frame_host()->web_ui();
GlobalFrameRoutingId initial_rfh_id =
child->current_frame_host()->GetGlobalFrameRoutingId();
GURL subframe_same_site_url(GetWebUIURL("web-ui/title2.html"));
{
......@@ -373,6 +375,7 @@ IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUIReuseInSubframe) {
child->current_frame_host()->GetSiteInstance());
EXPECT_NE(root->current_frame_host()->web_ui(),
child->current_frame_host()->web_ui());
EXPECT_NE(initial_web_ui, child->current_frame_host()->web_ui());
// Capture the new SiteInstance and WebUI of the subframe and navigate it to
// another document on the same site.
......@@ -393,7 +396,8 @@ IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUIReuseInSubframe) {
EXPECT_EQ(second_web_ui, child->current_frame_host()->web_ui());
// Navigate back to the first document in the subframe, which should bring
// it back to the initial SiteInstance, but use a different WebUI instance.
// it back to the initial SiteInstance, but use a different RenderFrameHost
// and by that a different WebUI instance.
{
TestFrameNavigationObserver observer(child);
shell()->web_contents()->GetController().GoToOffset(-2);
......@@ -403,7 +407,14 @@ IN_PROC_BROWSER_TEST_F(WebUISecurityTest, WebUIReuseInSubframe) {
}
EXPECT_EQ(initial_site_instance,
child->current_frame_host()->GetSiteInstance());
EXPECT_NE(initial_web_ui, child->current_frame_host()->web_ui());
// Use routing id comparison for the RenderFrameHost as the memory allocator
// sometime places the newly created RenderFrameHost for the back navigation
// at the same memory location as the initial one. For this reason too, it
// is not possible to check the web_ui() for inequality, since in some runs
// the memory in which two different WebUI instances of the same type are
// placed is the same.
EXPECT_NE(initial_rfh_id,
child->current_frame_host()->GetGlobalFrameRoutingId());
}
// Verify that if one WebUI does a window.open() to another WebUI, then the two
......
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