diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /devtools/client/netmonitor | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/netmonitor')
8 files changed, 193 insertions, 3 deletions
diff --git a/devtools/client/netmonitor/test/browser.toml b/devtools/client/netmonitor/test/browser.toml index 186810de06..52f465ab57 100644 --- a/devtools/client/netmonitor/test/browser.toml +++ b/devtools/client/netmonitor/test/browser.toml @@ -12,6 +12,7 @@ support-files = [ "html_cause-test-page.html", "html_content-type-without-cache-test-page.html", "html_brotli-test-page.html", + "html_zstd-test-page.html", "html_image-tooltip-test-page.html", "html_cache-test-page.html", "html_cors-test-page.html", @@ -49,6 +50,7 @@ support-files = [ "html_single-get-page.html", "html_slow-requests-test-page.html", "html_send-beacon.html", + "html_send-beacon-late-iframe-request.html", "html_sorting-test-page.html", "html_statistics-edge-case-page.html", "html_statistics-test-page.html", @@ -557,3 +559,5 @@ fail-if = ["a11y_checks"] # Bug 1849028 clicked element may not be focusable and ["browser_net_ws-sse-persist-columns.js"] ["browser_net_ws-stomp-payload.js"] + +["browser_net_zstd.js"] diff --git a/devtools/client/netmonitor/test/browser_net_clear.js b/devtools/client/netmonitor/test/browser_net_clear.js index 5a97de3e02..e831d07e36 100644 --- a/devtools/client/netmonitor/test/browser_net_clear.js +++ b/devtools/client/netmonitor/test/browser_net_clear.js @@ -15,7 +15,7 @@ Services.scriptloader.loadSubScript( add_task(async function () { Services.prefs.setBoolPref("devtools.webconsole.filter.net", true); - const { monitor, toolbox } = await initNetMonitor(SIMPLE_URL, { + const { monitor, toolbox } = await initNetMonitor(HTTPS_SIMPLE_URL, { requestCount: 1, }); info("Starting test... "); @@ -43,7 +43,7 @@ add_task(async function () { await onWebConsole; info("Wait for request"); - await waitFor(() => findMessageByType(hud, SIMPLE_URL, ".network")); + await waitFor(() => findMessageByType(hud, HTTPS_SIMPLE_URL, ".network")); info("Switch back the the netmonitor"); await monitor.toolbox.selectTool("netmonitor"); @@ -63,7 +63,9 @@ add_task(async function () { info("Wait for network request to show and that its disabled"); - await waitFor(() => findMessageByType(hud, SIMPLE_URL, ".network.disabled")); + await waitFor(() => + findMessageByType(hud, HTTPS_SIMPLE_URL, ".network.disabled") + ); // Switch back to the netmonitor. await monitor.toolbox.selectTool("netmonitor"); diff --git a/devtools/client/netmonitor/test/browser_net_column_slow-request-indicator.js b/devtools/client/netmonitor/test/browser_net_column_slow-request-indicator.js index 368873c3c6..34dd64ac38 100644 --- a/devtools/client/netmonitor/test/browser_net_column_slow-request-indicator.js +++ b/devtools/client/netmonitor/test/browser_net_column_slow-request-indicator.js @@ -12,6 +12,8 @@ add_task(async function () { // definately above the slow threshold set here. const SLOW_THRESHOLD = 450; + await pushPref("dom.security.https_first", false); + Services.prefs.setIntPref("devtools.netmonitor.audits.slow", SLOW_THRESHOLD); const { monitor } = await initNetMonitor(SLOW_REQUESTS_URL, { diff --git a/devtools/client/netmonitor/test/browser_net_send-beacon.js b/devtools/client/netmonitor/test/browser_net_send-beacon.js index d47299ca7f..9d1f078bf5 100644 --- a/devtools/client/netmonitor/test/browser_net_send-beacon.js +++ b/devtools/client/netmonitor/test/browser_net_send-beacon.js @@ -7,6 +7,8 @@ * Tests if beacons are handled correctly. */ +const IFRAME_URL = EXAMPLE_URL + "html_send-beacon-late-iframe-request.html"; + add_task(async function () { const { tab, monitor } = await initNetMonitor(SEND_BEACON_URL, { requestCount: 1, @@ -40,5 +42,26 @@ add_task(async function () { is(request.status, "404", "The status is correct."); is(request.blockedReason, 0, "The request is not blocked"); + const onNetworkEvents = waitForNetworkEvents(monitor, 2); + await SpecialPowers.spawn( + tab.linkedBrowser, + [IFRAME_URL], + async function (url) { + const iframe = content.document.createElement("iframe"); + iframe.src = url; + content.document.body.appendChild(iframe); + await new Promise(resolve => (iframe.onload = resolve)); + iframe.remove(); + } + ); + await onNetworkEvents; + + // Request at index 1 will be the HTML page of the iframe + const lateRequest = getSortedRequests(store.getState())[2]; + is(lateRequest.method, "POST", "The method is correct."); + ok(lateRequest.url.endsWith("beacon_late_request"), "The URL is correct."); + is(lateRequest.status, "404", "The status is correct."); + is(lateRequest.blockedReason, 0, "The request is not blocked"); + return teardown(monitor); }); diff --git a/devtools/client/netmonitor/test/browser_net_zstd.js b/devtools/client/netmonitor/test/browser_net_zstd.js new file mode 100644 index 0000000000..07b6f3a89f --- /dev/null +++ b/devtools/client/netmonitor/test/browser_net_zstd.js @@ -0,0 +1,81 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +const ZSTD_URL = HTTPS_EXAMPLE_URL + "html_zstd-test-page.html"; +const ZSTD_REQUESTS = 1; + +/** + * Test zstd encoded response is handled correctly on HTTPS. + */ + +add_task(async function () { + const { + L10N, + } = require("resource://devtools/client/netmonitor/src/utils/l10n.js"); + + const { tab, monitor } = await initNetMonitor(ZSTD_URL, { + requestCount: 1, + }); + info("Starting test... "); + + const { document, store, windowRequire } = monitor.panelWin; + const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); + const { getDisplayedRequests, getSortedRequests } = windowRequire( + "devtools/client/netmonitor/src/selectors/index" + ); + + store.dispatch(Actions.batchEnable(false)); + + // Execute requests. + await performRequests(monitor, tab, ZSTD_REQUESTS); + + const requestItem = document.querySelector(".request-list-item"); + // Status code title is generated on hover + const requestsListStatus = requestItem.querySelector(".status-code"); + EventUtils.sendMouseEvent({ type: "mouseover" }, requestsListStatus); + await waitUntil(() => requestsListStatus.title); + await waitForDOMIfNeeded(requestItem, ".requests-list-timings-total"); + + verifyRequestItemTarget( + document, + getDisplayedRequests(store.getState()), + getSortedRequests(store.getState())[0], + "GET", + HTTPS_CONTENT_TYPE_SJS + "?fmt=zstd", + { + status: 200, + statusText: "OK", + type: "json", + fullMimeType: "text/json", + transferred: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 261), + size: L10N.getFormatStrWithNumbers("networkMenu.sizeB", 64), + time: true, + } + ); + + const wait = waitForDOM(document, ".CodeMirror-code"); + const onResponseContent = monitor.panelWin.api.once( + TEST_EVENTS.RECEIVED_RESPONSE_CONTENT + ); + store.dispatch(Actions.toggleNetworkDetails()); + clickOnSidebarTab(document, "response"); + await wait; + await onResponseContent; + await testResponse("zstd"); + await teardown(monitor); + + function testResponse(type) { + switch (type) { + case "zstd": { + is( + getCodeMirrorValue(monitor), + "X".repeat(64), + "The text shown in the source editor is incorrect for the zstd request." + ); + break; + } + } + } +}); diff --git a/devtools/client/netmonitor/test/html_send-beacon-late-iframe-request.html b/devtools/client/netmonitor/test/html_send-beacon-late-iframe-request.html new file mode 100644 index 0000000000..3d567bd5d9 --- /dev/null +++ b/devtools/client/netmonitor/test/html_send-beacon-late-iframe-request.html @@ -0,0 +1,25 @@ +<!-- Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ --> +<!doctype html> + +<html> + <head> + <meta charset="utf-8"/> + <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> + <meta http-equiv="Pragma" content="no-cache" /> + <meta http-equiv="Expires" content="0" /> + <title>Network Monitor test page</title> + </head> + + <body> + <p>Do a late beacon request on iframe removal</p> + + <script type="text/javascript"> + "use strict"; + + window.onunload = () => { + navigator.sendBeacon("beacon_late_request"); + }; + </script> + </body> +</html> diff --git a/devtools/client/netmonitor/test/html_zstd-test-page.html b/devtools/client/netmonitor/test/html_zstd-test-page.html new file mode 100644 index 0000000000..52fdabcecb --- /dev/null +++ b/devtools/client/netmonitor/test/html_zstd-test-page.html @@ -0,0 +1,41 @@ +<!-- Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ --> + <!doctype html> + + <html> + <head> + <meta charset="utf-8"/> + <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" /> + <meta http-equiv="Pragma" content="no-cache" /> + <meta http-equiv="Expires" content="0" /> + <title>Network Monitor test page</title> + </head> + + <body> + <p>Zstd test</p> + + <script type="text/javascript"> + /* exported performRequests */ + "use strict"; + + function get(address) { + return new Promise(resolve => { + const xhr = new XMLHttpRequest(); + xhr.open("GET", address, true); + + xhr.onreadystatechange = function() { + if (this.readyState == this.DONE) { + resolve(); + } + }; + xhr.send(null); + }); + } + + async function performRequests() { + await get("sjs_content-type-test-server.sjs?fmt=zstd"); + } + </script> + </body> + + </html> diff --git a/devtools/client/netmonitor/test/sjs_content-type-test-server.sjs b/devtools/client/netmonitor/test/sjs_content-type-test-server.sjs index d9ac186396..adc882252d 100644 --- a/devtools/client/netmonitor/test/sjs_content-type-test-server.sjs +++ b/devtools/client/netmonitor/test/sjs_content-type-test-server.sjs @@ -372,6 +372,18 @@ function handleRequest(request, response) { response.finish(); break; } + case "zstd": { + response.setStatusLine(request.httpVersion, status, "OK"); + response.setHeader("Content-Type", "text/json", false); + response.setHeader("Content-Encoding", "zstd", false); + setCacheHeaders(); + // Use static data since we cannot encode zstandard. + const data = "(\xb5/\xfd @E\x00\x00\x10XX\x01\x00\x93\x00\x16"; + response.setHeader("Content-Length", "" + data.length, false); + response.write(data); + response.finish(); + break; + } case "hls-m3u8": { response.setStatusLine(request.httpVersion, status, "OK"); response.setHeader("Content-Type", "application/x-mpegurl", false); |