diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /devtools/client/netmonitor/test/browser_net_new_request_panel_content-length.js | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'devtools/client/netmonitor/test/browser_net_new_request_panel_content-length.js')
-rw-r--r-- | devtools/client/netmonitor/test/browser_net_new_request_panel_content-length.js | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/test/browser_net_new_request_panel_content-length.js b/devtools/client/netmonitor/test/browser_net_new_request_panel_content-length.js new file mode 100644 index 0000000000..7d0bbc42c7 --- /dev/null +++ b/devtools/client/netmonitor/test/browser_net_new_request_panel_content-length.js @@ -0,0 +1,94 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Test that the content length field is always updated when + * the message body changes. + */ + +add_task(async function () { + const { tab, monitor } = await initNetMonitor(POST_RAW_URL, { + requestCount: 1, + }); + + info("Starting test... "); + + const { window, document, store, windowRequire } = monitor.panelWin; + + // Action should be processed synchronously in tests. + const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); + store.dispatch(Actions.batchEnable(false)); + + const { getSelectedRequest } = windowRequire( + "devtools/client/netmonitor/src/selectors/index" + ); + + await performRequests(monitor, tab, 1); + + info("Select the first request"); + const firstRequest = document.querySelectorAll(".request-list-item")[0]; + + const waitForHeaders = waitUntil(() => + document.querySelector(".headers-overview") + ); + EventUtils.sendMouseEvent({ type: "mousedown" }, firstRequest); + await waitForHeaders; + + info("Open the first request in the request panel to resend"); + const waitForPanels = waitUntil( + () => + document.querySelector(".http-custom-request-panel") && + document.querySelector("#http-custom-request-send-button").disabled === + false + ); + + // Open the context menu and select resend menu item + EventUtils.sendMouseEvent({ type: "contextmenu" }, firstRequest); + await selectContextMenuItem(monitor, "request-list-context-edit-resend"); + + await waitForPanels; + + const contentLengthField = document.querySelector( + "#http-custom-content-length .http-custom-input-value" + ); + + is(contentLengthField.value, "15", "The content length is correct"); + + const messageBody = document.querySelector("#http-custom-postdata-value"); + messageBody.focus(); + EventUtils.sendString("bla=333&", window); + + await waitUntil(() => { + return contentLengthField.value == "23"; + }); + ok(true, "The content length is still correct"); + + const prevRequest = getSelectedRequest(store.getState()); + + info("Send the request"); + const waitUntilEventsDisplayed = waitForNetworkEvents(monitor, 1); + document.querySelector("#http-custom-request-send-button").click(); + await waitUntilEventsDisplayed; + + // Also make sure the selected request has switched to the new resent request + await waitUntil(() => getSelectedRequest(store.getState()) !== prevRequest); + + const newRequest = getSelectedRequest(store.getState()); + + // Wait for request headers to be available + await waitUntil(() => newRequest.requestHeaders?.headers.length); + + const contentLengthHeader = newRequest.requestHeaders.headers.find( + header => header.name == "Content-Length" + ); + + is( + contentLengthHeader.value, + "23", + "The content length of the resent request is correct" + ); + + await teardown(monitor); +}); |