browser_net_server_timings.js (2022B)
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 server side timings are displayed 8 */ 9 add_task(async function () { 10 const { tab, monitor } = await initNetMonitor(HTTPS_CUSTOM_GET_URL, { 11 requestCount: 1, 12 }); 13 14 const { document, store, windowRequire } = monitor.panelWin; 15 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 16 store.dispatch(Actions.batchEnable(false)); 17 18 let wait = waitForNetworkEvents(monitor, 1); 19 await SpecialPowers.spawn( 20 tab.linkedBrowser, 21 [SERVER_TIMINGS_TYPE_SJS], 22 async function (url) { 23 content.wrappedJSObject.performRequests(1, url); 24 } 25 ); 26 await wait; 27 28 // There must be 4 timing values (including server side timings). 29 const timingsSelector = "#timings-panel .tabpanel-summary-container.server"; 30 wait = waitForDOM(document, timingsSelector, 4); 31 32 AccessibilityUtils.setEnv({ 33 // Keyboard users will will see the sidebar when the request row is 34 // selected. Accessibility is handled on the container level. 35 actionCountRule: false, 36 interactiveRule: false, 37 labelRule: false, 38 }); 39 EventUtils.sendMouseEvent( 40 { type: "click" }, 41 document.querySelectorAll(".request-list-item")[0] 42 ); 43 AccessibilityUtils.resetEnv(); 44 45 store.dispatch(Actions.toggleNetworkDetails()); 46 47 clickOnSidebarTab(document, "timings"); 48 await wait; 49 50 // Check the UI contains server side timings and correct values 51 const timings = document.querySelectorAll(timingsSelector, 4); 52 is( 53 timings[0].textContent, 54 "time1123 ms", 55 "The first server-timing must be correct" 56 ); 57 is( 58 timings[1].textContent, 59 "time20 ms", 60 "The second server-timing must be correct" 61 ); 62 is( 63 timings[2].textContent, 64 "time31.66 min", 65 "The third server-timing must be correct" 66 ); 67 is( 68 timings[3].textContent, 69 "time41.11 s", 70 "The fourth server-timing must be correct" 71 ); 72 73 await teardown(monitor); 74 });