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_cause_source_map.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_cause_source_map.js')
-rw-r--r-- | devtools/client/netmonitor/test/browser_net_cause_source_map.js | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/devtools/client/netmonitor/test/browser_net_cause_source_map.js b/devtools/client/netmonitor/test/browser_net_cause_source_map.js new file mode 100644 index 0000000000..740bad3767 --- /dev/null +++ b/devtools/client/netmonitor/test/browser_net_cause_source_map.js @@ -0,0 +1,60 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +"use strict"; + +/** + * Tests if request cause is reported correctly when using source maps. + */ + +const CAUSE_FILE_NAME = "html_maps-test-page.html"; +const CAUSE_URL = HTTPS_EXAMPLE_URL + CAUSE_FILE_NAME; + +const N_EXPECTED_REQUESTS = 4; + +add_task(async function () { + // the initNetMonitor function clears the network request list after the + // page is loaded. That's why we first load a bogus page from SIMPLE_URL, + // and only then load the real thing from CAUSE_URL - we want to catch + // all the requests the page is making, not only the XHRs. + // We can't use about:blank here, because initNetMonitor checks that the + // page has actually made at least one request. + const { monitor } = await initNetMonitor(SIMPLE_URL, { requestCount: 1 }); + + const { document, store, windowRequire } = monitor.panelWin; + const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); + + store.dispatch(Actions.batchEnable(false)); + let waitPromise = waitForNetworkEvents(monitor, N_EXPECTED_REQUESTS); + await navigateTo(CAUSE_URL); + await waitPromise; + + info("Clicking item and waiting for details panel to open"); + waitPromise = waitForDOM(document, ".network-details-bar"); + const xhrRequestItem = document.querySelectorAll(".request-list-item")[3]; + EventUtils.sendMouseEvent({ type: "mousedown" }, xhrRequestItem); + await waitPromise; + + info("Clicking stack tab and waiting for stack panel to open"); + waitPromise = waitForDOM(document, "#stack-trace-panel"); + clickOnSidebarTab(document, "stack-trace"); + await waitPromise; + + info("Waiting for source maps to be applied"); + await waitUntil(() => { + const frames = document.querySelectorAll(".frame-link"); + return ( + frames && + frames.length >= 2 && + frames[0].textContent.includes("xhr_original") && + frames[1].textContent.includes("xhr_original") + ); + }); + + const frames = document.querySelectorAll(".frame-link"); + is(frames.length, 3, "should have 3 stack frames"); + is(frames[0].textContent, `reallydoxhr xhr_original.js:6`); + is(frames[1].textContent, `doxhr xhr_original.js:10`); + + await teardown(monitor); +}); |