browser_contextmenu_share_linux.js (1431B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const BASE = getRootDirectory(gTestPath).replace( 7 "chrome://mochitests/content", 8 "https://example.com" 9 ); 10 const TEST_URL = BASE + "browser_contextmenu_shareurl.html"; 11 12 /** 13 * Test the "Share" item in the tab contextmenu on Linux. 14 */ 15 add_task(async function test_contextmenu_share_linux() { 16 await BrowserTestUtils.withNewTab(TEST_URL, async () => { 17 await openTabContextMenu(gBrowser.selectedTab); 18 19 let contextMenu = document.getElementById("tabContextMenu"); 20 let contextMenuClosedPromise = BrowserTestUtils.waitForPopupEvent( 21 contextMenu, 22 "hidden" 23 ); 24 let itemCreated = contextMenu.querySelector(".share-tab-url-item"); 25 ok(itemCreated, "Got Share item on Linux"); 26 await SimpleTest.promiseClipboardChange(TEST_URL, () => 27 contextMenu.activateItem(itemCreated) 28 ); 29 ok(true, "Copied to clipboard."); 30 31 await contextMenuClosedPromise; 32 }); 33 }); 34 35 /** 36 * Helper for opening the toolbar context menu. 37 */ 38 async function openTabContextMenu(tab) { 39 info("Opening tab context menu"); 40 let contextMenu = document.getElementById("tabContextMenu"); 41 let openTabContextMenuPromise = BrowserTestUtils.waitForPopupEvent( 42 contextMenu, 43 "shown" 44 ); 45 46 EventUtils.synthesizeMouseAtCenter(tab, { type: "contextmenu" }); 47 await openTabContextMenuPromise; 48 }