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