browser_net_copy_url.js (1751B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Tests if copying a request's url works. 8 */ 9 10 add_task(async function () { 11 const { tab, monitor } = await initNetMonitor(CUSTOM_GET_URL, { 12 requestCount: 1, 13 }); 14 info("Starting test... "); 15 16 const { document, store, windowRequire } = monitor.panelWin; 17 const { getSortedRequests } = windowRequire( 18 "devtools/client/netmonitor/src/selectors/index" 19 ); 20 21 // Execute requests. 22 await performRequests(monitor, tab, 1); 23 24 EventUtils.sendMouseEvent( 25 { type: "mousedown" }, 26 document.querySelectorAll(".request-list-item")[0] 27 ); 28 29 const requestItem = getSortedRequests(store.getState())[0]; 30 31 info("Simulating CmdOrCtrl+C on a first element of the request table"); 32 await waitForClipboardPromise( 33 () => synthesizeKeyShortcut("CmdOrCtrl+C"), 34 requestItem.url 35 ); 36 37 emptyClipboard(); 38 39 info("Simulating context click on a first element of the request table"); 40 EventUtils.sendMouseEvent( 41 { type: "contextmenu" }, 42 document.querySelectorAll(".request-list-item")[0] 43 ); 44 45 await waitForClipboardPromise(async function setup() { 46 await selectContextMenuItem(monitor, "request-list-context-copy-url"); 47 }, requestItem.url); 48 49 info( 50 "Check that URL isn't copied to clipboard when hitting CmdOrCtrl+C in input" 51 ); 52 // focus filter input 53 document.querySelector(".devtools-filterinput").focus(); 54 55 await SimpleTest.promiseClipboardChange( 56 // when expecting failure, aExpectedStringOrValidatorFn must be null 57 null, 58 () => synthesizeKeyShortcut("CmdOrCtrl+C"), 59 null, 60 // timeout 61 1000, 62 // Expect failure 63 true 64 ); 65 66 await teardown(monitor); 67 });