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

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

Issue 1313223005: Fix RemoteToLocalSwapOnMainFrameInitializesCoreFrame to not crash on Android. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 3 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 | « no previous file | 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 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after
2299 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS caleFactor()); 2299 EXPECT_EQ(initialPageScaleFactor, webViewHelper.webViewImpl()->pageS caleFactor());
2300 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra me()->scrollOffset()); 2300 EXPECT_EQ(expectedScrollOffset, webViewHelper.webViewImpl()->mainFra me()->scrollOffset());
2301 } 2301 }
2302 } 2302 }
2303 }; 2303 };
2304 2304
2305 INSTANTIATE_TEST_CASE_P(All, WebFrameResizeTest, ::testing::Values( 2305 INSTANTIATE_TEST_CASE_P(All, WebFrameResizeTest, ::testing::Values(
2306 ParameterizedWebFrameTestConfig::Default, 2306 ParameterizedWebFrameTestConfig::Default,
2307 ParameterizedWebFrameTestConfig::RootLayerScrolls)); 2307 ParameterizedWebFrameTestConfig::RootLayerScrolls));
2308 2308
2309 // Fails on Android: https://crbug.com/528186
2310 #if OS(ANDROID)
2311 TEST_P(WebFrameResizeTest, DISABLED_ResizeYieldsCorrectScrollAndScaleForWidthEqu alsDeviceWidth)
2312 #else
2313 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice Width) 2309 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForWidthEqualsDevice Width)
2314 #endif
2315 { 2310 {
2316 // With width=device-width, pageScaleFactor is preserved across resizes as 2311 // With width=device-width, pageScaleFactor is preserved across resizes as
2317 // long as the content adjusts according to the device-width. 2312 // long as the content adjusts according to the device-width.
2318 const char* url = "resize_scroll_mobile.html"; 2313 const char* url = "resize_scroll_mobile.html";
2319 const float initialPageScaleFactor = 1; 2314 const float initialPageScaleFactor = 1;
2320 const WebSize scrollOffset(0, 50); 2315 const WebSize scrollOffset(0, 50);
2321 const WebSize viewportSize(120, 160); 2316 const WebSize viewportSize(120, 160);
2322 const bool shouldScaleRelativeToViewportWidth = true; 2317 const bool shouldScaleRelativeToViewportWidth = true;
2323 2318
2324 testResizeYieldsCorrectScrollAndScale( 2319 testResizeYieldsCorrectScrollAndScale(
2325 url, initialPageScaleFactor, scrollOffset, viewportSize, shouldScaleRela tiveToViewportWidth); 2320 url, initialPageScaleFactor, scrollOffset, viewportSize, shouldScaleRela tiveToViewportWidth);
2326 } 2321 }
2327 2322
2328 // Fails on Android: https://crbug.com/528186
2329 #if OS(ANDROID)
2330 TEST_P(WebFrameResizeTest, DISABLED_ResizeYieldsCorrectScrollAndScaleForMinimumS cale)
2331 #else
2332 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForMinimumScale) 2323 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForMinimumScale)
2333 #endif
2334 { 2324 {
2335 // This tests a scenario where minimum-scale is set to 1.0, but some element 2325 // This tests a scenario where minimum-scale is set to 1.0, but some element
2336 // on the page is slightly larger than the portrait width, so our "natural" 2326 // on the page is slightly larger than the portrait width, so our "natural"
2337 // minimum-scale would be lower. In that case, we should stick to 1.0 scale 2327 // minimum-scale would be lower. In that case, we should stick to 1.0 scale
2338 // on rotation and not do anything strange. 2328 // on rotation and not do anything strange.
2339 const char* url = "resize_scroll_minimum_scale.html"; 2329 const char* url = "resize_scroll_minimum_scale.html";
2340 const float initialPageScaleFactor = 1; 2330 const float initialPageScaleFactor = 1;
2341 const WebSize scrollOffset(0, 0); 2331 const WebSize scrollOffset(0, 0);
2342 const WebSize viewportSize(240, 320); 2332 const WebSize viewportSize(240, 320);
2343 const bool shouldScaleRelativeToViewportWidth = false; 2333 const bool shouldScaleRelativeToViewportWidth = false;
2344 2334
2345 testResizeYieldsCorrectScrollAndScale( 2335 testResizeYieldsCorrectScrollAndScale(
2346 url, initialPageScaleFactor, scrollOffset, viewportSize, shouldScaleRela tiveToViewportWidth); 2336 url, initialPageScaleFactor, scrollOffset, viewportSize, shouldScaleRela tiveToViewportWidth);
2347 } 2337 }
2348 2338
2349 // Fails on Android: https://crbug.com/528186
2350 #if OS(ANDROID)
2351 TEST_P(WebFrameResizeTest, DISABLED_ResizeYieldsCorrectScrollAndScaleForFixedWid th)
2352 #else
2353 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForFixedWidth) 2339 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForFixedWidth)
2354 #endif
2355 { 2340 {
2356 // With a fixed width, pageScaleFactor scales by the relative change in view port width. 2341 // With a fixed width, pageScaleFactor scales by the relative change in view port width.
2357 const char* url = "resize_scroll_fixed_width.html"; 2342 const char* url = "resize_scroll_fixed_width.html";
2358 const float initialPageScaleFactor = 2; 2343 const float initialPageScaleFactor = 2;
2359 const WebSize scrollOffset(0, 200); 2344 const WebSize scrollOffset(0, 200);
2360 const WebSize viewportSize(240, 320); 2345 const WebSize viewportSize(240, 320);
2361 const bool shouldScaleRelativeToViewportWidth = true; 2346 const bool shouldScaleRelativeToViewportWidth = true;
2362 2347
2363 testResizeYieldsCorrectScrollAndScale( 2348 testResizeYieldsCorrectScrollAndScale(
2364 url, initialPageScaleFactor, scrollOffset, viewportSize, shouldScaleRela tiveToViewportWidth); 2349 url, initialPageScaleFactor, scrollOffset, viewportSize, shouldScaleRela tiveToViewportWidth);
2365 } 2350 }
2366 2351
2367 // Fails on Android: https://crbug.com/528186
2368 #if OS(ANDROID)
2369 TEST_P(WebFrameResizeTest, DISABLED_ResizeYieldsCorrectScrollAndScaleForFixedLay out)
2370 #else
2371 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForFixedLayout) 2352 TEST_P(WebFrameResizeTest, ResizeYieldsCorrectScrollAndScaleForFixedLayout)
2372 #endif
2373 { 2353 {
2374 // With a fixed layout, pageScaleFactor scales by the relative change in vie wport width. 2354 // With a fixed layout, pageScaleFactor scales by the relative change in vie wport width.
2375 const char* url = "resize_scroll_fixed_layout.html"; 2355 const char* url = "resize_scroll_fixed_layout.html";
2376 const float initialPageScaleFactor = 2; 2356 const float initialPageScaleFactor = 2;
2377 const WebSize scrollOffset(200, 400); 2357 const WebSize scrollOffset(200, 400);
2378 const WebSize viewportSize(320, 240); 2358 const WebSize viewportSize(320, 240);
2379 const bool shouldScaleRelativeToViewportWidth = true; 2359 const bool shouldScaleRelativeToViewportWidth = true;
2380 2360
2381 testResizeYieldsCorrectScrollAndScale( 2361 testResizeYieldsCorrectScrollAndScale(
2382 url, initialPageScaleFactor, scrollOffset, viewportSize, shouldScaleRela tiveToViewportWidth); 2362 url, initialPageScaleFactor, scrollOffset, viewportSize, shouldScaleRela tiveToViewportWidth);
(...skipping 5426 matching lines...) Expand 10 before | Expand all | Expand 10 after
7809 } 7789 }
7810 7790
7811 FixedLayoutTestWebViewClient m_client; 7791 FixedLayoutTestWebViewClient m_client;
7812 FrameTestHelpers::WebViewHelper m_webViewHelper; 7792 FrameTestHelpers::WebViewHelper m_webViewHelper;
7813 }; 7793 };
7814 7794
7815 INSTANTIATE_TEST_CASE_P(All, ViewportOnResizeTest, ::testing::Values( 7795 INSTANTIATE_TEST_CASE_P(All, ViewportOnResizeTest, ::testing::Values(
7816 ParameterizedWebFrameTestConfig::Default, 7796 ParameterizedWebFrameTestConfig::Default,
7817 ParameterizedWebFrameTestConfig::RootLayerScrolls)); 7797 ParameterizedWebFrameTestConfig::RootLayerScrolls));
7818 7798
7819 // Fails on Android: https://crbug.com/528186
7820 #if OS(ANDROID)
7821 TEST_P(ViewportOnResizeTest, DISABLED_ViewportInvalidatedOnResizeWithEmulation)
7822 #else
7823 TEST_P(ViewportOnResizeTest, ViewportInvalidatedOnResizeWithEmulation) 7799 TEST_P(ViewportOnResizeTest, ViewportInvalidatedOnResizeWithEmulation)
7824 #endif
7825 { 7800 {
7826 WebDeviceEmulationParams params; 7801 WebDeviceEmulationParams params;
7827 params.screenPosition = WebDeviceEmulationParams::Mobile; 7802 params.screenPosition = WebDeviceEmulationParams::Mobile;
7828 m_webViewHelper.webView()->enableDeviceEmulation(params); 7803 m_webViewHelper.webView()->enableDeviceEmulation(params);
7829 7804
7830 testResize(WebSize(700, 500), "300x300"); 7805 testResize(WebSize(700, 500), "300x300");
7831 testResize(WebSize(710, 500), "400x300"); 7806 testResize(WebSize(710, 500), "400x300");
7832 testResize(WebSize(690, 500), "200x300"); 7807 testResize(WebSize(690, 500), "200x300");
7833 testResize(WebSize(700, 510), "300x400"); 7808 testResize(WebSize(700, 510), "300x400");
7834 testResize(WebSize(700, 490), "300x200"); 7809 testResize(WebSize(700, 490), "300x200");
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
7916 // Finally, make sure an embedder triggered load in the local frame swapped 7891 // Finally, make sure an embedder triggered load in the local frame swapped
7917 // back in works. 7892 // back in works.
7918 registerMockedHttpURLLoad("send_beacon.html"); 7893 registerMockedHttpURLLoad("send_beacon.html");
7919 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon() 7894 registerMockedHttpURLLoad("reload_post.html"); // url param to sendBeacon()
7920 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html"); 7895 FrameTestHelpers::loadFrame(localFrame, m_baseURL + "send_beacon.html");
7921 7896
7922 view->close(); 7897 view->close();
7923 } 7898 }
7924 7899
7925 // See https://crbug.com/525285. 7900 // See https://crbug.com/525285.
7926 // Fails on Android: https://crbug.com/528186
7927 #if OS(ANDROID)
7928 TEST_P(ParameterizedWebFrameTest, DISABLED_RemoteToLocalSwapOnMainFrameInitializ esCoreFrame)
7929 #else
7930 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me) 7901 TEST_P(ParameterizedWebFrameTest, RemoteToLocalSwapOnMainFrameInitializesCoreFra me)
7931 #endif
7932 { 7902 {
7933 FrameTestHelpers::TestWebViewClient viewClient; 7903 FrameTestHelpers::TestWebViewClient viewClient;
7934 FrameTestHelpers::TestWebRemoteFrameClient remoteClient; 7904 FrameTestHelpers::TestWebRemoteFrameClient remoteClient;
7935 WebView* view = WebView::create(&viewClient); 7905 WebView* view = WebView::create(&viewClient);
7936 view->setMainFrame(remoteClient.frame()); 7906 view->setMainFrame(remoteClient.frame());
7937 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame(); 7907 WebRemoteFrame* remoteRoot = view->mainFrame()->toWebRemoteFrame();
7938 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique()); 7908 remoteRoot->setReplicatedOrigin(SecurityOrigin::createUnique());
7939 7909
7940 FrameTestHelpers::TestWebFrameClient localFrameClient; 7910 FrameTestHelpers::TestWebFrameClient localFrameClient;
7941 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr); 7911 remoteRoot->createLocalChild(WebTreeScopeType::Document, "", WebSandboxFlags ::None, &localFrameClient, nullptr);
7942 7912
7943 // Do a remote-to-local swap of the top frame. 7913 // Do a remote-to-local swap of the top frame.
7944 FrameTestHelpers::TestWebFrameClient localClient; 7914 FrameTestHelpers::TestWebFrameClient localClient;
7945 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient); 7915 WebLocalFrame* localRoot = WebLocalFrame::create(WebTreeScopeType::Document, &localClient);
7946 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one); 7916 localRoot->initializeToReplaceRemoteFrame(remoteRoot, "", WebSandboxFlags::N one);
7947 remoteRoot->swap(localRoot); 7917 remoteRoot->swap(localRoot);
7948 7918
7949 // Load a page with a child frame in the new root to make sure this doesn't 7919 // Load a page with a child frame in the new root to make sure this doesn't
7950 // crash when the child frame invokes setCoreFrame. 7920 // crash when the child frame invokes setCoreFrame.
7951 FrameTestHelpers::loadFrame(localRoot, "data:text/html,<iframe></iframe>"); 7921 registerMockedHttpURLLoad("single_iframe.html");
7922 registerMockedHttpURLLoad("visible_iframe.html");
7923 FrameTestHelpers::loadFrame(localRoot, m_baseURL + "single_iframe.html");
7952 7924
7953 view->close(); 7925 view->close();
7954 } 7926 }
7955 7927
7956 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { 7928 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient {
7957 public: 7929 public:
7958 MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, c onst WebFloatPoint&, const WebFloatSize&)); 7930 MOCK_METHOD4(didOverscroll, void(const WebFloatSize&, const WebFloatSize&, c onst WebFloatPoint&, const WebFloatSize&));
7959 }; 7931 };
7960 7932
7961 class WebFrameOverscrollTest : public WebFrameTest { 7933 class WebFrameOverscrollTest : public WebFrameTest {
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
8230 8202
8231 TEST_F(WebFrameTest, MaxFramesDetach) 8203 TEST_F(WebFrameTest, MaxFramesDetach)
8232 { 8204 {
8233 registerMockedHttpURLLoad("max-frames-detach.html"); 8205 registerMockedHttpURLLoad("max-frames-detach.html");
8234 FrameTestHelpers::WebViewHelper webViewHelper; 8206 FrameTestHelpers::WebViewHelper webViewHelper;
8235 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true); 8207 WebViewImpl* webViewImpl = webViewHelper.initializeAndLoad(m_baseURL + "max- frames-detach.html", true);
8236 webViewImpl->mainFrameImpl()->collectGarbage(); 8208 webViewImpl->mainFrameImpl()->collectGarbage();
8237 } 8209 }
8238 8210
8239 } // namespace blink 8211 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698