From 26a029d407be480d791972afb5975cf62c9360a6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 02:47:55 +0200 Subject: Adding upstream version 124.0.1. Signed-off-by: Daniel Baumann --- .../preferences/tests/browser_searchScroll.js | 66 ++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 browser/components/preferences/tests/browser_searchScroll.js (limited to 'browser/components/preferences/tests/browser_searchScroll.js') diff --git a/browser/components/preferences/tests/browser_searchScroll.js b/browser/components/preferences/tests/browser_searchScroll.js new file mode 100644 index 0000000000..ef3af646e9 --- /dev/null +++ b/browser/components/preferences/tests/browser_searchScroll.js @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/publicdomain/zero/1.0/ */ + +Services.scriptloader.loadSubScript( + "chrome://mochitests/content/browser/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js", + this +); + +const { AddonTestUtils } = ChromeUtils.importESModule( + "resource://testing-common/AddonTestUtils.sys.mjs" +); +const { SearchTestUtils } = ChromeUtils.importESModule( + "resource://testing-common/SearchTestUtils.sys.mjs" +); +const { SearchUtils } = ChromeUtils.importESModule( + "resource://gre/modules/SearchUtils.sys.mjs" +); + +AddonTestUtils.initMochitest(this); +SearchTestUtils.init(this); + +add_setup(async function () { + await SpecialPowers.pushPrefEnv({ + set: [["dom.w3c_touch_events.enabled", 0]], + }); +}); + +add_task(async function test_scroll() { + info("Open preferences page for search"); + await openPreferencesViaOpenPreferencesAPI("search", { leaveOpen: true }); + + const doc = gBrowser.selectedBrowser.contentDocument; + const tree = doc.querySelector("#engineList"); + + info("Add engines to make the tree scrollable"); + for (let i = 0, n = parseInt(tree.getAttribute("rows")); i < n; i++) { + let extension = await SearchTestUtils.installSearchExtension({ + id: `${i}@tests.mozilla.org`, + name: `example${i}`, + version: "1.0", + keyword: `example${i}`, + }); + await AddonTestUtils.waitForSearchProviderStartup(extension); + } + + info("Make tree element move into viewport"); + const mainContent = doc.querySelector(".main-content"); + const readyForScrollIntoView = new Promise(r => { + mainContent.addEventListener("scroll", r, { once: true }); + }); + tree.scrollIntoView(); + await readyForScrollIntoView; + + const previousScroll = mainContent.scrollTop; + + await promiseMoveMouseAndScrollWheelOver(tree, 1, 1, false); + + Assert.equal( + previousScroll, + mainContent.scrollTop, + "Container element does not scroll" + ); + + info("Clean up"); + gBrowser.removeCurrentTab(); +}); -- cgit v1.2.3