summaryrefslogtreecommitdiffstats
path: root/toolkit/components/tooltiptext/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:13:27 +0000
commit40a355a42d4a9444dc753c04c6608dade2f06a23 (patch)
tree871fc667d2de662f171103ce5ec067014ef85e61 /toolkit/components/tooltiptext/tests
parentAdding upstream version 124.0.1. (diff)
downloadfirefox-upstream/125.0.1.tar.xz
firefox-upstream/125.0.1.zip
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/tooltiptext/tests')
-rw-r--r--toolkit/components/tooltiptext/tests/browser.toml2
-rw-r--r--toolkit/components/tooltiptext/tests/browser_input_file_tooltips.js4
-rw-r--r--toolkit/components/tooltiptext/tests/browser_nac_tooltip.js66
-rw-r--r--toolkit/components/tooltiptext/tests/browser_shadow_dom_tooltip.js2
4 files changed, 71 insertions, 3 deletions
diff --git a/toolkit/components/tooltiptext/tests/browser.toml b/toolkit/components/tooltiptext/tests/browser.toml
index 189f880be2..d03716e683 100644
--- a/toolkit/components/tooltiptext/tests/browser.toml
+++ b/toolkit/components/tooltiptext/tests/browser.toml
@@ -13,4 +13,6 @@ support-files = ["xul_tooltiptext.xhtml"]
["browser_input_file_tooltips.js"]
skip-if = ["os == 'win' && os_version == '10.0'"] # Permafail on Win 10 (bug 1400368)
+["browser_nac_tooltip.js"]
+
["browser_shadow_dom_tooltip.js"]
diff --git a/toolkit/components/tooltiptext/tests/browser_input_file_tooltips.js b/toolkit/components/tooltiptext/tests/browser_input_file_tooltips.js
index 7d6c5043c4..2f1385f37f 100644
--- a/toolkit/components/tooltiptext/tests/browser_input_file_tooltips.js
+++ b/toolkit/components/tooltiptext/tests/browser_input_file_tooltips.js
@@ -2,7 +2,7 @@
let tempFile;
add_setup(async function () {
- await SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] });
+ await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });
tempFile = createTempFile();
registerCleanupFunction(function () {
tempFile.remove(true);
@@ -63,7 +63,7 @@ async function do_test(test) {
if (test.value) {
info("Creating mock filepicker to select files");
let MockFilePicker = SpecialPowers.MockFilePicker;
- MockFilePicker.init(window);
+ MockFilePicker.init(window.browsingContext);
MockFilePicker.returnValue = MockFilePicker.returnOK;
MockFilePicker.displayDirectory = FileUtils.getDir("TmpD", []);
MockFilePicker.setFiles([tempFile]);
diff --git a/toolkit/components/tooltiptext/tests/browser_nac_tooltip.js b/toolkit/components/tooltiptext/tests/browser_nac_tooltip.js
new file mode 100644
index 0000000000..449c8b9da7
--- /dev/null
+++ b/toolkit/components/tooltiptext/tests/browser_nac_tooltip.js
@@ -0,0 +1,66 @@
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/ */
+/* eslint-disable mozilla/no-arbitrary-setTimeout */
+
+"use strict";
+
+add_setup(async function () {
+ await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });
+});
+
+add_task(async function () {
+ await BrowserTestUtils.withNewTab(
+ {
+ gBrowser,
+ url: "data:text/html,<!DOCTYPE html>",
+ },
+ async function (browser) {
+ info("Moving mouse out of the way.");
+ await EventUtils.synthesizeAndWaitNativeMouseMove(browser, 300, 300);
+
+ await SpecialPowers.spawn(browser, [], function () {
+ let widget = content.document.insertAnonymousContent();
+ widget.root.innerHTML = `<button style="pointer-events: auto; position: absolute; width: 200px; height: 200px;" title="foo">bar</button>`;
+ let tttp = Cc[
+ "@mozilla.org/embedcomp/default-tooltiptextprovider;1"
+ ].getService(Ci.nsITooltipTextProvider);
+
+ let text = {};
+ let dir = {};
+ ok(
+ tttp.getNodeText(widget.root.querySelector("button"), text, dir),
+ "A tooltip should be shown for NAC"
+ );
+ is(text.value, "foo", "Tooltip text should be correct");
+ });
+
+ let awaitTooltipOpen = new Promise(resolve => {
+ let tooltipId = Services.appinfo.browserTabsRemoteAutostart
+ ? "remoteBrowserTooltip"
+ : "aHTMLTooltip";
+ let tooltip = document.getElementById(tooltipId);
+ tooltip.addEventListener(
+ "popupshown",
+ function (event) {
+ resolve(event.target);
+ },
+ { once: true }
+ );
+ });
+
+ info("Initial mouse move");
+ await EventUtils.synthesizeAndWaitNativeMouseMove(browser, 50, 5);
+ info("Waiting");
+ await new Promise(resolve => setTimeout(resolve, 400));
+ info("Second mouse move");
+ await EventUtils.synthesizeAndWaitNativeMouseMove(browser, 70, 5);
+ info("Waiting for tooltip to open");
+ let tooltip = await awaitTooltipOpen;
+ is(
+ tooltip.getAttribute("label"),
+ "foo",
+ "tooltip label should match expectation"
+ );
+ }
+ );
+});
diff --git a/toolkit/components/tooltiptext/tests/browser_shadow_dom_tooltip.js b/toolkit/components/tooltiptext/tests/browser_shadow_dom_tooltip.js
index 50386e07e2..4ceb918da1 100644
--- a/toolkit/components/tooltiptext/tests/browser_shadow_dom_tooltip.js
+++ b/toolkit/components/tooltiptext/tests/browser_shadow_dom_tooltip.js
@@ -1,7 +1,7 @@
/* eslint-disable mozilla/no-arbitrary-setTimeout */
add_setup(async function () {
- await SpecialPowers.pushPrefEnv({ set: [["ui.tooltipDelay", 0]] });
+ await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });
});
add_task(async function test_title_in_shadow_dom() {