commit 271284c1c82a7c27442f04d64bf5ad0545f8acd0
parent 60835df282886923a31534c25fb1e668b2b0c92f
Author: Hiroyuki Ikezoe <hikezoe.birchill@mozilla.com>
Date: Fri, 7 Nov 2025 01:58:04 +0000
Bug 1978682 - Stricter checks in browser_test_background_tab_load_scroll.js. r=botond
browser_test_background_tab_load_scroll.js has provided us a scenario
swtiching tabs. It just had tested there's no discrepancy between the
visual and the layout scroll offsets, it had not tested the scroll
offsets exactly.
Now the sticter checks test the layout offsets as it's supposed to be,
before reloading the offset is 10000, after reloading, it's 20000.
Differential Revision: https://phabricator.services.mozilla.com/D269336
Diffstat:
1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/gfx/layers/apz/test/mochitest/browser_test_background_tab_load_scroll.js b/gfx/layers/apz/test/mochitest/browser_test_background_tab_load_scroll.js
@@ -37,7 +37,7 @@ add_task(async function test_main() {
});
}
- async function checkScrollPosInContent(browser, iter, num) {
+ async function checkScrollPosInContent(browser, iter, reload) {
let visualScrollPos = await SpecialPowers.spawn(browser, [], function () {
const offsetX = {};
const offsetY = {};
@@ -61,10 +61,14 @@ add_task(async function test_main() {
scrollPos +
" (" +
iter +
- "," +
- num +
+ (reload ? reload : "") +
")"
);
+
+ // After reload, the scroll position should be doubled since the target
+ // document calls `scrollBy(0, 10000)` after restoring the previous scroll
+ // position `(0, 10000)`.
+ is(scrollPos, 10000 * (reload === "reload" ? 2 : 1));
}
for (let i = 0; i < 5; i++) {
@@ -88,7 +92,7 @@ add_task(async function test_main() {
await waitForApzInContent(browser);
- await checkScrollPosInContent(browser, i, 1);
+ await checkScrollPosInContent(browser, i);
await BrowserTestUtils.switchTab(gBrowser, blankTab);
@@ -103,7 +107,7 @@ add_task(async function test_main() {
await waitForApzInContent(browser);
- await checkScrollPosInContent(browser, i, 2);
+ await checkScrollPosInContent(browser, i, "reload");
// Cleanup
let tabClosed = BrowserTestUtils.waitForTabClosing(backgroundTab);