Chromium Code Reviews| Index: third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| diff --git a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| index 33f12ab739c68ff8b51f8b67849f1e33d269e02f..31c20290b1f7b496a68b27556f14c629d939f925 100644 |
| --- a/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| +++ b/third_party/WebKit/Source/web/tests/WebFrameTest.cpp |
| @@ -9876,11 +9876,12 @@ TEST_P(ParameterizedWebFrameTest, SuspendedPageLoadWithRemoteMainFrame) { |
| class OverscrollWebViewClient : public FrameTestHelpers::TestWebViewClient { |
| public: |
| - MOCK_METHOD4(DidOverscroll, |
| + MOCK_METHOD5(DidOverscroll, |
| void(const WebFloatSize&, |
| const WebFloatSize&, |
| const WebFloatPoint&, |
| - const WebFloatSize&)); |
| + const WebFloatSize&, |
| + const WebScrollBoundaryBehavior&)); |
| }; |
| typedef std::pair<bool, blink::WebGestureDevice> WebFrameOverscrollTestParam; |
| @@ -9957,38 +9958,42 @@ TEST_P(WebFrameOverscrollTest, |
| // scrollUpdate. |
| ScrollBegin(&web_view_helper, -300, -316); |
| EXPECT_CALL(client, DidOverscroll(WebFloatSize(8, 16), WebFloatSize(8, 16), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, -308, -316); |
| Mock::VerifyAndClearExpectations(&client); |
| EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 13), WebFloatSize(8, 29), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 0, -13); |
| Mock::VerifyAndClearExpectations(&client); |
| EXPECT_CALL(client, DidOverscroll(WebFloatSize(20, 13), WebFloatSize(28, 42), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, -20, -13); |
| Mock::VerifyAndClearExpectations(&client); |
| // Overscroll is not reported. |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, 0, 1); |
| Mock::VerifyAndClearExpectations(&client); |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, 1, 0); |
| Mock::VerifyAndClearExpectations(&client); |
| // Overscroll is reported. |
| EXPECT_CALL(client, |
| DidOverscroll(WebFloatSize(0, -701), WebFloatSize(0, -701), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 0, 1000); |
| Mock::VerifyAndClearExpectations(&client); |
| // Overscroll is not reported. |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollEnd(&web_view_helper); |
| Mock::VerifyAndClearExpectations(&client); |
| } |
| @@ -10006,7 +10011,7 @@ TEST_P(WebFrameOverscrollTest, |
| ScrollBegin(&web_view_helper, 0, -316); |
| // Scroll the Div to the end. |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, 0, -316); |
| Mock::VerifyAndClearExpectations(&client); |
| @@ -10015,7 +10020,8 @@ TEST_P(WebFrameOverscrollTest, |
| // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
| EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 100), WebFloatSize(0, 100), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 0, -100); |
| ScrollUpdate(&web_view_helper, 0, -100); |
| Mock::VerifyAndClearExpectations(&client); |
| @@ -10025,18 +10031,19 @@ TEST_P(WebFrameOverscrollTest, |
| // the bug, crbug.com/589320. |
| // Page scrolls vertically, but over-scrolls horizontally. |
| // EXPECT_CALL(client, didOverscroll(WebFloatSize(-100, 0), WebFloatSize(-100, |
| - // 0), WebFloatPoint(100, 100), WebFloatSize())); |
| + // 0), WebFloatPoint(100, 100), WebFloatSize(), WebScrollBoundaryBehavior())); |
| // ScrollUpdate(&webViewHelper, 100, 50); |
| // Mock::VerifyAndClearExpectations(&client); |
| // Scrolling up, Overscroll is not reported. |
| - // EXPECT_CALL(client, didOverscroll(_, _, _, _)).Times(0); |
| + // EXPECT_CALL(client, didOverscroll(_, _, _, _, _)).Times(0); |
| // ScrollUpdate(&webViewHelper, 0, -50); |
| // Mock::VerifyAndClearExpectations(&client); |
| // Page scrolls horizontally, but over-scrolls vertically. |
| // EXPECT_CALL(client, didOverscroll(WebFloatSize(0, 100), WebFloatSize(0, |
| - // 100), WebFloatPoint(100, 100), WebFloatSize())); |
| + // 100), WebFloatPoint(100, 100), WebFloatSize(), |
| + // WebScrollBoundaryBehavior())); |
| // ScrollUpdate(&webViewHelper, -100, -100); |
| // Mock::VerifyAndClearExpectations(&client); |
| } |
| @@ -10053,7 +10060,7 @@ TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { |
| ScrollBegin(&web_view_helper, 0, -316); |
| // Scroll the Div to the end. |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, 0, -316); |
| Mock::VerifyAndClearExpectations(&client); |
| @@ -10062,7 +10069,8 @@ TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerDivOverScroll) { |
| // Now On Scrolling DIV, scroll is bubbled and root layer is over-scrolled. |
| EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 0, -150); |
| Mock::VerifyAndClearExpectations(&client); |
| } |
| @@ -10079,7 +10087,7 @@ TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { |
| ScrollBegin(&web_view_helper, 0, -320); |
| // Scroll the IFrame to the end. |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| // This scroll will fully scroll the iframe but will be consumed before being |
| // counted as overscroll. |
| @@ -10095,7 +10103,8 @@ TEST_P(WebFrameOverscrollTest, RootLayerOverscrolledOnInnerIFrameOverScroll) { |
| // Now On Scrolling IFrame, scroll is bubbled and root layer is over-scrolled. |
| EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, 50), WebFloatSize(0, 50), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 0, -150); |
| Mock::VerifyAndClearExpectations(&client); |
| @@ -10117,29 +10126,33 @@ TEST_P(WebFrameOverscrollTest, ScaledPageRootLayerOverscrolled) { |
| // we go back to viewport coordinates it becomes (99, 99). |
| ScrollBegin(&web_view_helper, 0, 30); |
| EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -30), |
| - WebFloatPoint(99, 99), WebFloatSize())); |
| + WebFloatPoint(99, 99), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 0, 30); |
| Mock::VerifyAndClearExpectations(&client); |
| EXPECT_CALL(client, DidOverscroll(WebFloatSize(0, -30), WebFloatSize(0, -60), |
| - WebFloatPoint(99, 99), WebFloatSize())); |
| + WebFloatPoint(99, 99), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 0, 30); |
| Mock::VerifyAndClearExpectations(&client); |
| EXPECT_CALL(client, |
| DidOverscroll(WebFloatSize(-30, -30), WebFloatSize(-30, -90), |
| - WebFloatPoint(99, 99), WebFloatSize())); |
| + WebFloatPoint(99, 99), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 30, 30); |
| Mock::VerifyAndClearExpectations(&client); |
| EXPECT_CALL(client, |
| DidOverscroll(WebFloatSize(-30, 0), WebFloatSize(-60, -90), |
| - WebFloatPoint(99, 99), WebFloatSize())); |
| + WebFloatPoint(99, 99), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 30, 0); |
| Mock::VerifyAndClearExpectations(&client); |
| // Overscroll is not reported. |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollEnd(&web_view_helper); |
| Mock::VerifyAndClearExpectations(&client); |
| } |
| @@ -10156,53 +10169,92 @@ TEST_P(WebFrameOverscrollTest, NoOverscrollForSmallvalues) { |
| ScrollBegin(&web_view_helper, 10, 10); |
| EXPECT_CALL(client, |
| DidOverscroll(WebFloatSize(-10, -10), WebFloatSize(-10, -10), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 10, 10); |
| Mock::VerifyAndClearExpectations(&client); |
| EXPECT_CALL(client, |
| DidOverscroll(WebFloatSize(0, -0.10), WebFloatSize(-10, -10.10), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 0, 0.10); |
| Mock::VerifyAndClearExpectations(&client); |
| EXPECT_CALL(client, DidOverscroll(WebFloatSize(-0.10, 0), |
| WebFloatSize(-10.10, -10.10), |
| - WebFloatPoint(100, 100), WebFloatSize())); |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior())); |
| ScrollUpdate(&web_view_helper, 0.10, 0); |
| Mock::VerifyAndClearExpectations(&client); |
| // For residual values overscrollDelta should be reset and didOverscroll |
| // shouldn't be called. |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, 0, 0.09); |
| Mock::VerifyAndClearExpectations(&client); |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, 0.09, 0.09); |
| Mock::VerifyAndClearExpectations(&client); |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, 0.09, 0); |
| Mock::VerifyAndClearExpectations(&client); |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, 0, -0.09); |
| Mock::VerifyAndClearExpectations(&client); |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, -0.09, -0.09); |
| Mock::VerifyAndClearExpectations(&client); |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollUpdate(&web_view_helper, -0.09, 0); |
| Mock::VerifyAndClearExpectations(&client); |
| - EXPECT_CALL(client, DidOverscroll(_, _, _, _)).Times(0); |
| + EXPECT_CALL(client, DidOverscroll(_, _, _, _, _)).Times(0); |
| ScrollEnd(&web_view_helper); |
| Mock::VerifyAndClearExpectations(&client); |
| } |
| +TEST_P(WebFrameOverscrollTest, OnlyMainFrameScrollBoundaryBehaviorHasEffect) { |
|
majidvp
2017/07/25 20:38:29
Please also add a test to ensure that updating mai
sunyunjia
2017/08/03 14:54:34
Done.
|
| + OverscrollWebViewClient client; |
| + RegisterMockedHttpURLLoad("single_iframe.html"); |
| + RegisterMockedHttpURLLoad("visible_iframe.html"); |
| + FrameTestHelpers::WebViewHelper web_view_helper; |
| + web_view_helper.InitializeAndLoad(base_url_ + "single_iframe.html", nullptr, |
| + &client, nullptr, ConfigureAndroid); |
| + web_view_helper.Resize(WebSize(200, 200)); |
| + |
| + WebLocalFrame* mainFrame = |
| + web_view_helper.WebView()->MainFrame()->ToWebLocalFrame(); |
| + mainFrame->ExecuteScript( |
| + WebScriptSource(WebString("document.body.style=" |
| + "'height: 400px;" |
| + "width: 400px;" |
| + "scroll-boundary-behavior: auto;'"))); |
|
majidvp
2017/07/25 20:38:29
If I understand it correctly, the height and width
sunyunjia
2017/08/03 14:54:34
Done.
|
| + WebLocalFrame* subframe = |
| + web_view_helper.WebView()->MainFrame()->FirstChild()->ToWebLocalFrame(); |
| + subframe->ExecuteScript( |
| + WebScriptSource(WebString("document.body.style=" |
| + "'scroll-boundary-behavior: none;" |
| + "height: 50px;" |
| + "width: 50px'"))); |
| + |
| + ScrollBegin(&web_view_helper, 100, 116); |
| + EXPECT_CALL( |
| + client, |
| + DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100), |
| + WebFloatPoint(100, 100), WebFloatSize(), |
| + WebScrollBoundaryBehavior( |
| + WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
| + kScrollBoundaryBehaviorTypeAuto))); |
| + ScrollUpdate(&web_view_helper, 100, 100); |
| + Mock::VerifyAndClearExpectations(&client); |
| +} |
| + |
| TEST_P(ParameterizedWebFrameTest, OrientationFrameDetach) { |
| RuntimeEnabledFeatures::SetOrientationEventEnabled(true); |
| RegisterMockedHttpURLLoad("orientation-frame-detach.html"); |