browser_net_column_slow-request-indicator.js (1944B)
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 that the slow request indicator is visible for slow requests. 8 */ 9 10 add_task(async function () { 11 // The script sjs_slow-script-server.sjs takes about 2s which is 12 // definately above the slow threshold set here. 13 const SLOW_THRESHOLD = 450; 14 15 await pushPref("dom.security.https_first", false); 16 17 Services.prefs.setIntPref("devtools.netmonitor.audits.slow", SLOW_THRESHOLD); 18 19 const { monitor } = await initNetMonitor(SLOW_REQUESTS_URL, { 20 requestCount: 2, 21 }); 22 info("Starting test... "); 23 24 const { document, store, windowRequire } = monitor.panelWin; 25 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 26 store.dispatch(Actions.batchEnable(false)); 27 28 const wait = waitForNetworkEvents(monitor, 2); 29 await reloadBrowser(); 30 await wait; 31 32 const requestList = document.querySelectorAll( 33 ".network-monitor .request-list-item" 34 ); 35 36 info("Checking the html document request"); 37 is( 38 requestList[0].querySelector(".requests-list-file div:first-child") 39 .textContent, 40 "html_slow-requests-test-page.html", 41 "The html document is the first request" 42 ); 43 is( 44 !!requestList[0].querySelector(".requests-list-slow-button"), 45 false, 46 "The request is not slow" 47 ); 48 49 info("Checking the slow script request"); 50 is( 51 requestList[1].querySelector(".requests-list-file div:first-child") 52 .textContent, 53 "sjs_slow-script-server.sjs", 54 "The slow test script is the second request" 55 ); 56 is( 57 !!requestList[1].querySelector(".requests-list-slow-button"), 58 true, 59 "The request is slow" 60 ); 61 62 is( 63 requestList[1] 64 .querySelector(".requests-list-slow-button") 65 .title.includes(`The recommended limit is ${SLOW_THRESHOLD} ms.`), 66 true, 67 "The tooltip text is correct" 68 ); 69 70 return teardown(monitor); 71 });