Commit e478b23e authored by David Bokan's avatar David Bokan Committed by Commit Bot

Prevent remote frame effective root scrollers

We don't support setting an OOPIF as the root scroller today so avoid
promoting it since some of the operations assume we're in a local frame.

Bug: 805427
Change-Id: I196e402e5e47ac86d364b705eab614758d0239b1
Reviewed-on: https://chromium-review.googlesource.com/895871
Commit-Queue: David Bokan <bokan@chromium.org>
Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534104}
parent 47e79040
......@@ -179,9 +179,20 @@ bool RootScrollerController::IsValidRootScroller(const Element& element) const {
!element.IsFrameOwnerElement())
return false;
if (element.IsFrameOwnerElement() &&
!ToHTMLFrameOwnerElement(&element)->OwnedEmbeddedContentView())
return false;
if (element.IsFrameOwnerElement()) {
const HTMLFrameOwnerElement* frame_owner =
ToHTMLFrameOwnerElement(&element);
if (!frame_owner)
return false;
if (!frame_owner->OwnedEmbeddedContentView())
return false;
// TODO(bokan): Make work with OOPIF. crbug.com/642378.
if (!frame_owner->OwnedEmbeddedContentView()->IsLocalFrameView())
return false;
}
if (!FillsViewport(element))
return false;
......
......@@ -762,12 +762,37 @@ TEST_P(RootScrollerTest, RemoteIFrame) {
MainWebFrame()->FirstChild()->Swap(FrameTestHelpers::CreateRemote());
// Set the root scroller in the local main frame to the iframe (which is
// remote).
// remote). Make sure we don't promote a remote frame to the root scroller.
{
Element* iframe = MainFrame()->GetDocument()->getElementById("iframe");
NonThrowableExceptionState non_throw;
MainFrame()->GetDocument()->setRootScroller(iframe, non_throw);
EXPECT_EQ(iframe, MainFrame()->GetDocument()->rootScroller());
EXPECT_EQ(MainFrame()->GetDocument(),
EffectiveRootScroller(MainFrame()->GetDocument()));
MainFrameView()->UpdateAllLifecyclePhases();
}
}
// Make sure that if an effective root scroller becomes a remote frame, it's
// demoted.
TEST_P(RootScrollerTest, IFrameSwapToRemote) {
Initialize("root-scroller-iframe.html");
Element* iframe = MainFrame()->GetDocument()->getElementById("iframe");
{
NonThrowableExceptionState non_throw;
MainFrame()->GetDocument()->setRootScroller(iframe, non_throw);
ASSERT_EQ(iframe, EffectiveRootScroller(MainFrame()->GetDocument()));
MainFrameView()->UpdateAllLifecyclePhases();
}
// Swap in a remote frame. Make sure we revert back to the document.
{
MainWebFrame()->FirstChild()->Swap(FrameTestHelpers::CreateRemote());
MainFrameView()->UpdateAllLifecyclePhases();
EXPECT_EQ(MainFrame()->GetDocument(),
EffectiveRootScroller(MainFrame()->GetDocument()));
}
}
......
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