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

Side by Side Diff: third_party/WebKit/Source/core/exported/WebFrameTest.cpp

Issue 2884423003: Use scroll-boundary-behavior to control overscroll-refresh/glow on android. (Closed)
Patch Set: Update input_messages with the order in the enum. Created 3 years, 4 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
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 9958 matching lines...) Expand 10 before | Expand all | Expand 10 after
9969 EXPECT_TRUE( 9969 EXPECT_TRUE(
9970 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); 9970 local_child->GetDocument()->Fetcher()->Context().DefersLoading());
9971 } 9971 }
9972 EXPECT_FALSE(page->Paused()); 9972 EXPECT_FALSE(page->Paused());
9973 EXPECT_FALSE( 9973 EXPECT_FALSE(
9974 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); 9974 local_child->GetDocument()->Fetcher()->Context().DefersLoading());
9975 } 9975 }
9976 9976
9977 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { 9977 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient {
9978 public: 9978 public:
9979 MOCK_METHOD4(DidOverscroll, 9979 MOCK_METHOD5(DidOverscroll,
9980 void(const WebFloatSize&, 9980 void(const WebFloatSize&,
9981 const WebFloatSize&, 9981 const WebFloatSize&,
9982 const WebFloatPoint&, 9982 const WebFloatPoint&,
9983 const WebFloatSize&)); 9983 const WebFloatSize&,
9984 const WebScrollBoundaryBehavior&));
9984 }; 9985 };
9985 9986
9986 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam; 9987 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam;
9987 class WebFrameOverscrollTest 9988 class WebFrameOverscrollTest
9988 : public WebFrameTest, 9989 : public WebFrameTest,
9989 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>, 9990 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>,
9990 private ScopedRootLayerScrollingForTest { 9991 private ScopedRootLayerScrollingForTest {
9991 public: 9992 public:
9992 WebFrameOverscrollTest() 9993 WebFrameOverscrollTest()
9993 : ScopedRootLayerScrollingForTest(GetParam().first) {} 9994 : ScopedRootLayerScrollingForTest(GetParam().first) {}
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
10050 FrameTestHelpers::WebViewHelper web_view_helper; 10051 FrameTestHelpers::WebViewHelper web_view_helper;
10051 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10052 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10052 nullptr, &client, nullptr, 10053 nullptr, &client, nullptr,
10053 ConfigureAndroid); 10054 ConfigureAndroid);
10054 web_view_helper.Resize(WebSize(200, 200)); 10055 web_view_helper.Resize(WebSize(200, 200));
10055 10056
10056 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple 10057 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple
10057 // scrollUpdate. 10058 // scrollUpdate.
10058 ScrollBegin(&web_view_helper, -300, -316); 10059 ScrollBegin(&web_view_helper, -300, -316);
10059 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), 10060 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16),
10060 WebFloatPoint(100, 100), WebFloatSize())); 10061 WebFloatPoint(100, 100), WebFloatSize(),
10062 WebScrollBoundaryBehavior()));
10061 ScrollUpdate(&web_view_helper, -308, -316); 10063 ScrollUpdate(&web_view_helper, -308, -316);
10062 Mock::VerifyAndClearExpectations(&client); 10064 Mock::VerifyAndClearExpectations(&client);
10063 10065
10064 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), 10066 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29),
10065 WebFloatPoint(100, 100), WebFloatSize())); 10067 WebFloatPoint(100, 100), WebFloatSize(),
10068 WebScrollBoundaryBehavior()));
10066 ScrollUpdate(&web_view_helper, 0, -13); 10069 ScrollUpdate(&web_view_helper, 0, -13);
10067 Mock::VerifyAndClearExpectations(&client); 10070 Mock::VerifyAndClearExpectations(&client);
10068 10071
10069 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42), 10072 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42),
10070 WebFloatPoint(100, 100), WebFloatSize())); 10073 WebFloatPoint(100, 100), WebFloatSize(),
10074 WebScrollBoundaryBehavior()));
10071 ScrollUpdate(&web_view_helper, -20, -13); 10075 ScrollUpdate(&web_view_helper, -20, -13);
10072 Mock::VerifyAndClearExpectations(&client); 10076 Mock::VerifyAndClearExpectations(&client);
10073 10077
10074 // Overscroll is not reported. 10078 // Overscroll is not reported.
10075 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10079 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10076 ScrollUpdate(&web_view_helper, 0, 1); 10080 ScrollUpdate(&web_view_helper, 0, 1);
10077 Mock::VerifyAndClearExpectations(&client); 10081 Mock::VerifyAndClearExpectations(&client);
10078 10082
10079 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10083 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10080 ScrollUpdate(&web_view_helper, 1, 0); 10084 ScrollUpdate(&web_view_helper, 1, 0);
10081 Mock::VerifyAndClearExpectations(&client); 10085 Mock::VerifyAndClearExpectations(&client);
10082 10086
10083 // Overscroll is reported. 10087 // Overscroll is reported.
10084 EXPECT_CALL(client, 10088 EXPECT_CALL(client,
10085 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701), 10089 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701),
10086 WebFloatPoint(100, 100), WebFloatSize())); 10090 WebFloatPoint(100, 100), WebFloatSize(),
10091 WebScrollBoundaryBehavior()));
10087 ScrollUpdate(&web_view_helper, 0, 1000); 10092 ScrollUpdate(&web_view_helper, 0, 1000);
10088 Mock::VerifyAndClearExpectations(&client); 10093 Mock::VerifyAndClearExpectations(&client);
10089 10094
10090 // Overscroll is not reported. 10095 // Overscroll is not reported.
10091 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10096 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10092 ScrollEnd(&web_view_helper); 10097 ScrollEnd(&web_view_helper);
10093 Mock::VerifyAndClearExpectations(&client); 10098 Mock::VerifyAndClearExpectations(&client);
10094 } 10099 }
10095 10100
10096 TEST_P(WebFrameOverscrollTest, 10101 TEST_P(WebFrameOverscrollTest,
10097 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { 10102 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) {
10098 OverscrollWebViewClient client; 10103 OverscrollWebViewClient client;
10099 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 10104 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
10100 FrameTestHelpers::WebViewHelper web_view_helper; 10105 FrameTestHelpers::WebViewHelper web_view_helper;
10101 web_view_helper.InitializeAndLoad( 10106 web_view_helper.InitializeAndLoad(
10102 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, 10107 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr,
10103 ConfigureAndroid); 10108 ConfigureAndroid);
10104 web_view_helper.Resize(WebSize(200, 200)); 10109 web_view_helper.Resize(WebSize(200, 200));
10105 10110
10106 ScrollBegin(&web_view_helper, 0, -316); 10111 ScrollBegin(&web_view_helper, 0, -316);
10107 10112
10108 // Scroll the Div to the end. 10113 // Scroll the Div to the end.
10109 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10114 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10110 ScrollUpdate(&web_view_helper, 0, -316); 10115 ScrollUpdate(&web_view_helper, 0, -316);
10111 Mock::VerifyAndClearExpectations(&client); 10116 Mock::VerifyAndClearExpectations(&client);
10112 10117
10113 ScrollEnd(&web_view_helper); 10118 ScrollEnd(&web_view_helper);
10114 ScrollBegin(&web_view_helper, 0, -100); 10119 ScrollBegin(&web_view_helper, 0, -100);
10115 10120
10116 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 10121 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
10117 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), 10122 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100),
10118 WebFloatPoint(100, 100), WebFloatSize())); 10123 WebFloatPoint(100, 100), WebFloatSize(),
10124 WebScrollBoundaryBehavior()));
10119 ScrollUpdate(&web_view_helper, 0, -100); 10125 ScrollUpdate(&web_view_helper, 0, -100);
10120 ScrollUpdate(&web_view_helper, 0, -100); 10126 ScrollUpdate(&web_view_helper, 0, -100);
10121 Mock::VerifyAndClearExpectations(&client); 10127 Mock::VerifyAndClearExpectations(&client);
10122 10128
10123 // TODO(bokan): This has never worked but by the accident that this test was 10129 // TODO(bokan): This has never worked but by the accident that this test was
10124 // being run in a WebView without a size. This test should be fixed along with 10130 // being run in a WebView without a size. This test should be fixed along with
10125 // the bug, crbug.com/589320. 10131 // the bug, crbug.com/589320.
10126 // Page scrolls vertically, but over-scrolls horizontally. 10132 // Page scrolls vertically, but over-scrolls horizontally.
10127 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, 10133 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100,
10128 // 0), WebFloatPoint(100, 100), WebFloatSize())); 10134 // 0), WebFloatPoint(100, 100), WebFloatSize(), WebScrollBoundaryBehavior()));
10129 // ScrollUpdate(&webViewHelper, 100, 50); 10135 // ScrollUpdate(&webViewHelper, 100, 50);
10130 // Mock::VerifyAndClearExpectations(&client); 10136 // Mock::VerifyAndClearExpectations(&client);
10131 10137
10132 // Scrolling up, Overscroll is not reported. 10138 // Scrolling up, Overscroll is not reported.
10133 // EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); 10139 // EXPECT_CALL(client, didOverscroll(_, _, _, _, _)).Times(0);
10134 // ScrollUpdate(&webViewHelper, 0, -50); 10140 // ScrollUpdate(&webViewHelper, 0, -50);
10135 // Mock::VerifyAndClearExpectations(&client); 10141 // Mock::VerifyAndClearExpectations(&client);
10136 10142
10137 // Page scrolls horizontally, but over-scrolls vertically. 10143 // Page scrolls horizontally, but over-scrolls vertically.
10138 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 10144 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0,
10139 // 100), WebFloatPoint(100, 100), WebFloatSize())); 10145 // 100), WebFloatPoint(100, 100), WebFloatSize(),
10146 // WebScrollBoundaryBehavior()));
10140 // ScrollUpdate(&webViewHelper, -100, -100); 10147 // ScrollUpdate(&webViewHelper, -100, -100);
10141 // Mock::VerifyAndClearExpectations(&client); 10148 // Mock::VerifyAndClearExpectations(&client);
10142 } 10149 }
10143 10150
10144 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { 10151 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) {
10145 OverscrollWebViewClient client; 10152 OverscrollWebViewClient client;
10146 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); 10153 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html");
10147 FrameTestHelpers::WebViewHelper web_view_helper; 10154 FrameTestHelpers::WebViewHelper web_view_helper;
10148 web_view_helper.InitializeAndLoad( 10155 web_view_helper.InitializeAndLoad(
10149 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, 10156 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr,
10150 ConfigureAndroid); 10157 ConfigureAndroid);
10151 web_view_helper.Resize(WebSize(200, 200)); 10158 web_view_helper.Resize(WebSize(200, 200));
10152 10159
10153 ScrollBegin(&web_view_helper, 0, -316); 10160 ScrollBegin(&web_view_helper, 0, -316);
10154 10161
10155 // Scroll the Div to the end. 10162 // Scroll the Div to the end.
10156 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10163 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10157 ScrollUpdate(&web_view_helper, 0, -316); 10164 ScrollUpdate(&web_view_helper, 0, -316);
10158 Mock::VerifyAndClearExpectations(&client); 10165 Mock::VerifyAndClearExpectations(&client);
10159 10166
10160 ScrollEnd(&web_view_helper); 10167 ScrollEnd(&web_view_helper);
10161 ScrollBegin(&web_view_helper, 0, -150); 10168 ScrollBegin(&web_view_helper, 0, -150);
10162 10169
10163 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. 10170 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled.
10164 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10171 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10165 WebFloatPoint(100, 100), WebFloatSize())); 10172 WebFloatPoint(100, 100), WebFloatSize(),
10173 WebScrollBoundaryBehavior()));
10166 ScrollUpdate(&web_view_helper, 0, -150); 10174 ScrollUpdate(&web_view_helper, 0, -150);
10167 Mock::VerifyAndClearExpectations(&client); 10175 Mock::VerifyAndClearExpectations(&client);
10168 } 10176 }
10169 10177
10170 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { 10178 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) {
10171 OverscrollWebViewClient client; 10179 OverscrollWebViewClient client;
10172 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); 10180 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html");
10173 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); 10181 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html");
10174 FrameTestHelpers::WebViewHelper web_view_helper; 10182 FrameTestHelpers::WebViewHelper web_view_helper;
10175 web_view_helper.InitializeAndLoad( 10183 web_view_helper.InitializeAndLoad(
10176 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, 10184 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client,
10177 nullptr, ConfigureAndroid); 10185 nullptr, ConfigureAndroid);
10178 web_view_helper.Resize(WebSize(200, 200)); 10186 web_view_helper.Resize(WebSize(200, 200));
10179 10187
10180 ScrollBegin(&web_view_helper, 0, -320); 10188 ScrollBegin(&web_view_helper, 0, -320);
10181 // Scroll the IFrame to the end. 10189 // Scroll the IFrame to the end.
10182 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10190 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10183 10191
10184 // This scroll will fully scroll the iframe but will be consumed before being 10192 // This scroll will fully scroll the iframe but will be consumed before being
10185 // counted as overscroll. 10193 // counted as overscroll.
10186 ScrollUpdate(&web_view_helper, 0, -320); 10194 ScrollUpdate(&web_view_helper, 0, -320);
10187 10195
10188 // This scroll will again target the iframe but wont bubble further up. Make 10196 // This scroll will again target the iframe but wont bubble further up. Make
10189 // sure that the unused scroll isn't handled as overscroll. 10197 // sure that the unused scroll isn't handled as overscroll.
10190 ScrollUpdate(&web_view_helper, 0, -50); 10198 ScrollUpdate(&web_view_helper, 0, -50);
10191 Mock::VerifyAndClearExpectations(&client); 10199 Mock::VerifyAndClearExpectations(&client);
10192 10200
10193 ScrollEnd(&web_view_helper); 10201 ScrollEnd(&web_view_helper);
10194 ScrollBegin(&web_view_helper, 0, -150); 10202 ScrollBegin(&web_view_helper, 0, -150);
10195 10203
10196 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. 10204 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled.
10197 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), 10205 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50),
10198 WebFloatPoint(100, 100), WebFloatSize())); 10206 WebFloatPoint(100, 100), WebFloatSize(),
10207 WebScrollBoundaryBehavior()));
10199 ScrollUpdate(&web_view_helper, 0, -150); 10208 ScrollUpdate(&web_view_helper, 0, -150);
10200 Mock::VerifyAndClearExpectations(&client); 10209 Mock::VerifyAndClearExpectations(&client);
10201 10210
10202 ScrollEnd(&web_view_helper); 10211 ScrollEnd(&web_view_helper);
10203 } 10212 }
10204 10213
10205 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { 10214 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) {
10206 OverscrollWebViewClient client; 10215 OverscrollWebViewClient client;
10207 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10216 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10208 FrameTestHelpers::WebViewHelper web_view_helper; 10217 FrameTestHelpers::WebViewHelper web_view_helper;
10209 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( 10218 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad(
10210 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, 10219 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr,
10211 ConfigureAndroid); 10220 ConfigureAndroid);
10212 web_view_helper.Resize(WebSize(200, 200)); 10221 web_view_helper.Resize(WebSize(200, 200));
10213 web_view_impl->SetPageScaleFactor(3.0); 10222 web_view_impl->SetPageScaleFactor(3.0);
10214 10223
10215 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. 10224 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page.
10216 // The point is (99, 99) because we clamp in the division by 3 to 33 so when 10225 // The point is (99, 99) because we clamp in the division by 3 to 33 so when
10217 // we go back to viewport coordinates it becomes (99, 99). 10226 // we go back to viewport coordinates it becomes (99, 99).
10218 ScrollBegin(&web_view_helper, 0, 30); 10227 ScrollBegin(&web_view_helper, 0, 30);
10219 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), 10228 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30),
10220 WebFloatPoint(99, 99), WebFloatSize())); 10229 WebFloatPoint(99, 99), WebFloatSize(),
10230 WebScrollBoundaryBehavior()));
10221 ScrollUpdate(&web_view_helper, 0, 30); 10231 ScrollUpdate(&web_view_helper, 0, 30);
10222 Mock::VerifyAndClearExpectations(&client); 10232 Mock::VerifyAndClearExpectations(&client);
10223 10233
10224 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), 10234 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60),
10225 WebFloatPoint(99, 99), WebFloatSize())); 10235 WebFloatPoint(99, 99), WebFloatSize(),
10236 WebScrollBoundaryBehavior()));
10226 ScrollUpdate(&web_view_helper, 0, 30); 10237 ScrollUpdate(&web_view_helper, 0, 30);
10227 Mock::VerifyAndClearExpectations(&client); 10238 Mock::VerifyAndClearExpectations(&client);
10228 10239
10229 EXPECT_CALL(client, 10240 EXPECT_CALL(client,
10230 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90), 10241 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90),
10231 WebFloatPoint(99, 99), WebFloatSize())); 10242 WebFloatPoint(99, 99), WebFloatSize(),
10243 WebScrollBoundaryBehavior()));
10232 ScrollUpdate(&web_view_helper, 30, 30); 10244 ScrollUpdate(&web_view_helper, 30, 30);
10233 Mock::VerifyAndClearExpectations(&client); 10245 Mock::VerifyAndClearExpectations(&client);
10234 10246
10235 EXPECT_CALL(client, 10247 EXPECT_CALL(client,
10236 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90), 10248 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90),
10237 WebFloatPoint(99, 99), WebFloatSize())); 10249 WebFloatPoint(99, 99), WebFloatSize(),
10250 WebScrollBoundaryBehavior()));
10238 ScrollUpdate(&web_view_helper, 30, 0); 10251 ScrollUpdate(&web_view_helper, 30, 0);
10239 Mock::VerifyAndClearExpectations(&client); 10252 Mock::VerifyAndClearExpectations(&client);
10240 10253
10241 // Overscroll is not reported. 10254 // Overscroll is not reported.
10242 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10255 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10243 ScrollEnd(&web_view_helper); 10256 ScrollEnd(&web_view_helper);
10244 Mock::VerifyAndClearExpectations(&client); 10257 Mock::VerifyAndClearExpectations(&client);
10245 } 10258 }
10246 10259
10247 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { 10260 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) {
10248 OverscrollWebViewClient client; 10261 OverscrollWebViewClient client;
10249 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); 10262 RegisterMockedHttpURLLoad("overscroll/overscroll.html");
10250 FrameTestHelpers::WebViewHelper web_view_helper; 10263 FrameTestHelpers::WebViewHelper web_view_helper;
10251 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", 10264 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html",
10252 nullptr, &client, nullptr, 10265 nullptr, &client, nullptr,
10253 ConfigureAndroid); 10266 ConfigureAndroid);
10254 web_view_helper.Resize(WebSize(200, 200)); 10267 web_view_helper.Resize(WebSize(200, 200));
10255 10268
10256 ScrollBegin(&web_view_helper, 10, 10); 10269 ScrollBegin(&web_view_helper, 10, 10);
10257 EXPECT_CALL(client, 10270 EXPECT_CALL(client,
10258 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), 10271 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10),
10259 WebFloatPoint(100, 100), WebFloatSize())); 10272 WebFloatPoint(100, 100), WebFloatSize(),
10273 WebScrollBoundaryBehavior()));
10260 ScrollUpdate(&web_view_helper, 10, 10); 10274 ScrollUpdate(&web_view_helper, 10, 10);
10261 Mock::VerifyAndClearExpectations(&client); 10275 Mock::VerifyAndClearExpectations(&client);
10262 10276
10263 EXPECT_CALL(client, 10277 EXPECT_CALL(client,
10264 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), 10278 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10),
10265 WebFloatPoint(100, 100), WebFloatSize())); 10279 WebFloatPoint(100, 100), WebFloatSize(),
10280 WebScrollBoundaryBehavior()));
10266 ScrollUpdate(&web_view_helper, 0, 0.10); 10281 ScrollUpdate(&web_view_helper, 0, 0.10);
10267 Mock::VerifyAndClearExpectations(&client); 10282 Mock::VerifyAndClearExpectations(&client);
10268 10283
10269 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0), 10284 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0),
10270 WebFloatSize(-10.10, -10.10), 10285 WebFloatSize(-10.10, -10.10),
10271 WebFloatPoint(100, 100), WebFloatSize())); 10286 WebFloatPoint(100, 100), WebFloatSize(),
10287 WebScrollBoundaryBehavior()));
10272 ScrollUpdate(&web_view_helper, 0.10, 0); 10288 ScrollUpdate(&web_view_helper, 0.10, 0);
10273 Mock::VerifyAndClearExpectations(&client); 10289 Mock::VerifyAndClearExpectations(&client);
10274 10290
10275 // For residual values overscrollDelta should be reset and didOverscroll 10291 // For residual values overscrollDelta should be reset and didOverscroll
10276 // shouldn't be called. 10292 // shouldn't be called.
10277 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10293 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10278 ScrollUpdate(&web_view_helper, 0, 0.09); 10294 ScrollUpdate(&web_view_helper, 0, 0.09);
10279 Mock::VerifyAndClearExpectations(&client); 10295 Mock::VerifyAndClearExpectations(&client);
10280 10296
10281 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10297 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10282 ScrollUpdate(&web_view_helper, 0.09, 0.09); 10298 ScrollUpdate(&web_view_helper, 0.09, 0.09);
10283 Mock::VerifyAndClearExpectations(&client); 10299 Mock::VerifyAndClearExpectations(&client);
10284 10300
10285 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10301 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10286 ScrollUpdate(&web_view_helper, 0.09, 0); 10302 ScrollUpdate(&web_view_helper, 0.09, 0);
10287 Mock::VerifyAndClearExpectations(&client); 10303 Mock::VerifyAndClearExpectations(&client);
10288 10304
10289 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10305 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10290 ScrollUpdate(&web_view_helper, 0, -0.09); 10306 ScrollUpdate(&web_view_helper, 0, -0.09);
10291 Mock::VerifyAndClearExpectations(&client); 10307 Mock::VerifyAndClearExpectations(&client);
10292 10308
10293 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10309 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10294 ScrollUpdate(&web_view_helper, -0.09, -0.09); 10310 ScrollUpdate(&web_view_helper, -0.09, -0.09);
10295 Mock::VerifyAndClearExpectations(&client); 10311 Mock::VerifyAndClearExpectations(&client);
10296 10312
10297 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10313 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10298 ScrollUpdate(&web_view_helper, -0.09, 0); 10314 ScrollUpdate(&web_view_helper, -0.09, 0);
10299 Mock::VerifyAndClearExpectations(&client); 10315 Mock::VerifyAndClearExpectations(&client);
10300 10316
10301 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); 10317 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0);
10302 ScrollEnd(&web_view_helper); 10318 ScrollEnd(&web_view_helper);
10303 Mock::VerifyAndClearExpectations(&client); 10319 Mock::VerifyAndClearExpectations(&client);
10304 } 10320 }
10305 10321
10322 TEST_P(WebFrameOverscrollTest, OnlyMainFrameScrollBoundaryBehaviorHasEffect) {
10323 OverscrollWebViewClient client;
10324 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html");
10325 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html");
10326 FrameTestHelpers::WebViewHelper web_view_helper;
10327 web_view_helper.InitializeAndLoad(
10328 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client,
10329 nullptr, ConfigureAndroid);
10330 web_view_helper.Resize(WebSize(200, 200));
10331
10332 WebLocalFrame* mainFrame =
10333 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame();
10334 mainFrame->ExecuteScript(
10335 WebScriptSource(WebString("document.body.style="
10336 "'scroll-boundary-behavior: auto;'")));
10337 WebLocalFrame* subframe =
10338 web_view_helper.WebView()->MainFrame()->FirstChild()->ToWebLocalFrame();
10339 subframe->ExecuteScript(
10340 WebScriptSource(WebString("document.body.style="
10341 "'scroll-boundary-behavior: none;'")));
10342
10343 ScrollBegin(&web_view_helper, 100, 116);
10344 EXPECT_CALL(
10345 client,
10346 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100),
10347 WebFloatPoint(100, 100), WebFloatSize(),
10348 WebScrollBoundaryBehavior(
10349 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10350 kScrollBoundaryBehaviorTypeAuto)));
10351 ScrollUpdate(&web_view_helper, 100, 100);
10352 Mock::VerifyAndClearExpectations(&client);
10353
10354 mainFrame->ExecuteScript(
10355 WebScriptSource(WebString("document.body.style="
10356 "'scroll-boundary-behavior: contain;'")));
10357
10358 EXPECT_CALL(
10359 client,
10360 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-200, -200),
10361 WebFloatPoint(100, 100), WebFloatSize(),
10362 WebScrollBoundaryBehavior(
10363 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType::
10364 kScrollBoundaryBehaviorTypeContain)));
10365 ScrollUpdate(&web_view_helper, 100, 100);
10366 Mock::VerifyAndClearExpectations(&client);
10367 }
10368
10306 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) { 10369 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) {
10307 RuntimeEnabledFeatures::SetOrientationEventEnabled(true); 10370 RuntimeEnabledFeatures::SetOrientationEventEnabled(true);
10308 RegisterMockedHttpURLLoad("orientation-frame-detach.html"); 10371 RegisterMockedHttpURLLoad("orientation-frame-detach.html");
10309 FrameTestHelpers::WebViewHelper web_view_helper; 10372 FrameTestHelpers::WebViewHelper web_view_helper;
10310 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad( 10373 WebViewBase* web_view_impl = web_view_helper.InitializeAndLoad(
10311 base_url_ + "orientation-frame-detach.html"); 10374 base_url_ + "orientation-frame-detach.html");
10312 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent(); 10375 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent();
10313 } 10376 }
10314 10377
10315 TEST_P(ParameterizedWebFrameTest, DISABLE_ON_TSAN(MaxFramesDetach)) { 10378 TEST_P(ParameterizedWebFrameTest, DISABLE_ON_TSAN(MaxFramesDetach)) {
(...skipping 1908 matching lines...) Expand 10 before | Expand all | Expand 10 after
12224 tester.ExpectBucketCount(histogramName, kSPANavTypeOtherFragmentNavigation, 12287 tester.ExpectBucketCount(histogramName, kSPANavTypeOtherFragmentNavigation,
12225 1); 12288 1);
12226 // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an 12289 // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an
12227 // illegal combination, which has been caught by DCHECK in 12290 // illegal combination, which has been caught by DCHECK in
12228 // UpdateForSameDocumentNavigation(). 12291 // UpdateForSameDocumentNavigation().
12229 12292
12230 tester.ExpectTotalCount(histogramName, 3); 12293 tester.ExpectTotalCount(histogramName, 3);
12231 } 12294 }
12232 12295
12233 } // namespace blink 12296 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698