Commit e9fdd779 authored by Lucas Furukawa Gadani's avatar Lucas Furukawa Gadani Committed by Commit Bot

Portals: Remove FrameTreeNode when detaching portal from outer WebContents.

Bug: 973542
Change-Id: Ib0b4768644c8c2ca2f3c42626a797a1203b6b55a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1650530
Commit-Queue: Lucas Gadani <lfg@chromium.org>
Reviewed-by: default avatarCharlie Reis <creis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668504}
parent 2ae47e4e
......@@ -193,8 +193,11 @@ void Portal::Activate(blink::TransferableMessage data,
WebContentsDelegate* delegate = outer_contents->GetDelegate();
bool is_loading = portal_contents_impl_->IsLoading();
FrameTreeNode* outer_frame_tree_node = FrameTreeNode::GloballyFindByID(
portal_contents_impl_->GetOuterDelegateFrameTreeNodeId());
std::unique_ptr<WebContents> portal_contents =
portal_contents_impl_->DetachFromOuterWebContents();
owner_render_frame_host_->RemoveChild(outer_frame_tree_node);
auto* outer_contents_main_frame_view = static_cast<RenderWidgetHostViewBase*>(
outer_contents->GetMainFrame()->GetView());
......
......@@ -584,6 +584,45 @@ IN_PROC_BROWSER_TEST_F(PortalBrowserTest, TouchAckAfterActivate) {
input_event_ack_waiter.Wait();
}
// Tests that the outer FrameTreeNode is deleted after activation.
IN_PROC_BROWSER_TEST_F(PortalBrowserTest, FrameDeletedAfterActivation) {
EXPECT_TRUE(NavigateToURL(
shell(), embedded_test_server()->GetURL("portal.test", "/title1.html")));
WebContentsImpl* web_contents_impl =
static_cast<WebContentsImpl*>(shell()->web_contents());
RenderFrameHostImpl* main_frame = web_contents_impl->GetMainFrame();
Portal* portal = nullptr;
{
PortalCreatedObserver portal_created_observer(main_frame);
GURL a_url(embedded_test_server()->GetURL("a.com", "/title1.html"));
EXPECT_TRUE(ExecJs(
main_frame, JsReplace("var portal = document.createElement('portal');"
"portal.src = $1;"
"document.body.appendChild(portal);",
a_url)));
portal = portal_created_observer.WaitUntilPortalCreated();
}
WebContentsImpl* portal_contents = portal->GetPortalContents();
// The portal should not have navigated yet; wait for the first navigation.
TestNavigationObserver navigation_observer(portal_contents);
navigation_observer.Wait();
FrameTreeNode* outer_frame_tree_node = FrameTreeNode::GloballyFindByID(
portal_contents->GetOuterDelegateFrameTreeNodeId());
EXPECT_TRUE(outer_frame_tree_node);
EXPECT_TRUE(ExecJs(portal_contents->GetMainFrame(),
"window.onportalactivate = e => "
"document.body.appendChild(e.adoptPredecessor());"));
FrameDeletedObserver observer(outer_frame_tree_node->current_frame_host());
ExecuteScriptAsync(main_frame,
"document.querySelector('portal').activate();");
observer.Wait();
}
class PortalOOPIFBrowserTest : public PortalBrowserTest {
protected:
PortalOOPIFBrowserTest() {}
......
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