diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /devtools/client/netmonitor/test/browser_net_cause_source_map.js | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-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); +}); |