browser_net_security-tab-deselect.js (1892B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Test that security details tab is no longer selected if an insecure request 8 * is selected. 9 */ 10 11 add_task(async function () { 12 // This test needs to trigger http and https requests. 13 // Disable https-first to avoid blocking the HTTP request due to mixed content. 14 await pushPref("dom.security.https_first", false); 15 16 const { tab, monitor } = await initNetMonitor(CUSTOM_GET_URL, { 17 requestCount: 1, 18 }); 19 const { document, store, windowRequire } = monitor.panelWin; 20 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 21 22 store.dispatch(Actions.batchEnable(false)); 23 24 info("Performing requests."); 25 let wait = waitForNetworkEvents(monitor, 2); 26 const REQUEST_URLS = [ 27 "https://example.com" + CORS_SJS_PATH, 28 "http://example.com" + CORS_SJS_PATH, 29 ]; 30 await SpecialPowers.spawn( 31 tab.linkedBrowser, 32 [REQUEST_URLS], 33 async function (urls) { 34 for (const url of urls) { 35 content.wrappedJSObject.performRequests(1, url); 36 } 37 } 38 ); 39 await wait; 40 41 info("Wait until the Security tab is visible"); 42 wait = waitForDOM(document, "#security-tab"); 43 44 info("Selecting secure request."); 45 EventUtils.sendMouseEvent( 46 { type: "mousedown" }, 47 document.querySelectorAll(".request-list-item")[0] 48 ); 49 await wait; 50 51 info("Selecting security tab."); 52 EventUtils.sendMouseEvent( 53 { type: "mousedown" }, 54 document.querySelector("#security-tab") 55 ); 56 57 info("Selecting insecure request."); 58 EventUtils.sendMouseEvent( 59 { type: "mousedown" }, 60 document.querySelectorAll(".request-list-item")[1] 61 ); 62 63 ok( 64 document.querySelector("#headers-tab[aria-selected=true]"), 65 "Selected tab was reset when selected security tab was hidden." 66 ); 67 68 return teardown(monitor); 69 });