Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
index 6cf1755d31342f65ff5cc46c1e0e0c02a3bbca4f..f47e9da5109a80879b9c417e8eb9730fb02dc41f 100644 |
--- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
+++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
@@ -73,6 +73,7 @@ |
#include "core/loader/FrameLoadRequest.h" |
#include "core/loader/ThreadableLoader.h" |
#include "core/page/Page.h" |
+#include "core/page/ScopedPageLoadDeferrer.h" |
#include "core/paint/PaintLayer.h" |
#include "core/testing/NullExecutionContext.h" |
#include "modules/mediastream/MediaStream.h" |
@@ -8153,6 +8154,46 @@ TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra |
view->close(); |
} |
+// See https://crbug.com/628942. |
+TEST_P(ParameterizedWebFrameTest, DeferredPageLoadWithRemoteMainFrame) |
+{ |
+ // Prepare a page with a remote main frame. |
+ FrameTestHelpers::TestWebViewClient viewClient; |
+ FrameTestHelpers::TestWebRemoteFrameClient remoteClient; |
+ WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible); |
+ view->setMainFrame(remoteClient.frame()); |
+ WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); |
+ remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); |
+ |
+ // Check that ScopedPageLoadDeferrer properly triggers deferred loading for |
+ // the current Page. |
+ Page* page = remoteRoot->toImplBase()->frame()->page(); |
+ EXPECT_FALSE(page->defersLoading()); |
+ { |
+ ScopedPageLoadDeferrer deferrer; |
+ EXPECT_TRUE(page->defersLoading()); |
+ } |
+ EXPECT_FALSE(page->defersLoading()); |
+ |
+ // Repeat this for a page with a local child frame, and ensure that the |
+ // child frame's loads are also deferred. |
+ WebLocalFrame* webLocalChild = FrameTestHelpers::createLocalChild(remoteRoot); |
+ registerMockedHttpURLLoad("foo.html"); |
+ FrameTestHelpers::loadFrame(webLocalChild, m_baseURL + "foo.html"); |
+ LocalFrame* localChild = toWebLocalFrameImpl(webLocalChild)->frame(); |
+ EXPECT_FALSE(page->defersLoading()); |
+ EXPECT_FALSE(localChild->document()->fetcher()->defersLoading()); |
+ { |
+ ScopedPageLoadDeferrer deferrer; |
+ EXPECT_TRUE(page->defersLoading()); |
+ EXPECT_TRUE(localChild->document()->fetcher()->defersLoading()); |
+ } |
+ EXPECT_FALSE(page->defersLoading()); |
+ EXPECT_FALSE(localChild->document()->fetcher()->defersLoading()); |
+ |
+ view->close(); |
+} |
+ |
class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { |
public: |
MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, const WebFloatPoint&, const WebFloatSize&)); |