diff --git a/gfx/layers/apz/src/APZCTreeManager.cpp b/gfx/layers/apz/src/APZCTreeManager.cpp index da77c86120d4..5741b5384d0b 100644 --- a/gfx/layers/apz/src/APZCTreeManager.cpp +++ b/gfx/layers/apz/src/APZCTreeManager.cpp @@ -1642,6 +1642,9 @@ APZEventResult APZCTreeManager::ReceiveInputEvent( return state.Finish(*this, std::move(aCallback)); } + panInput.mOverscrollBehaviorAllowsSwipe = + state.mHit.mTargetApzc->OverscrollBehaviorAllowsSwipe(); + state.mResult = mInputQueue->ReceiveInputEvent( state.mHit.mTargetApzc, TargetConfirmationFlags{state.mHit.mHitResult}, panInput); @@ -1649,9 +1652,6 @@ APZEventResult APZCTreeManager::ReceiveInputEvent( // Update the out-parameters so they are what the caller expects. panInput.mPanStartPoint = *untransformedStartPoint; panInput.mPanDisplacement = *untransformedDisplacement; - - panInput.mOverscrollBehaviorAllowsSwipe = - state.mHit.mTargetApzc->OverscrollBehaviorAllowsSwipe(); } break; } diff --git a/gfx/layers/apz/src/InputQueue.cpp b/gfx/layers/apz/src/InputQueue.cpp index 5df511d2f66b..697c5a6c0a5b 100644 --- a/gfx/layers/apz/src/InputQueue.cpp +++ b/gfx/layers/apz/src/InputQueue.cpp @@ -453,7 +453,7 @@ APZEventResult InputQueue::ReceivePanGestureInput( CancelAnimationsForNewBlock(block); MaybeRequestContentResponse(aTarget, block); - if (aFlags.mTargetConfirmed && + if (aFlags.mTargetConfirmed && event.mOverscrollBehaviorAllowsSwipe && event .mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection && !CanScrollTargetHorizontally(event, block)) { diff --git a/widget/tests/browser/browser.ini b/widget/tests/browser/browser.ini index c9251a33a429..837b41feef90 100644 --- a/widget/tests/browser/browser.ini +++ b/widget/tests/browser/browser.ini @@ -12,5 +12,6 @@ skip-if = os == "win" && bits == 32 && !debug # Bug 1759422 verify # Bug 1800022 support-files = + helper_swipe_gesture.html !/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js !/gfx/layers/apz/test/mochitest/apz_test_utils.js diff --git a/widget/tests/browser/browser_test_swipe_gesture.js b/widget/tests/browser/browser_test_swipe_gesture.js index 0f501c62d7a6..b189fae23d24 100644 --- a/widget/tests/browser/browser_test_swipe_gesture.js +++ b/widget/tests/browser/browser_test_swipe_gesture.js @@ -805,6 +805,90 @@ add_task(async () => { await SpecialPowers.popPrefEnv(); }); +add_task(async () => { + await SpecialPowers.pushPrefEnv({ + set: [ + ["browser.gesture.swipe.left", "Browser:BackOrBackDuplicate"], + ["browser.gesture.swipe.right", "Browser:ForwardOrForwardDuplicate"], + ["widget.disable-swipe-tracker", false], + ["widget.swipe.velocity-twitch-tolerance", 0.0000001], + ["widget.swipe.success-velocity-contribution", 0.5], + ["apz.overscroll.enabled", true], + ["apz.test.logging_enabled", true], + ], + }); + + const tab = await BrowserTestUtils.openNewForegroundTab( + gBrowser, + "about:about", + true /* waitForLoad */ + ); + + const URL_ROOT = getRootDirectory(gTestPath).replace( + "chrome://mochitests/content/", + "http://mochi.test:8888/" + ); + BrowserTestUtils.loadURI( + tab.linkedBrowser, + URL_ROOT + "helper_swipe_gesture.html" + ); + await BrowserTestUtils.browserLoaded( + tab.linkedBrowser, + false /* includeSubFrames */, + URL_ROOT + "helper_swipe_gesture.html" + ); + + // Make sure we can go back to the previous page. + ok(gBrowser.webNavigation.canGoBack); + + await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { + // Set `overscroll-behavior-x: contain` and flush it. + content.document.documentElement.style.overscrollBehaviorX = "contain"; + content.document.documentElement.getBoundingClientRect(); + await content.wrappedJSObject.promiseApzFlushedRepaints(); + }); + + // Start a pan gesture but keep touching. + await panLeftToRightBegin(tab.linkedBrowser, 100, 100, 2); + + // Flush APZ pending requests to make sure the pan gesture has been processed. + await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { + await content.wrappedJSObject.promiseApzFlushedRepaints(); + }); + + const isOverscrolled = await SpecialPowers.spawn( + tab.linkedBrowser, + [], + () => { + const scrollId = SpecialPowers.DOMWindowUtils.getViewId( + content.document.scrollingElement + ); + const data = SpecialPowers.DOMWindowUtils.getCompositorAPZTestData(); + return data.additionalData.some(entry => { + return ( + entry.key == scrollId && + entry.value.split(",").includes("overscrolled") + ); + }); + } + ); + + ok(isOverscrolled, "The root scroller should have overscrolled"); + + // Finish the pan gesture. + await panLeftToRightUpdate(tab.linkedBrowser, 100, 100, 2); + await panLeftToRightEnd(tab.linkedBrowser, 100, 100, 2); + + // And wait a while to give a chance to navigate. + await waitForWhile(); + + // Make sure any navigation didn't happen. + is(tab.linkedBrowser.currentURI.spec, URL_ROOT + "helper_swipe_gesture.html"); + + BrowserTestUtils.removeTab(tab); + await SpecialPowers.popPrefEnv(); +}); + // NOTE: This test listens wheel events so that it causes an overscroll issue // (bug 1800022). To avoid the bug, we need to run this test case at the end // of this file. diff --git a/widget/tests/browser/helper_swipe_gesture.html b/widget/tests/browser/helper_swipe_gesture.html new file mode 100644 index 000000000000..1fa79dbbf361 --- /dev/null +++ b/widget/tests/browser/helper_swipe_gesture.html @@ -0,0 +1,20 @@ + + + + + + +
+