browser_net_cause_source_map.js (2148B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 /** 7 * Tests if request cause is reported correctly when using source maps. 8 */ 9 10 const N_EXPECTED_REQUESTS = 4; 11 12 add_task(async function () { 13 // the initNetMonitor function clears the network request list after the 14 // page is loaded. That's why we first load a bogus page from SIMPLE_URL, 15 // and only then load the real thing from SOURCEMAP_URL - we want to catch 16 // all the requests the page is making, not only the XHRs. 17 // We can't use about:blank here, because initNetMonitor checks that the 18 // page has actually made at least one request. 19 const { monitor } = await initNetMonitor(SIMPLE_URL, { requestCount: 1 }); 20 21 const { document, store, windowRequire } = monitor.panelWin; 22 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index"); 23 24 store.dispatch(Actions.batchEnable(false)); 25 let waitPromise = waitForNetworkEvents(monitor, N_EXPECTED_REQUESTS); 26 await navigateTo(SOURCEMAP_URL); 27 await waitPromise; 28 29 info("Clicking item and waiting for details panel to open"); 30 waitPromise = waitForDOM(document, ".network-details-bar"); 31 const xhrRequestItem = document.querySelectorAll(".request-list-item")[3]; 32 EventUtils.sendMouseEvent({ type: "mousedown" }, xhrRequestItem); 33 await waitPromise; 34 35 info("Clicking stack tab and waiting for stack panel to open"); 36 waitPromise = waitForDOM(document, "#stack-trace-panel"); 37 clickOnSidebarTab(document, "stack-trace"); 38 await waitPromise; 39 40 info("Waiting for source maps to be applied"); 41 await waitUntil(() => { 42 const frames = document.querySelectorAll(".frame-link"); 43 return ( 44 frames && 45 frames.length >= 2 && 46 frames[0].textContent.includes("xhr_original") && 47 frames[1].textContent.includes("xhr_original") 48 ); 49 }); 50 51 const frames = document.querySelectorAll(".frame-link"); 52 is(frames.length, 3, "should have 3 stack frames"); 53 is(frames[0].textContent, `reallydoxhr xhr_original.js:6:1`); 54 is(frames[1].textContent, `doxhr xhr_original.js:10:1`); 55 56 await teardown(monitor); 57 });