Index: third_party/WebKit/Source/core/exported/WebFrameTest.cpp |
diff --git a/third_party/WebKit/Source/core/exported/WebFrameTest.cpp b/third_party/WebKit/Source/core/exported/WebFrameTest.cpp |
index 8686685bfc12c7476c11aa3b11378ea2158aa2ac..2ff225fdcd072b483ebf20ec05d391992d1bd00d 100644 |
--- a/third_party/WebKit/Source/core/exported/WebFrameTest.cpp |
+++ b/third_party/WebKit/Source/core/exported/WebFrameTest.cpp |
@@ -10021,11 +10021,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; |
@@ -10102,38 +10103,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); |
} |
@@ -10151,7 +10156,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); |
@@ -10160,7 +10165,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); |
@@ -10170,18 +10176,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); |
} |
@@ -10198,7 +10205,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); |
@@ -10207,7 +10214,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); |
} |
@@ -10224,7 +10232,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. |
@@ -10240,7 +10248,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); |
@@ -10262,29 +10271,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); |
} |
@@ -10301,55 +10314,57 @@ 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, |
- ScrollBoundaryBehaviorOnBodyDoesNotPreventOverscroll) { |
+TEST_P(WebFrameOverscrollTest, ScrollBoundaryBehaviorAffectsDidOverscroll) { |
OverscrollWebViewClient client; |
RegisterMockedHttpURLLoad("overscroll/overscroll.html"); |
FrameTestHelpers::WebViewHelper web_view_helper; |
@@ -10360,14 +10375,95 @@ TEST_P(WebFrameOverscrollTest, |
WebLocalFrame* mainFrame = |
web_view_helper.WebView()->MainFrame()->ToWebLocalFrame(); |
+ mainFrame->ExecuteScript( |
+ WebScriptSource(WebString("document.body.style=" |
+ "'scroll-boundary-behavior: auto;'"))); |
+ |
+ 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); |
+ |
mainFrame->ExecuteScript( |
WebScriptSource(WebString("document.body.style=" |
"'scroll-boundary-behavior: contain;'"))); |
- ScrollBegin(&web_view_helper, 100, 100); |
- EXPECT_CALL(client, |
- DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-100, -100), |
- WebFloatPoint(100, 100), WebFloatSize())); |
+ ScrollBegin(&web_view_helper, 100, 116); |
+ EXPECT_CALL( |
+ client, |
+ DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-200, -200), |
+ WebFloatPoint(100, 100), WebFloatSize(), |
+ WebScrollBoundaryBehavior( |
+ WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
+ kScrollBoundaryBehaviorTypeContain))); |
+ ScrollUpdate(&web_view_helper, 100, 100); |
+ Mock::VerifyAndClearExpectations(&client); |
+ |
+ mainFrame->ExecuteScript( |
+ WebScriptSource(WebString("document.body.style=" |
+ "'scroll-boundary-behavior: none;'"))); |
+ |
+ ScrollBegin(&web_view_helper, 100, 116); |
+ EXPECT_CALL( |
+ client, |
+ DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-300, -300), |
+ WebFloatPoint(100, 100), WebFloatSize(), |
+ WebScrollBoundaryBehavior( |
+ WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
+ kScrollBoundaryBehaviorTypeNone))); |
+ ScrollUpdate(&web_view_helper, 100, 100); |
+ Mock::VerifyAndClearExpectations(&client); |
+} |
+ |
+TEST_P(WebFrameOverscrollTest, OnlyMainFrameScrollBoundaryBehaviorHasEffect) { |
+ OverscrollWebViewClient client; |
+ RegisterMockedHttpURLLoad("overscroll/iframe-overscroll.html"); |
+ RegisterMockedHttpURLLoad("overscroll/scrollable-iframe.html"); |
+ FrameTestHelpers::WebViewHelper web_view_helper; |
+ web_view_helper.InitializeAndLoad( |
+ base_url_ + "overscroll/iframe-overscroll.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=" |
+ "'scroll-boundary-behavior: auto;'"))); |
+ WebLocalFrame* subframe = |
+ web_view_helper.WebView()->MainFrame()->FirstChild()->ToWebLocalFrame(); |
+ subframe->ExecuteScript( |
+ WebScriptSource(WebString("document.body.style=" |
+ "'scroll-boundary-behavior: none;'"))); |
+ |
+ 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); |
+ |
+ mainFrame->ExecuteScript( |
+ WebScriptSource(WebString("document.body.style=" |
+ "'scroll-boundary-behavior: contain;'"))); |
+ |
+ EXPECT_CALL( |
+ client, |
+ DidOverscroll(WebFloatSize(-100, -100), WebFloatSize(-200, -200), |
+ WebFloatPoint(100, 100), WebFloatSize(), |
+ WebScrollBoundaryBehavior( |
+ WebScrollBoundaryBehavior::ScrollBoundaryBehaviorType:: |
+ kScrollBoundaryBehaviorTypeContain))); |
ScrollUpdate(&web_view_helper, 100, 100); |
Mock::VerifyAndClearExpectations(&client); |
} |