Bug 1811871 - Check collapsed attribute rather than computed opacity value to tell whether which navigation ison is currently visible. r=tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D167740
This commit is contained in:
Hiroyuki Ikezoe 2023-01-25 21:03:55 +00:00
parent a8ab9054a3
commit 63b11934d6
3 changed files with 67 additions and 10 deletions

View file

@ -713,16 +713,10 @@ var gHistorySwipeAnimation = {
return;
}
let prevOpacity = window
.getComputedStyle(this._prevBox)
.getPropertyValue("opacity");
let nextOpacity = window
.getComputedStyle(this._nextBox)
.getPropertyValue("opacity");
let box = null;
if (prevOpacity > 0) {
if (!this._prevBox.collapsed) {
box = this._prevBox;
} else if (nextOpacity > 0) {
} else if (!this._nextBox.collapsed) {
box = this._nextBox;
}
if (box != null) {

View file

@ -1852,7 +1852,7 @@ if (!window.hasOwnProperty("NativePanHandler")) {
});
}
async function panRightToLeft(aElement, aX, aY, aMultiplier) {
async function panRightToLeftBegin(aElement, aX, aY, aMultiplier) {
await NativePanHandler.promiseNativePanEvent(
aElement,
aX,
@ -1861,6 +1861,9 @@ async function panRightToLeft(aElement, aX, aY, aMultiplier) {
0,
NativePanHandler.beginPhase
);
}
async function panRightToLeftUpdate(aElement, aX, aY, aMultiplier) {
await NativePanHandler.promiseNativePanEvent(
aElement,
aX,
@ -1869,6 +1872,9 @@ async function panRightToLeft(aElement, aX, aY, aMultiplier) {
0,
NativePanHandler.updatePhase
);
}
async function panRightToLeftEnd(aElement, aX, aY, aMultiplier) {
await NativePanHandler.promiseNativePanEvent(
aElement,
aX,
@ -1879,6 +1885,12 @@ async function panRightToLeft(aElement, aX, aY, aMultiplier) {
);
}
async function panRightToLeft(aElement, aX, aY, aMultiplier) {
await panRightToLeftBegin(aElement, aX, aY, aMultiplier);
await panRightToLeftUpdate(aElement, aX, aY, aMultiplier);
await panRightToLeftEnd(aElement, aX, aY, aMultiplier);
}
async function panLeftToRight(aElement, aX, aY, aMultiplier) {
await panLeftToRightBegin(aElement, aX, aY, aMultiplier);
await panLeftToRightUpdate(aElement, aX, aY, aMultiplier);

View file

@ -582,7 +582,14 @@ add_task(async () => {
let transitionPromise = new Promise(resolve => {
gHistorySwipeAnimation._prevBox.addEventListener(
"transitionstart",
resolve,
event => {
if (
event.propertyName == "opacity" &&
event.target == gHistorySwipeAnimation._prevBox
) {
resolve();
}
},
{ once: true }
);
});
@ -604,6 +611,50 @@ add_task(async () => {
);
});
// Navigate forward and check the forward navigation icon box state.
startLoadingPromise = BrowserTestUtils.browserStarted(
tab.linkedBrowser,
secondPage
);
stoppedLoadingPromise = BrowserTestUtils.browserStopped(
tab.linkedBrowser,
secondPage
);
await panRightToLeftBegin(tab.linkedBrowser, 100, 100, 100);
ok(gHistorySwipeAnimation._nextBox != null, "should have nextbox");
transitionPromise = new Promise(resolve => {
gHistorySwipeAnimation._nextBox.addEventListener(
"transitionstart",
event => {
if (
event.propertyName == "opacity" &&
event.target == gHistorySwipeAnimation._nextBox
) {
resolve();
}
}
);
});
await panRightToLeftUpdate(tab.linkedBrowser, 100, 100, 100);
await panRightToLeftEnd(tab.linkedBrowser, 100, 100, 100);
// Make sure the gesture triggered going forward to the next page.
await Promise.all([startLoadingPromise, stoppedLoadingPromise]);
ok(gBrowser.webNavigation.canGoBack);
await transitionPromise;
await TestUtils.waitForCondition(() => {
return (
gHistorySwipeAnimation._nextBox == null &&
gHistorySwipeAnimation._prevBox == null
);
});
BrowserTestUtils.removeTab(tab);
await SpecialPowers.popPrefEnv();
});