browser_net_edit_resend_cancel.js (2199B)
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 original request's header panel is visible when custom request is cancelled. 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 24 const { monitor } = await initNetMonitor(HTTPS_SIMPLE_URL, { 25 requestCount: 1, 26 }); 27 info("Starting test... "); 28 29 const { document, store, windowRequire } = monitor.panelWin; 30 const { getSelectedRequest } = windowRequire( 31 "devtools/client/netmonitor/src/selectors/index" 32 ); 33 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 34 store.dispatch(Actions.batchEnable(false)); 35 36 // Reload to have one request in the list 37 const waitForEvents = waitForNetworkEvents(monitor, 1); 38 await navigateTo(HTTPS_SIMPLE_URL); 39 await waitForEvents; 40 41 // Context Menu > "Edit & Resend" 42 const firstRequest = document.querySelectorAll(".request-list-item")[0]; 43 const waitForHeaders = waitUntil(() => 44 document.querySelector(".headers-overview") 45 ); 46 EventUtils.sendMouseEvent({ type: "mousedown" }, firstRequest); 47 await waitForHeaders; 48 EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest); 49 const firstRequestState = getSelectedRequest(store.getState()); 50 await selectContextMenuItem(monitor, "request-list-context-edit-resend"); 51 52 // Waits for "Edit & Resend" panel to appear > New request "Cancel" 53 await waitUntil(() => document.querySelector(".custom-request-panel")); 54 document.querySelector("#custom-request-close-button").click(); 55 const finalRequestState = getSelectedRequest(store.getState()); 56 57 Assert.strictEqual( 58 firstRequestState.id, 59 finalRequestState.id, 60 "Original request is selected after cancel button is clicked" 61 ); 62 63 Assert.notStrictEqual( 64 document.querySelector(".headers-overview"), 65 null, 66 "Request is selected and headers panel is visible" 67 ); 68 69 await teardown(monitor); 70 });