OLD | NEW |
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 10047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10058 EXPECT_TRUE( | 10058 EXPECT_TRUE( |
10059 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); | 10059 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); |
10060 } | 10060 } |
10061 EXPECT_FALSE(page->Paused()); | 10061 EXPECT_FALSE(page->Paused()); |
10062 EXPECT_FALSE( | 10062 EXPECT_FALSE( |
10063 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); | 10063 local_child->GetDocument()->Fetcher()->Context().DefersLoading()); |
10064 } | 10064 } |
10065 | 10065 |
10066 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { | 10066 class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { |
10067 public: | 10067 public: |
10068 MOCK_METHOD4(DidOverscroll, | 10068 MOCK_METHOD5(DidOverscroll, |
10069 void(const WebFloatSize&, | 10069 void(const WebFloatSize&, |
10070 const WebFloatSize&, | 10070 const WebFloatSize&, |
10071 const WebFloatPoint&, | 10071 const WebFloatPoint&, |
10072 const WebFloatSize&)); | 10072 const WebFloatSize&, |
| 10073 const WebScrollBoundaryBehavior&)); |
10073 }; | 10074 }; |
10074 | 10075 |
10075 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam; | 10076 typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam; |
10076 class WebFrameOverscrollTest | 10077 class WebFrameOverscrollTest |
10077 : public WebFrameTest, | 10078 : public WebFrameTest, |
10078 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>, | 10079 public ::testing::WithParamInterface<WebFrameOverscrollTestParam>, |
10079 private ScopedRootLayerScrollingForTest { | 10080 private ScopedRootLayerScrollingForTest { |
10080 public: | 10081 public: |
10081 WebFrameOverscrollTest() | 10082 WebFrameOverscrollTest() |
10082 : ScopedRootLayerScrollingForTest(GetParam().first) {} | 10083 : ScopedRootLayerScrollingForTest(GetParam().first) {} |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10139 FrameTestHelpers::WebViewHelper web_view_helper; | 10140 FrameTestHelpers::WebViewHelper web_view_helper; |
10140 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", | 10141 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", |
10141 nullptr, &client, nullptr, | 10142 nullptr, &client, nullptr, |
10142 ConfigureAndroid); | 10143 ConfigureAndroid); |
10143 web_view_helper.Resize(WebSize(200, 200)); | 10144 web_view_helper.Resize(WebSize(200, 200)); |
10144 | 10145 |
10145 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple | 10146 // Calculation of accumulatedRootOverscroll and unusedDelta on multiple |
10146 // scrollUpdate. | 10147 // scrollUpdate. |
10147 ScrollBegin(&web_view_helper, -300, -316); | 10148 ScrollBegin(&web_view_helper, -300, -316); |
10148 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), | 10149 EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), |
10149 WebFloatPoint(100, 100), WebFloatSize())); | 10150 WebFloatPoint(100, 100), WebFloatSize(), |
| 10151 WebScrollBoundaryBehavior())); |
10150 ScrollUpdate(&web_view_helper, -308, -316); | 10152 ScrollUpdate(&web_view_helper, -308, -316); |
10151 Mock::VerifyAndClearExpectations(&client); | 10153 Mock::VerifyAndClearExpectations(&client); |
10152 | 10154 |
10153 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), | 10155 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), |
10154 WebFloatPoint(100, 100), WebFloatSize())); | 10156 WebFloatPoint(100, 100), WebFloatSize(), |
| 10157 WebScrollBoundaryBehavior())); |
10155 ScrollUpdate(&web_view_helper, 0, -13); | 10158 ScrollUpdate(&web_view_helper, 0, -13); |
10156 Mock::VerifyAndClearExpectations(&client); | 10159 Mock::VerifyAndClearExpectations(&client); |
10157 | 10160 |
10158 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42), | 10161 EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42), |
10159 WebFloatPoint(100, 100), WebFloatSize())); | 10162 WebFloatPoint(100, 100), WebFloatSize(), |
| 10163 WebScrollBoundaryBehavior())); |
10160 ScrollUpdate(&web_view_helper, -20, -13); | 10164 ScrollUpdate(&web_view_helper, -20, -13); |
10161 Mock::VerifyAndClearExpectations(&client); | 10165 Mock::VerifyAndClearExpectations(&client); |
10162 | 10166 |
10163 // Overscroll is not reported. | 10167 // Overscroll is not reported. |
10164 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10168 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10165 ScrollUpdate(&web_view_helper, 0, 1); | 10169 ScrollUpdate(&web_view_helper, 0, 1); |
10166 Mock::VerifyAndClearExpectations(&client); | 10170 Mock::VerifyAndClearExpectations(&client); |
10167 | 10171 |
10168 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10172 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10169 ScrollUpdate(&web_view_helper, 1, 0); | 10173 ScrollUpdate(&web_view_helper, 1, 0); |
10170 Mock::VerifyAndClearExpectations(&client); | 10174 Mock::VerifyAndClearExpectations(&client); |
10171 | 10175 |
10172 // Overscroll is reported. | 10176 // Overscroll is reported. |
10173 EXPECT_CALL(client, | 10177 EXPECT_CALL(client, |
10174 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701), | 10178 DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701), |
10175 WebFloatPoint(100, 100), WebFloatSize())); | 10179 WebFloatPoint(100, 100), WebFloatSize(), |
| 10180 WebScrollBoundaryBehavior())); |
10176 ScrollUpdate(&web_view_helper, 0, 1000); | 10181 ScrollUpdate(&web_view_helper, 0, 1000); |
10177 Mock::VerifyAndClearExpectations(&client); | 10182 Mock::VerifyAndClearExpectations(&client); |
10178 | 10183 |
10179 // Overscroll is not reported. | 10184 // Overscroll is not reported. |
10180 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10185 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10181 ScrollEnd(&web_view_helper); | 10186 ScrollEnd(&web_view_helper); |
10182 Mock::VerifyAndClearExpectations(&client); | 10187 Mock::VerifyAndClearExpectations(&client); |
10183 } | 10188 } |
10184 | 10189 |
10185 TEST_P(WebFrameOverscrollTest, | 10190 TEST_P(WebFrameOverscrollTest, |
10186 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { | 10191 AccumulatedOverscrollAndUnusedDeltaValuesOnDifferentAxesOverscroll) { |
10187 OverscrollWebViewClient client; | 10192 OverscrollWebViewClient client; |
10188 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); | 10193 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); |
10189 FrameTestHelpers::WebViewHelper web_view_helper; | 10194 FrameTestHelpers::WebViewHelper web_view_helper; |
10190 web_view_helper.InitializeAndLoad( | 10195 web_view_helper.InitializeAndLoad( |
10191 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, | 10196 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, |
10192 ConfigureAndroid); | 10197 ConfigureAndroid); |
10193 web_view_helper.Resize(WebSize(200, 200)); | 10198 web_view_helper.Resize(WebSize(200, 200)); |
10194 | 10199 |
10195 ScrollBegin(&web_view_helper, 0, -316); | 10200 ScrollBegin(&web_view_helper, 0, -316); |
10196 | 10201 |
10197 // Scroll the Div to the end. | 10202 // Scroll the Div to the end. |
10198 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10203 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10199 ScrollUpdate(&web_view_helper, 0, -316); | 10204 ScrollUpdate(&web_view_helper, 0, -316); |
10200 Mock::VerifyAndClearExpectations(&client); | 10205 Mock::VerifyAndClearExpectations(&client); |
10201 | 10206 |
10202 ScrollEnd(&web_view_helper); | 10207 ScrollEnd(&web_view_helper); |
10203 ScrollBegin(&web_view_helper, 0, -100); | 10208 ScrollBegin(&web_view_helper, 0, -100); |
10204 | 10209 |
10205 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. | 10210 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
10206 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), | 10211 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), |
10207 WebFloatPoint(100, 100), WebFloatSize())); | 10212 WebFloatPoint(100, 100), WebFloatSize(), |
| 10213 WebScrollBoundaryBehavior())); |
10208 ScrollUpdate(&web_view_helper, 0, -100); | 10214 ScrollUpdate(&web_view_helper, 0, -100); |
10209 ScrollUpdate(&web_view_helper, 0, -100); | 10215 ScrollUpdate(&web_view_helper, 0, -100); |
10210 Mock::VerifyAndClearExpectations(&client); | 10216 Mock::VerifyAndClearExpectations(&client); |
10211 | 10217 |
10212 // TODO(bokan): This has never worked but by the accident that this test was | 10218 // TODO(bokan): This has never worked but by the accident that this test was |
10213 // being run in a WebView without a size. This test should be fixed along with | 10219 // being run in a WebView without a size. This test should be fixed along with |
10214 // the bug, crbug.com/589320. | 10220 // the bug, crbug.com/589320. |
10215 // Page scrolls vertically, but over-scrolls horizontally. | 10221 // Page scrolls vertically, but over-scrolls horizontally. |
10216 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, | 10222 // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, |
10217 // 0), WebFloatPoint(100, 100), WebFloatSize())); | 10223 // 0), WebFloatPoint(100, 100), WebFloatSize(), WebScrollBoundaryBehavior())); |
10218 // ScrollUpdate(&webViewHelper, 100, 50); | 10224 // ScrollUpdate(&webViewHelper, 100, 50); |
10219 // Mock::VerifyAndClearExpectations(&client); | 10225 // Mock::VerifyAndClearExpectations(&client); |
10220 | 10226 |
10221 // Scrolling up, Overscroll is not reported. | 10227 // Scrolling up, Overscroll is not reported. |
10222 // EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); | 10228 // EXPECT_CALL(client, didOverscroll(_, _, _, _, _)).Times(0); |
10223 // ScrollUpdate(&webViewHelper, 0, -50); | 10229 // ScrollUpdate(&webViewHelper, 0, -50); |
10224 // Mock::VerifyAndClearExpectations(&client); | 10230 // Mock::VerifyAndClearExpectations(&client); |
10225 | 10231 |
10226 // Page scrolls horizontally, but over-scrolls vertically. | 10232 // Page scrolls horizontally, but over-scrolls vertically. |
10227 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, | 10233 // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, |
10228 // 100), WebFloatPoint(100, 100), WebFloatSize())); | 10234 // 100), WebFloatPoint(100, 100), WebFloatSize(), |
| 10235 // WebScrollBoundaryBehavior())); |
10229 // ScrollUpdate(&webViewHelper, -100, -100); | 10236 // ScrollUpdate(&webViewHelper, -100, -100); |
10230 // Mock::VerifyAndClearExpectations(&client); | 10237 // Mock::VerifyAndClearExpectations(&client); |
10231 } | 10238 } |
10232 | 10239 |
10233 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { | 10240 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { |
10234 OverscrollWebViewClient client; | 10241 OverscrollWebViewClient client; |
10235 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); | 10242 RegisterMockedHttpURLLoad("overscroll/div-overscroll.html"); |
10236 FrameTestHelpers::WebViewHelper web_view_helper; | 10243 FrameTestHelpers::WebViewHelper web_view_helper; |
10237 web_view_helper.InitializeAndLoad( | 10244 web_view_helper.InitializeAndLoad( |
10238 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, | 10245 base_url_ + "overscroll/div-overscroll.html", nullptr, &client, nullptr, |
10239 ConfigureAndroid); | 10246 ConfigureAndroid); |
10240 web_view_helper.Resize(WebSize(200, 200)); | 10247 web_view_helper.Resize(WebSize(200, 200)); |
10241 | 10248 |
10242 ScrollBegin(&web_view_helper, 0, -316); | 10249 ScrollBegin(&web_view_helper, 0, -316); |
10243 | 10250 |
10244 // Scroll the Div to the end. | 10251 // Scroll the Div to the end. |
10245 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10252 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10246 ScrollUpdate(&web_view_helper, 0, -316); | 10253 ScrollUpdate(&web_view_helper, 0, -316); |
10247 Mock::VerifyAndClearExpectations(&client); | 10254 Mock::VerifyAndClearExpectations(&client); |
10248 | 10255 |
10249 ScrollEnd(&web_view_helper); | 10256 ScrollEnd(&web_view_helper); |
10250 ScrollBegin(&web_view_helper, 0, -150); | 10257 ScrollBegin(&web_view_helper, 0, -150); |
10251 | 10258 |
10252 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. | 10259 // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
10253 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), | 10260 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
10254 WebFloatPoint(100, 100), WebFloatSize())); | 10261 WebFloatPoint(100, 100), WebFloatSize(), |
| 10262 WebScrollBoundaryBehavior())); |
10255 ScrollUpdate(&web_view_helper, 0, -150); | 10263 ScrollUpdate(&web_view_helper, 0, -150); |
10256 Mock::VerifyAndClearExpectations(&client); | 10264 Mock::VerifyAndClearExpectations(&client); |
10257 } | 10265 } |
10258 | 10266 |
10259 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { | 10267 TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { |
10260 OverscrollWebViewClient client; | 10268 OverscrollWebViewClient client; |
10261 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); | 10269 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); |
10262 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); | 10270 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); |
10263 FrameTestHelpers::WebViewHelper web_view_helper; | 10271 FrameTestHelpers::WebViewHelper web_view_helper; |
10264 web_view_helper.InitializeAndLoad( | 10272 web_view_helper.InitializeAndLoad( |
10265 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, | 10273 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, |
10266 nullptr, ConfigureAndroid); | 10274 nullptr, ConfigureAndroid); |
10267 web_view_helper.Resize(WebSize(200, 200)); | 10275 web_view_helper.Resize(WebSize(200, 200)); |
10268 | 10276 |
10269 ScrollBegin(&web_view_helper, 0, -320); | 10277 ScrollBegin(&web_view_helper, 0, -320); |
10270 // Scroll the IFrame to the end. | 10278 // Scroll the IFrame to the end. |
10271 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10279 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10272 | 10280 |
10273 // This scroll will fully scroll the iframe but will be consumed before being | 10281 // This scroll will fully scroll the iframe but will be consumed before being |
10274 // counted as overscroll. | 10282 // counted as overscroll. |
10275 ScrollUpdate(&web_view_helper, 0, -320); | 10283 ScrollUpdate(&web_view_helper, 0, -320); |
10276 | 10284 |
10277 // This scroll will again target the iframe but wont bubble further up. Make | 10285 // This scroll will again target the iframe but wont bubble further up. Make |
10278 // sure that the unused scroll isn't handled as overscroll. | 10286 // sure that the unused scroll isn't handled as overscroll. |
10279 ScrollUpdate(&web_view_helper, 0, -50); | 10287 ScrollUpdate(&web_view_helper, 0, -50); |
10280 Mock::VerifyAndClearExpectations(&client); | 10288 Mock::VerifyAndClearExpectations(&client); |
10281 | 10289 |
10282 ScrollEnd(&web_view_helper); | 10290 ScrollEnd(&web_view_helper); |
10283 ScrollBegin(&web_view_helper, 0, -150); | 10291 ScrollBegin(&web_view_helper, 0, -150); |
10284 | 10292 |
10285 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. | 10293 // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. |
10286 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), | 10294 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
10287 WebFloatPoint(100, 100), WebFloatSize())); | 10295 WebFloatPoint(100, 100), WebFloatSize(), |
| 10296 WebScrollBoundaryBehavior())); |
10288 ScrollUpdate(&web_view_helper, 0, -150); | 10297 ScrollUpdate(&web_view_helper, 0, -150); |
10289 Mock::VerifyAndClearExpectations(&client); | 10298 Mock::VerifyAndClearExpectations(&client); |
10290 | 10299 |
10291 ScrollEnd(&web_view_helper); | 10300 ScrollEnd(&web_view_helper); |
10292 } | 10301 } |
10293 | 10302 |
10294 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { | 10303 TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { |
10295 OverscrollWebViewClient client; | 10304 OverscrollWebViewClient client; |
10296 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 10305 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
10297 FrameTestHelpers::WebViewHelper web_view_helper; | 10306 FrameTestHelpers::WebViewHelper web_view_helper; |
10298 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( | 10307 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( |
10299 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, | 10308 base_url_ + "overscroll/overscroll.html", nullptr, &client, nullptr, |
10300 ConfigureAndroid); | 10309 ConfigureAndroid); |
10301 web_view_helper.Resize(WebSize(200, 200)); | 10310 web_view_helper.Resize(WebSize(200, 200)); |
10302 web_view_impl->SetPageScaleFactor(3.0); | 10311 web_view_impl->SetPageScaleFactor(3.0); |
10303 | 10312 |
10304 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. | 10313 // Calculation of accumulatedRootOverscroll and unusedDelta on scaled page. |
10305 // The point is (99, 99) because we clamp in the division by 3 to 33 so when | 10314 // The point is (99, 99) because we clamp in the division by 3 to 33 so when |
10306 // we go back to viewport coordinates it becomes (99, 99). | 10315 // we go back to viewport coordinates it becomes (99, 99). |
10307 ScrollBegin(&web_view_helper, 0, 30); | 10316 ScrollBegin(&web_view_helper, 0, 30); |
10308 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), | 10317 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), |
10309 WebFloatPoint(99, 99), WebFloatSize())); | 10318 WebFloatPoint(99, 99), WebFloatSize(), |
| 10319 WebScrollBoundaryBehavior())); |
10310 ScrollUpdate(&web_view_helper, 0, 30); | 10320 ScrollUpdate(&web_view_helper, 0, 30); |
10311 Mock::VerifyAndClearExpectations(&client); | 10321 Mock::VerifyAndClearExpectations(&client); |
10312 | 10322 |
10313 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), | 10323 EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), |
10314 WebFloatPoint(99, 99), WebFloatSize())); | 10324 WebFloatPoint(99, 99), WebFloatSize(), |
| 10325 WebScrollBoundaryBehavior())); |
10315 ScrollUpdate(&web_view_helper, 0, 30); | 10326 ScrollUpdate(&web_view_helper, 0, 30); |
10316 Mock::VerifyAndClearExpectations(&client); | 10327 Mock::VerifyAndClearExpectations(&client); |
10317 | 10328 |
10318 EXPECT_CALL(client, | 10329 EXPECT_CALL(client, |
10319 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90), | 10330 DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90), |
10320 WebFloatPoint(99, 99), WebFloatSize())); | 10331 WebFloatPoint(99, 99), WebFloatSize(), |
| 10332 WebScrollBoundaryBehavior())); |
10321 ScrollUpdate(&web_view_helper, 30, 30); | 10333 ScrollUpdate(&web_view_helper, 30, 30); |
10322 Mock::VerifyAndClearExpectations(&client); | 10334 Mock::VerifyAndClearExpectations(&client); |
10323 | 10335 |
10324 EXPECT_CALL(client, | 10336 EXPECT_CALL(client, |
10325 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90), | 10337 DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90), |
10326 WebFloatPoint(99, 99), WebFloatSize())); | 10338 WebFloatPoint(99, 99), WebFloatSize(), |
| 10339 WebScrollBoundaryBehavior())); |
10327 ScrollUpdate(&web_view_helper, 30, 0); | 10340 ScrollUpdate(&web_view_helper, 30, 0); |
10328 Mock::VerifyAndClearExpectations(&client); | 10341 Mock::VerifyAndClearExpectations(&client); |
10329 | 10342 |
10330 // Overscroll is not reported. | 10343 // Overscroll is not reported. |
10331 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10344 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10332 ScrollEnd(&web_view_helper); | 10345 ScrollEnd(&web_view_helper); |
10333 Mock::VerifyAndClearExpectations(&client); | 10346 Mock::VerifyAndClearExpectations(&client); |
10334 } | 10347 } |
10335 | 10348 |
10336 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { | 10349 TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { |
10337 OverscrollWebViewClient client; | 10350 OverscrollWebViewClient client; |
10338 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); | 10351 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
10339 FrameTestHelpers::WebViewHelper web_view_helper; | 10352 FrameTestHelpers::WebViewHelper web_view_helper; |
10340 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", | 10353 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", |
10341 nullptr, &client, nullptr, | 10354 nullptr, &client, nullptr, |
10342 ConfigureAndroid); | 10355 ConfigureAndroid); |
10343 web_view_helper.Resize(WebSize(200, 200)); | 10356 web_view_helper.Resize(WebSize(200, 200)); |
10344 | 10357 |
10345 ScrollBegin(&web_view_helper, 10, 10); | 10358 ScrollBegin(&web_view_helper, 10, 10); |
10346 EXPECT_CALL(client, | 10359 EXPECT_CALL(client, |
10347 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), | 10360 DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), |
10348 WebFloatPoint(100, 100), WebFloatSize())); | 10361 WebFloatPoint(100, 100), WebFloatSize(), |
| 10362 WebScrollBoundaryBehavior())); |
10349 ScrollUpdate(&web_view_helper, 10, 10); | 10363 ScrollUpdate(&web_view_helper, 10, 10); |
10350 Mock::VerifyAndClearExpectations(&client); | 10364 Mock::VerifyAndClearExpectations(&client); |
10351 | 10365 |
10352 EXPECT_CALL(client, | 10366 EXPECT_CALL(client, |
10353 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), | 10367 DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), |
10354 WebFloatPoint(100, 100), WebFloatSize())); | 10368 WebFloatPoint(100, 100), WebFloatSize(), |
| 10369 WebScrollBoundaryBehavior())); |
10355 ScrollUpdate(&web_view_helper, 0, 0.10); | 10370 ScrollUpdate(&web_view_helper, 0, 0.10); |
10356 Mock::VerifyAndClearExpectations(&client); | 10371 Mock::VerifyAndClearExpectations(&client); |
10357 | 10372 |
10358 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0), | 10373 EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0), |
10359 WebFloatSize(-10.10, -10.10), | 10374 WebFloatSize(-10.10, -10.10), |
10360 WebFloatPoint(100, 100), WebFloatSize())); | 10375 WebFloatPoint(100, 100), WebFloatSize(), |
| 10376 WebScrollBoundaryBehavior())); |
10361 ScrollUpdate(&web_view_helper, 0.10, 0); | 10377 ScrollUpdate(&web_view_helper, 0.10, 0); |
10362 Mock::VerifyAndClearExpectations(&client); | 10378 Mock::VerifyAndClearExpectations(&client); |
10363 | 10379 |
10364 // For residual values overscrollDelta should be reset and didOverscroll | 10380 // For residual values overscrollDelta should be reset and didOverscroll |
10365 // shouldn't be called. | 10381 // shouldn't be called. |
10366 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10382 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10367 ScrollUpdate(&web_view_helper, 0, 0.09); | 10383 ScrollUpdate(&web_view_helper, 0, 0.09); |
10368 Mock::VerifyAndClearExpectations(&client); | 10384 Mock::VerifyAndClearExpectations(&client); |
10369 | 10385 |
10370 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10386 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10371 ScrollUpdate(&web_view_helper, 0.09, 0.09); | 10387 ScrollUpdate(&web_view_helper, 0.09, 0.09); |
10372 Mock::VerifyAndClearExpectations(&client); | 10388 Mock::VerifyAndClearExpectations(&client); |
10373 | 10389 |
10374 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10390 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10375 ScrollUpdate(&web_view_helper, 0.09, 0); | 10391 ScrollUpdate(&web_view_helper, 0.09, 0); |
10376 Mock::VerifyAndClearExpectations(&client); | 10392 Mock::VerifyAndClearExpectations(&client); |
10377 | 10393 |
10378 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10394 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10379 ScrollUpdate(&web_view_helper, 0, -0.09); | 10395 ScrollUpdate(&web_view_helper, 0, -0.09); |
10380 Mock::VerifyAndClearExpectations(&client); | 10396 Mock::VerifyAndClearExpectations(&client); |
10381 | 10397 |
10382 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10398 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10383 ScrollUpdate(&web_view_helper, -0.09, -0.09); | 10399 ScrollUpdate(&web_view_helper, -0.09, -0.09); |
10384 Mock::VerifyAndClearExpectations(&client); | 10400 Mock::VerifyAndClearExpectations(&client); |
10385 | 10401 |
10386 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10402 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10387 ScrollUpdate(&web_view_helper, -0.09, 0); | 10403 ScrollUpdate(&web_view_helper, -0.09, 0); |
10388 Mock::VerifyAndClearExpectations(&client); | 10404 Mock::VerifyAndClearExpectations(&client); |
10389 | 10405 |
10390 EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); | 10406 EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
10391 ScrollEnd(&web_view_helper); | 10407 ScrollEnd(&web_view_helper); |
10392 Mock::VerifyAndClearExpectations(&client); | 10408 Mock::VerifyAndClearExpectations(&client); |
10393 } | 10409 } |
10394 | 10410 |
| 10411 TEST_P(WebFrameOverscrollTest, ScrollBoundaryBehaviorAffectsDidOverscroll) { |
| 10412 OverscrollWebViewClient client; |
| 10413 RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
| 10414 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10415 web_view_helper.InitializeAndLoad(base_url_ + "overscroll/overscroll.html", |
| 10416 nullptr, &client, nullptr, |
| 10417 ConfigureAndroid); |
| 10418 web_view_helper.Resize(WebSize(200, 200)); |
| 10419 |
| 10420 WebLocalFrame* mainFrame = |
| 10421 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame(); |
| 10422 mainFrame->ExecuteScript( |
| 10423 WebScriptSource(WebString("document.body.style=" |
| 10424 "'scroll-boundary-behavior: auto;'"))); |
| 10425 |
| 10426 ScrollBegin(&web_view_helper, 100, 116); |
| 10427 EXPECT_CALL( |
| 10428 client, |
| 10429 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100), |
| 10430 WebFloatPoint(100, 100), WebFloatSize(), |
| 10431 WebScrollBoundaryBehavior( |
| 10432 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
| 10433 kScrollBoundaryBehaviorTypeAuto))); |
| 10434 ScrollUpdate(&web_view_helper, 100, 100); |
| 10435 Mock::VerifyAndClearExpectations(&client); |
| 10436 |
| 10437 mainFrame->ExecuteScript( |
| 10438 WebScriptSource(WebString("document.body.style=" |
| 10439 "'scroll-boundary-behavior: contain;'"))); |
| 10440 |
| 10441 ScrollBegin(&web_view_helper, 100, 116); |
| 10442 EXPECT_CALL( |
| 10443 client, |
| 10444 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-200, -200), |
| 10445 WebFloatPoint(100, 100), WebFloatSize(), |
| 10446 WebScrollBoundaryBehavior( |
| 10447 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
| 10448 kScrollBoundaryBehaviorTypeContain))); |
| 10449 ScrollUpdate(&web_view_helper, 100, 100); |
| 10450 Mock::VerifyAndClearExpectations(&client); |
| 10451 |
| 10452 mainFrame->ExecuteScript( |
| 10453 WebScriptSource(WebString("document.body.style=" |
| 10454 "'scroll-boundary-behavior: none;'"))); |
| 10455 |
| 10456 ScrollBegin(&web_view_helper, 100, 116); |
| 10457 EXPECT_CALL( |
| 10458 client, |
| 10459 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-300, -300), |
| 10460 WebFloatPoint(100, 100), WebFloatSize(), |
| 10461 WebScrollBoundaryBehavior( |
| 10462 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
| 10463 kScrollBoundaryBehaviorTypeNone))); |
| 10464 ScrollUpdate(&web_view_helper, 100, 100); |
| 10465 Mock::VerifyAndClearExpectations(&client); |
| 10466 } |
| 10467 |
| 10468 TEST_P(WebFrameOverscrollTest, OnlyMainFrameScrollBoundaryBehaviorHasEffect) { |
| 10469 OverscrollWebViewClient client; |
| 10470 RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); |
| 10471 RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); |
| 10472 FrameTestHelpers::WebViewHelper web_view_helper; |
| 10473 web_view_helper.InitializeAndLoad( |
| 10474 base_url_ + "overscroll/iframe-overscroll.html", nullptr, &client, |
| 10475 nullptr, ConfigureAndroid); |
| 10476 web_view_helper.Resize(WebSize(200, 200)); |
| 10477 |
| 10478 WebLocalFrame* mainFrame = |
| 10479 web_view_helper.WebView()->MainFrame()->ToWebLocalFrame(); |
| 10480 mainFrame->ExecuteScript( |
| 10481 WebScriptSource(WebString("document.body.style=" |
| 10482 "'scroll-boundary-behavior: auto;'"))); |
| 10483 WebLocalFrame* subframe = |
| 10484 web_view_helper.WebView()->MainFrame()->FirstChild()->ToWebLocalFrame(); |
| 10485 subframe->ExecuteScript( |
| 10486 WebScriptSource(WebString("document.body.style=" |
| 10487 "'scroll-boundary-behavior: none;'"))); |
| 10488 |
| 10489 ScrollBegin(&web_view_helper, 100, 116); |
| 10490 EXPECT_CALL( |
| 10491 client, |
| 10492 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100), |
| 10493 WebFloatPoint(100, 100), WebFloatSize(), |
| 10494 WebScrollBoundaryBehavior( |
| 10495 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
| 10496 kScrollBoundaryBehaviorTypeAuto))); |
| 10497 ScrollUpdate(&web_view_helper, 100, 100); |
| 10498 Mock::VerifyAndClearExpectations(&client); |
| 10499 |
| 10500 mainFrame->ExecuteScript( |
| 10501 WebScriptSource(WebString("document.body.style=" |
| 10502 "'scroll-boundary-behavior: contain;'"))); |
| 10503 |
| 10504 EXPECT_CALL( |
| 10505 client, |
| 10506 DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-200, -200), |
| 10507 WebFloatPoint(100, 100), WebFloatSize(), |
| 10508 WebScrollBoundaryBehavior( |
| 10509 WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
| 10510 kScrollBoundaryBehaviorTypeContain))); |
| 10511 ScrollUpdate(&web_view_helper, 100, 100); |
| 10512 Mock::VerifyAndClearExpectations(&client); |
| 10513 } |
| 10514 |
10395 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) { | 10515 TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) { |
10396 RuntimeEnabledFeatures::SetOrientationEventEnabled(true); | 10516 RuntimeEnabledFeatures::SetOrientationEventEnabled(true); |
10397 RegisterMockedHttpURLLoad("orientation-frame-detach.html"); | 10517 RegisterMockedHttpURLLoad("orientation-frame-detach.html"); |
10398 FrameTestHelpers::WebViewHelper web_view_helper; | 10518 FrameTestHelpers::WebViewHelper web_view_helper; |
10399 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( | 10519 WebViewImpl* web_view_impl = web_view_helper.InitializeAndLoad( |
10400 base_url_ + "orientation-frame-detach.html"); | 10520 base_url_ + "orientation-frame-detach.html"); |
10401 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent(); | 10521 web_view_impl->MainFrameImpl()->SendOrientationChangeEvent(); |
10402 } | 10522 } |
10403 | 10523 |
10404 TEST_P(ParameterizedWebFrameTest, DISABLE_ON_TSAN(MaxFramesDetach)) { | 10524 TEST_P(ParameterizedWebFrameTest, DISABLE_ON_TSAN(MaxFramesDetach)) { |
(...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12598 tester.ExpectBucketCount(histogramName, kSPANavTypeOtherFragmentNavigation, | 12718 tester.ExpectBucketCount(histogramName, kSPANavTypeOtherFragmentNavigation, |
12599 1); | 12719 1); |
12600 // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an | 12720 // kSameDocumentNavigationHistoryApi and kFrameLoadTypeBackForward is an |
12601 // illegal combination, which has been caught by DCHECK in | 12721 // illegal combination, which has been caught by DCHECK in |
12602 // UpdateForSameDocumentNavigation(). | 12722 // UpdateForSameDocumentNavigation(). |
12603 | 12723 |
12604 tester.ExpectTotalCount(histogramName, 3); | 12724 tester.ExpectTotalCount(histogramName, 3); |
12605 } | 12725 } |
12606 | 12726 |
12607 } // namespace blink | 12727 } // namespace blink |
OLD | NEW |