Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(585)

Side by Side Diff: third_party/WebKit/Source/web/tests/WebFrameTest.cpp

Issue 2155393002: Fix ScopedPageLoadDeferrer to work with pages that have remote main frames. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a test Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/page/ScopedPageLoadDeferrer.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 #include "core/layout/HitTestResult.h" 66 #include "core/layout/HitTestResult.h"
67 #include "core/layout/LayoutFullScreen.h" 67 #include "core/layout/LayoutFullScreen.h"
68 #include "core/layout/api/LayoutViewItem.h" 68 #include "core/layout/api/LayoutViewItem.h"
69 #include "core/layout/compositing/PaintLayerCompositor.h" 69 #include "core/layout/compositing/PaintLayerCompositor.h"
70 #include "core/loader/DocumentLoader.h" 70 #include "core/loader/DocumentLoader.h"
71 #include "core/loader/DocumentThreadableLoader.h" 71 #include "core/loader/DocumentThreadableLoader.h"
72 #include "core/loader/DocumentThreadableLoaderClient.h" 72 #include "core/loader/DocumentThreadableLoaderClient.h"
73 #include "core/loader/FrameLoadRequest.h" 73 #include "core/loader/FrameLoadRequest.h"
74 #include "core/loader/ThreadableLoader.h" 74 #include "core/loader/ThreadableLoader.h"
75 #include "core/page/Page.h" 75 #include "core/page/Page.h"
76 #include "core/page/ScopedPageLoadDeferrer.h"
76 #include "core/paint/PaintLayer.h" 77 #include "core/paint/PaintLayer.h"
77 #include "core/testing/NullExecutionContext.h" 78 #include "core/testing/NullExecutionContext.h"
78 #include "modules/mediastream/MediaStream.h" 79 #include "modules/mediastream/MediaStream.h"
79 #include "modules/mediastream/MediaStreamRegistry.h" 80 #include "modules/mediastream/MediaStreamRegistry.h"
80 #include "platform/DragImage.h" 81 #include "platform/DragImage.h"
81 #include "platform/PlatformResourceLoader.h" 82 #include "platform/PlatformResourceLoader.h"
82 #include "platform/RuntimeEnabledFeatures.h" 83 #include "platform/RuntimeEnabledFeatures.h"
83 #include "platform/UserGestureIndicator.h" 84 #include "platform/UserGestureIndicator.h"
84 #include "platform/geometry/FloatRect.h" 85 #include "platform/geometry/FloatRect.h"
85 #include "platform/network/ResourceError.h" 86 #include "platform/network/ResourceError.h"
(...skipping 8060 matching lines...) Expand 10 before | Expand all | Expand 10 after
8146 8147
8147 // Load a page with a child frame in the new root to make sure this doesn't 8148 // Load a page with a child frame in the new root to make sure this doesn't
8148 // crash when the child frame invokes setCoreFrame. 8149 // crash when the child frame invokes setCoreFrame.
8149 registerMockedHttpURLLoad("single_iframe.html"); 8150 registerMockedHttpURLLoad("single_iframe.html");
8150 registerMockedHttpURLLoad("visible_iframe.html"); 8151 registerMockedHttpURLLoad("visible_iframe.html");
8151 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html"); 8152 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html");
8152 8153
8153 view->close(); 8154 view->close();
8154 } 8155 }
8155 8156
8157 // See https://crbug.com/628942.
8158 TEST_P(ParameterizedWebFrameTest, DeferredPageLoadWithRemoteMainFrame)
8159 {
8160 // Prepare a page with a remote main frame.
8161 FrameTestHelpers::TestWebViewClient viewClient;
8162 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
8163 WebView* view = WebView::create(&viewClient, WebPageVisibilityStateVisible);
8164 view->setMainFrame(remoteClient.frame());
8165 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
8166 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
8167
8168 // Check that ScopedPageLoadDeferrer properly triggers deferred loading for
8169 // the current Page.
8170 Page* page = remoteRoot->toImplBase()->frame()->page();
8171 EXPECT_FALSE(page->defersLoading());
8172 {
8173 ScopedPageLoadDeferrer deferrer;
8174 EXPECT_TRUE(page->defersLoading());
8175 }
8176 EXPECT_FALSE(page->defersLoading());
8177
8178 // Repeat this for a page with a local child frame, and ensure that the
8179 // child frame's loads are also deferred.
8180 WebLocalFrame* webLocalChild = FrameTestHelpers::createLocalChild(remoteRoot );
8181 registerMockedHttpURLLoad("foo.html");
8182 FrameTestHelpers::loadFrame(webLocalChild, m_baseURL + "foo.html");
8183 LocalFrame* localChild = toWebLocalFrameImpl(webLocalChild)->frame();
8184 EXPECT_FALSE(page->defersLoading());
8185 EXPECT_FALSE(localChild->document()->fetcher()->defersLoading());
8186 {
8187 ScopedPageLoadDeferrer deferrer;
8188 EXPECT_TRUE(page->defersLoading());
8189 EXPECT_TRUE(localChild->document()->fetcher()->defersLoading());
8190 }
8191 EXPECT_FALSE(remoteRoot->toImplBase()->frame()->page()->defersLoading());
dcheng 2016/07/20 02:08:57 Nit: page->defersLoading()?
alexmos 2016/07/20 16:08:32 Done.
8192 EXPECT_FALSE(localChild->document()->fetcher()->defersLoading());
8193
8194 view->close();
8195 }
8196
8156 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { 8197 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient {
8157 public: 8198 public:
8158 MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, c onst WebFloatPoint&, const WebFloatSize&)); 8199 MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, c onst WebFloatPoint&, const WebFloatSize&));
8159 }; 8200 };
8160 8201
8161 class WebFrameOverscrollTest : public WebFrameTest, public ::testing::WithParamI nterface<blink::WebGestureDevice> { 8202 class WebFrameOverscrollTest : public WebFrameTest, public ::testing::WithParamI nterface<blink::WebGestureDevice> {
8162 protected: 8203 protected:
8163 WebGestureEvent generateEvent(WebInputEvent::Type type, float deltaX = 0.0, float deltaY = 0.0) 8204 WebGestureEvent generateEvent(WebInputEvent::Type type, float deltaX = 0.0, float deltaY = 0.0)
8164 { 8205 {
8165 WebGestureEvent event; 8206 WebGestureEvent event;
(...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after
8810 request.setRequestorOrigin(WebSecurityOrigin::createUnique()); 8851 request.setRequestorOrigin(WebSecurityOrigin::createUnique());
8811 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request); 8852 helper.webViewImpl()->mainFrame()->toWebLocalFrame()->loadRequest(request);
8812 8853
8813 // Normally, the result of the JS url replaces the existing contents on the 8854 // Normally, the result of the JS url replaces the existing contents on the
8814 // Document. However, if the JS triggers a navigation, the contents should 8855 // Document. However, if the JS triggers a navigation, the contents should
8815 // not be replaced. 8856 // not be replaced.
8816 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum ent()->documentElement()->innerText()); 8857 EXPECT_EQ("", toLocalFrame(helper.webViewImpl()->page()->mainFrame())->docum ent()->documentElement()->innerText());
8817 } 8858 }
8818 8859
8819 } // namespace blink 8860 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/page/ScopedPageLoadDeferrer.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698