Bug 1722153 - [devtools] Fix blank stacktrace panel when opening from a second location r=jdescottes

Differential Revision: https://phabricator.services.mozilla.com/D120819
This commit is contained in:
Hubert Boma Manilla 2021-07-26 13:07:55 +00:00
Родитель c4112332c9
Коммит 2c45a516e9
3 изменённых файлов: 72 добавлений и 1 удалений

Просмотреть файл

@ -235,6 +235,7 @@ skip-if = true #Bug 1667115
[browser_net_sort-02.js]
[browser_net_sort-reset.js]
[browser_net_sse-basic.js]
[browser_net_stacktraces-visibility.js]
[browser_net_statistics-01.js]
skip-if = true # Bug 1373558
[browser_net_statistics-02.js]

Просмотреть файл

@ -0,0 +1,70 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/**
* Tests that opening the stacktrace details panel in the netmonitor and console
* show the expected stacktraces.
*/
add_task(async function() {
const INITIATOR_URL = EXAMPLE_URL + "html_cause-test-page.html";
const FETCH_REQUEST =
"http://example.com/browser/devtools/client/netmonitor/test/fetch_request";
const { tab, monitor } = await initNetMonitor(INITIATOR_URL, {
requestCount: 1,
});
const { document, store, windowRequire } = monitor.panelWin;
const Actions = windowRequire("devtools/client/netmonitor/src/actions/index");
store.dispatch(Actions.batchEnable(false));
info("Starting test... ");
const wait = waitForNetworkEvents(monitor, 8);
tab.linkedBrowser.reload();
await wait;
const onStackTracesVisible = waitUntil(
() => document.querySelector("#stack-trace-panel .stack-trace .frame-link"),
"Wait for the stacktrace to be rendered"
);
// Select the fetch-request
EventUtils.sendMouseEvent(
{ type: "mousedown" },
document.querySelector(
`.request-list-item .requests-list-file[title="${FETCH_REQUEST}"]`
)
);
clickOnSidebarTab(document, "stack-trace");
await onStackTracesVisible;
// Switch to the webconsole.
const { hud } = await monitor.toolbox.selectTool("webconsole");
const fetchRequestUrlNode = hud.ui.outputNode.querySelector(
`.webconsole-output .cm-s-mozilla.message.network span[title="${FETCH_REQUEST}"]`
);
fetchRequestUrlNode.click();
const messageWrapper = fetchRequestUrlNode.closest(".message-body-wrapper");
await waitFor(
() => messageWrapper.querySelector(".network-info"),
"Wait for .network-info to be rendered"
);
// Select stacktrace details panel and check the content.
messageWrapper.querySelector("#stack-trace-tab").click();
await waitFor(
() => messageWrapper.querySelector("#stack-trace-panel .frame-link"),
"Wait for stacktrace to be rendered"
);
return teardown(monitor);
});

Просмотреть файл

@ -55,6 +55,7 @@ class NetworkEventStackTracesWatcher {
* The target actor from which we should stop observing the strack traces
*/
destroy(targetActor) {
this.stacktraces.clear();
Services.obs.removeObserver(this, "http-on-opening-request");
Services.obs.removeObserver(this, "document-on-opening-request");
Services.obs.removeObserver(this, "network-monitor-alternate-stack");
@ -194,7 +195,6 @@ class NetworkEventStackTracesWatcher {
let stacktrace = [];
if (this.stacktraces.has(id)) {
stacktrace = this.stacktraces.get(id);
this.stacktraces.delete(id);
}
return stacktrace;
}