browser_net_telemetry_edit_resend.js (2206B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const ALL_CHANNELS = Ci.nsITelemetry.DATASET_ALL_CHANNELS; 7 8 /** 9 * Test the edit_resend telemetry event. 10 */ 11 add_task(async function () { 12 if ( 13 Services.prefs.getBoolPref( 14 "devtools.netmonitor.features.newEditAndResend", 15 true 16 ) 17 ) { 18 ok( 19 true, 20 "Skip this test when pref is true, because this panel won't be default when that is the case." 21 ); 22 return; 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 Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 31 store.dispatch(Actions.batchEnable(false)); 32 33 // Remove all telemetry events (you can check about:telemetry). 34 Services.telemetry.clearEvents(); 35 36 // Ensure no events have been logged 37 const snapshot = Services.telemetry.snapshotEvents(ALL_CHANNELS, true); 38 ok(!snapshot.parent, "No events have been logged for the main process"); 39 40 // Reload to have one request in the list. 41 const waitForEvents = waitForNetworkEvents(monitor, 1); 42 await navigateTo(HTTPS_SIMPLE_URL); 43 await waitForEvents; 44 45 // Open context menu and execute "Edit & Resend". 46 const firstRequest = document.querySelectorAll(".request-list-item")[0]; 47 const waitForHeaders = waitUntil(() => 48 document.querySelector(".headers-overview") 49 ); 50 EventUtils.sendMouseEvent({ type: "mousedown" }, firstRequest); 51 await waitForHeaders; 52 await waitForRequestData(store, ["requestHeaders", "responseHeaders"]); 53 EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest); 54 55 // Open "New Request" form and resend. 56 await selectContextMenuItem(monitor, "request-list-context-edit-resend"); 57 await waitUntil(() => document.querySelector("#custom-request-send-button")); 58 document.querySelector("#custom-request-send-button").click(); 59 60 await waitForNetworkEvents(monitor, 1); 61 62 // Verify existence of the telemetry event. 63 checkTelemetryEvent( 64 {}, 65 { 66 method: "edit_resend", 67 } 68 ); 69 70 await teardown(monitor); 71 });