diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /browser/base/content/test/general/browser_visibleFindSelection.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/base/content/test/general/browser_visibleFindSelection.js')
-rw-r--r-- | browser/base/content/test/general/browser_visibleFindSelection.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/browser/base/content/test/general/browser_visibleFindSelection.js b/browser/base/content/test/general/browser_visibleFindSelection.js new file mode 100644 index 0000000000..56099521e2 --- /dev/null +++ b/browser/base/content/test/general/browser_visibleFindSelection.js @@ -0,0 +1,62 @@ +add_task(async function () { + const childContent = + "<div style='position: absolute; left: 2200px; background: green; width: 200px; height: 200px;'>" + + "div</div><div style='position: absolute; left: 0px; background: red; width: 200px; height: 200px;'>" + + "<span id='s'>div</span></div>"; + + let tab = (gBrowser.selectedTab = BrowserTestUtils.addTab(gBrowser)); + + await promiseTabLoadEvent( + tab, + "data:text/html;charset=utf-8," + escape(childContent) + ); + await SimpleTest.promiseFocus(gBrowser.selectedBrowser); + + let remote = gBrowser.selectedBrowser.isRemoteBrowser; + + let findBarOpenPromise = BrowserTestUtils.waitForEvent( + gBrowser, + "findbaropen" + ); + EventUtils.synthesizeKey("f", { accelKey: true }); + await findBarOpenPromise; + + ok(gFindBarInitialized, "find bar is now initialized"); + + // Finds the div in the green box. + let scrollPromise = remote + ? BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "scroll") + : BrowserTestUtils.waitForEvent(gBrowser, "scroll"); + EventUtils.sendString("div"); + await scrollPromise; + + // Wait for one paint to ensure we've processed the previous key events and scrolling. + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { + return new Promise(resolve => { + content.requestAnimationFrame(() => { + content.setTimeout(resolve, 0); + }); + }); + }); + + // Finds the div in the red box. + scrollPromise = remote + ? BrowserTestUtils.waitForContentEvent(gBrowser.selectedBrowser, "scroll") + : BrowserTestUtils.waitForEvent(gBrowser, "scroll"); + EventUtils.synthesizeKey("g", { accelKey: true }); + await scrollPromise; + + await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () { + Assert.ok( + content.document.getElementById("s").getBoundingClientRect().left >= 0, + "scroll should include find result" + ); + }); + + // clear the find bar + EventUtils.synthesizeKey("a", { accelKey: true }); + EventUtils.synthesizeKey("KEY_Delete"); + + gFindBar.close(); + gBrowser.removeCurrentTab(); +}); |