Backed out changeset b71c8c052463 (bug 1943846) for causing mass failures. CLOSED...
[gecko.git] / devtools / client / netmonitor / test / browser_net_view-source-debugger.js
blobe443001da07ff1be89a0489948f4ae2e1f7144db
1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
4 "use strict";
6 // There are shutdown issues for which multiple rejections are left uncaught.
7 // See bug 1018184 for resolving these issues.
8 const { PromiseTestUtils } = ChromeUtils.importESModule(
9 "resource://testing-common/PromiseTestUtils.sys.mjs"
11 PromiseTestUtils.allowMatchingRejectionsGlobally(/Component not initialized/);
12 PromiseTestUtils.allowMatchingRejectionsGlobally(/Connection closed/);
14 Services.scriptloader.loadSubScript(
15 "chrome://mochitests/content/browser/devtools/client/debugger/test/mochitest/shared-head.js",
16 this
19 /**
20 * Tests if on clicking the stack frame, UI switches to the Debugger panel.
22 add_task(async function () {
23 // Set a higher panel height in order to get full CodeMirror content
24 await pushPref("devtools.toolbox.footer.height", 400);
26 const { tab, monitor, toolbox } = await initNetMonitor(POST_DATA_URL, {
27 requestCount: 1,
28 });
29 info("Starting test... ");
31 const { document, store, windowRequire } = monitor.panelWin;
32 const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
33 store.dispatch(Actions.batchEnable(false));
35 // Execute requests.
36 await performRequests(monitor, tab, 2);
38 info("Clicking stack-trace tab and waiting for stack-trace panel to open");
39 const waitForTab = waitForDOM(document, "#stack-trace-tab");
40 // Click on the first request
41 EventUtils.sendMouseEvent(
42 { type: "mousedown" },
43 document.querySelector(".request-list-item")
45 await waitForTab;
46 const waitForPanel = waitForDOM(
47 document,
48 "#stack-trace-panel .frame-link",
51 // Open the stack-trace tab for that request
52 document.getElementById("stack-trace-tab").click();
53 await waitForPanel;
55 const frameLinkNode = document.querySelector(".frame-link");
56 await checkClickOnNode(toolbox, frameLinkNode);
58 await teardown(monitor);
59 });
61 /**
62 * Helper function for testOpenInDebugger.
64 async function checkClickOnNode(toolbox, frameLinkNode) {
65 info("checking click on node location");
67 const url = frameLinkNode.getAttribute("data-url");
68 ok(url, `source url found ("${url}")`);
70 const line = frameLinkNode.getAttribute("data-line");
71 ok(line, `source line found ("${line}")`);
73 // Fire the click event
74 frameLinkNode.querySelector(".frame-link-source").click();
76 // Wait for the debugger to have fully processed the opened source
77 await toolbox.getPanelWhenReady("jsdebugger");
78 const dbg = createDebuggerContext(toolbox);
79 await waitForSelectedSource(dbg, url);