browser_net_resend_xhr.js (1778B)
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 resending a request works. 8 */ 9 10 add_task(async function () { 11 if ( 12 Services.prefs.getBoolPref( 13 "devtools.netmonitor.features.newEditAndResend", 14 true 15 ) 16 ) { 17 ok( 18 true, 19 "Skip this test when pref is true, because this panel won't be default when that is the case." 20 ); 21 return; 22 } 23 const { tab, monitor } = await initNetMonitor(POST_RAW_URL, { 24 requestCount: 1, 25 }); 26 27 const { document, store, windowRequire } = monitor.panelWin; 28 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 29 store.dispatch(Actions.batchEnable(false)); 30 31 // Executes 1 request 32 await performRequests(monitor, tab, 1); 33 34 // Selects 1st request 35 const firstRequest = document.querySelectorAll(".request-list-item")[0]; 36 EventUtils.sendMouseEvent({ type: "mousedown" }, firstRequest); 37 38 // Stores original request for comparison of values later 39 const { getSelectedRequest } = windowRequire( 40 "devtools/client/netmonitor/src/selectors/index" 41 ); 42 const originalRequest = getSelectedRequest(store.getState()); 43 44 const waitForResentRequestEvent = waitForNetworkEvents(monitor, 1); 45 // Context Menu > "Resend" 46 EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest); 47 await selectContextMenuItem(monitor, "request-list-context-resend-only"); 48 await waitForResentRequestEvent; 49 50 // Selects request that was resent 51 const selectedRequest = getSelectedRequest(store.getState()); 52 53 // Compares if the requests are the same. 54 Assert.strictEqual( 55 originalRequest.url, 56 selectedRequest.url, 57 "Both requests are the same" 58 ); 59 60 await teardown(monitor); 61 });