From 36d22d82aa202bb199967e9512281e9a53db42c9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 21:33:14 +0200 Subject: Adding upstream version 115.7.0esr. Signed-off-by: Daniel Baumann --- .../test/browser/browser_popup_mouseover.js | 81 ++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 toolkit/components/satchel/test/browser/browser_popup_mouseover.js (limited to 'toolkit/components/satchel/test/browser/browser_popup_mouseover.js') diff --git a/toolkit/components/satchel/test/browser/browser_popup_mouseover.js b/toolkit/components/satchel/test/browser/browser_popup_mouseover.js new file mode 100644 index 0000000000..2b293ab983 --- /dev/null +++ b/toolkit/components/satchel/test/browser/browser_popup_mouseover.js @@ -0,0 +1,81 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +const { FormHistory } = ChromeUtils.importESModule( + "resource://gre/modules/FormHistory.sys.mjs" +); + +add_task(async function test() { + const url = `data:text/html,`; + await BrowserTestUtils.withNewTab( + { gBrowser, url }, + async function (browser) { + const { + autoCompletePopup, + autoCompletePopup: { richlistbox: itemsBox }, + } = browser; + const mockHistory = [ + { op: "add", fieldname: "field1", value: "value1" }, + { op: "add", fieldname: "field1", value: "value2" }, + { op: "add", fieldname: "field1", value: "value3" }, + { op: "add", fieldname: "field1", value: "value4" }, + ]; + + await FormHistory.update([{ op: "remove" }, ...mockHistory]); + await SpecialPowers.spawn(browser, [], async function () { + const input = content.document.querySelector("input"); + + input.focus(); + }); + + // show popup + await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); + await BrowserTestUtils.waitForCondition(() => { + return autoCompletePopup.popupOpen; + }); + const listItemElems = itemsBox.querySelectorAll( + ".autocomplete-richlistitem" + ); + Assert.equal( + listItemElems.length, + mockHistory.length, + "ensure result length" + ); + Assert.equal( + autoCompletePopup.mousedOverIndex, + -1, + "mousedOverIndex should be -1" + ); + + // navigate to the first item + await BrowserTestUtils.synthesizeKey("VK_DOWN", {}, browser); + Assert.equal( + autoCompletePopup.selectedIndex, + 0, + "selectedIndex should be 0" + ); + + // mouseover the second item + EventUtils.synthesizeMouseAtCenter(listItemElems[1], { + type: "mouseover", + }); + await BrowserTestUtils.waitForCondition(() => { + return (autoCompletePopup.mousedOverIndex = 1); + }); + Assert.ok(true, "mousedOverIndex changed"); + Assert.equal( + autoCompletePopup.selectedIndex, + 0, + "selectedIndex should not be changed by mouseover" + ); + + // close popup + await SpecialPowers.spawn(browser, [], async function () { + const input = content.document.querySelector("input"); + + input.blur(); + }); + } + ); +}); -- cgit v1.2.3