commit ee898df722d8f559c15e9bf7e0625ee32aec96cf
parent 4b64cad5f815ea2189bd04f02efe5068c5d64af7
Author: Edgar Chen <echen@mozilla.com>
Date: Mon, 5 Jan 2026 11:45:33 +0000
Bug 2005080 - Add tests to ensure paste context menu is dismissed when tab becomes inactive; r=tschuster
Differential Revision: https://phabricator.services.mozilla.com/D275690
Diffstat:
2 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/dom/events/test/clipboard/browser.toml b/dom/events/test/clipboard/browser.toml
@@ -36,6 +36,9 @@ support-files = [
"file_toplevel.html",
"file_iframe.html",
]
+skip-if = [
+ "headless", # bug 1989339
+]
["browser_navigator_clipboard_contextmenu_suppression.js"]
support-files = [
diff --git a/dom/events/test/clipboard/browser_navigator_clipboard_contextmenu_dismiss.js b/dom/events/test/clipboard/browser_navigator_clipboard_contextmenu_dismiss.js
@@ -15,6 +15,67 @@ async function readText(aBrowser) {
});
}
+add_task(async function test_context_menu_dimiss_tab_close() {
+ let pasteButtonIsHidden;
+ await BrowserTestUtils.withNewTab(kContentFileUrl, async aBrowser => {
+ info(`Randomized text to avoid overlappings with other tests`);
+ await promiseWritingRandomTextToClipboard();
+
+ info(`Wait for paste context menu is shown`);
+ let pasteButtonIsShown = promisePasteButtonIsShown();
+ let readTextRequest = readText(aBrowser);
+ await pasteButtonIsShown;
+
+ pasteButtonIsHidden = promisePasteButtonIsHidden();
+ info("Close tab");
+ });
+
+ info(`Wait for paste context menu is hidden`);
+ await pasteButtonIsHidden;
+});
+
+add_task(async function test_context_menu_dimiss_tab_switch() {
+ await BrowserTestUtils.withNewTab(kContentFileUrl, async aBrowser => {
+ info(`Randomized text to avoid overlappings with other tests`);
+ await promiseWritingRandomTextToClipboard();
+
+ info(`Wait for paste context menu is shown`);
+ let pasteButtonIsShown = promisePasteButtonIsShown();
+ await readText(aBrowser);
+ await pasteButtonIsShown;
+
+ info("Switch tab");
+ let pasteButtonIsHidden = promisePasteButtonIsHidden();
+ let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser);
+
+ info(`Wait for paste context menu is hidden`);
+ await pasteButtonIsHidden;
+
+ BrowserTestUtils.removeTab(tab);
+ });
+});
+
+add_task(async function test_context_menu_dimiss_browser_window_switch() {
+ await BrowserTestUtils.withNewTab(kContentFileUrl, async aBrowser => {
+ info(`Randomized text to avoid overlappings with other tests`);
+ await promiseWritingRandomTextToClipboard();
+
+ info(`Wait for paste context menu is shown`);
+ let pasteButtonIsShown = promisePasteButtonIsShown();
+ await readText(aBrowser);
+ await pasteButtonIsShown;
+
+ info("Switch browser window");
+ let pasteButtonIsHidden = promisePasteButtonIsHidden();
+ let newWin = await BrowserTestUtils.openNewBrowserWindow();
+
+ info(`Wait for paste context menu is hidden`);
+ await pasteButtonIsHidden;
+
+ await BrowserTestUtils.closeWindow(newWin);
+ });
+});
+
add_task(async function test_context_menu_dimiss_tab_navigate() {
await BrowserTestUtils.withNewTab(kContentFileUrl, async aBrowser => {
info(`Randomized text to avoid overlappings with other tests`);