From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- layout/base/tests/browser_bug1757410.js | 62 +++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 layout/base/tests/browser_bug1757410.js (limited to 'layout/base/tests/browser_bug1757410.js') diff --git a/layout/base/tests/browser_bug1757410.js b/layout/base/tests/browser_bug1757410.js new file mode 100644 index 0000000000..59c740e5a8 --- /dev/null +++ b/layout/base/tests/browser_bug1757410.js @@ -0,0 +1,62 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const PAGECONTENT = + "" + + "" + + "" + + ""; + +const pageUrl = "data:text/html," + encodeURIComponent(PAGECONTENT); + +add_task(async function test() { + if (window.devicePixelRatio == 1) { + ok( + true, + "Skip this test since this test is supposed to run on HiDPI mode, " + + "the devixePixelRato on this machine is " + + window.devicePixelRatio + ); + return; + } + + const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, pageUrl); + + // Scroll the content a bit. + const originalScrollPosition = await SpecialPowers.spawn( + tab.linkedBrowser, + [], + async () => { + content.document.scrollingElement.scrollTop = 100; + return content.document.scrollingElement.scrollTop; + } + ); + + // Disabling HiDPI mode and check the scroll position. + SpecialPowers.DOMWindowUtils.setHiDPIMode(false); + // Make sure we restore even if this test failed. + registerCleanupFunction(() => { + SpecialPowers.DOMWindowUtils.restoreHiDPIMode(); + }); + + const scrollPosition = await SpecialPowers.spawn( + tab.linkedBrowser, + [], + async () => { + return content.document.scrollingElement.scrollTop; + } + ); + is( + originalScrollPosition, + scrollPosition, + "The scroll position should be kept" + ); + BrowserTestUtils.removeTab(tab); +}); -- cgit v1.2.3