browser_net_zstd.js (2394B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 const ZSTD_URL = HTTPS_EXAMPLE_URL + "html_zstd-test-page.html"; 7 const ZSTD_REQUESTS = 1; 8 9 /** 10 * Test zstd encoded response is handled correctly on HTTPS. 11 */ 12 13 add_task(async function () { 14 const { 15 L10N, 16 } = require("resource://devtools/client/netmonitor/src/utils/l10n.js"); 17 18 const { tab, monitor } = await initNetMonitor(ZSTD_URL, { 19 requestCount: 1, 20 }); 21 info("Starting test... "); 22 23 const { document, store, windowRequire } = monitor.panelWin; 24 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 25 const { getDisplayedRequests, getSortedRequests } = windowRequire( 26 "devtools/client/netmonitor/src/selectors/index" 27 ); 28 29 store.dispatch(Actions.batchEnable(false)); 30 31 // Execute requests. 32 await performRequests(monitor, tab, ZSTD_REQUESTS); 33 34 const requestItem = document.querySelector(".request-list-item"); 35 // Status code title is generated on hover 36 const requestsListStatus = requestItem.querySelector(".status-code"); 37 EventUtils.sendMouseEvent({ type: "mouseover" }, requestsListStatus); 38 await waitUntil(() => requestsListStatus.title); 39 await waitForDOMIfNeeded(requestItem, ".requests-list-timings-total"); 40 41 await verifyRequestItemTarget( 42 document, 43 getDisplayedRequests(store.getState()), 44 getSortedRequests(store.getState())[0], 45 "GET", 46 HTTPS_CONTENT_TYPE_SJS + "?fmt=zstd", 47 { 48 status: 200, 49 statusText: "OK", 50 type: "json", 51 fullMimeType: "text/json", 52 transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 261), 53 size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 64), 54 time: true, 55 } 56 ); 57 58 const wait = waitForDOM(document, ".cm-content"); 59 const onResponseContent = monitor.panelWin.api.once( 60 TEST_EVENTS.RECEIVED_RESPONSE_CONTENT 61 ); 62 store.dispatch(Actions.toggleNetworkDetails()); 63 clickOnSidebarTab(document, "response"); 64 await wait; 65 await onResponseContent; 66 await testResponse("zstd"); 67 await teardown(monitor); 68 69 function testResponse(type) { 70 switch (type) { 71 case "zstd": { 72 is( 73 getCodeMirrorValue(monitor), 74 "X".repeat(64), 75 "The text shown in the source editor is incorrect for the zstd request." 76 ); 77 break; 78 } 79 } 80 } 81 });