diff --git a/devtools/client/netmonitor/src/connector/index.js b/devtools/client/netmonitor/src/connector/index.js index 23cdfae95e21..4ee341704875 100644 --- a/devtools/client/netmonitor/src/connector/index.js +++ b/devtools/client/netmonitor/src/connector/index.js @@ -162,6 +162,7 @@ class Connector { this.dataProvider.destroy(); this.toolbox.resourceCommand.clearResources(Connector.NETWORK_RESOURCES); + this.emitForTests("clear-network-resources"); // Disable the realted network logs in the webconsole this.toolbox.disableAllConsoleNetworkLogs(); diff --git a/devtools/client/netmonitor/test/head.js b/devtools/client/netmonitor/test/head.js index 9ea8d7de56b0..ccc1eaeb725b 100644 --- a/devtools/client/netmonitor/test/head.js +++ b/devtools/client/netmonitor/test/head.js @@ -287,6 +287,10 @@ function startNetworkEventUpdateObserver(panelWin) { finishedQueue[key] = finishedQueue[key] ? finishedQueue[key] - 1 : -1; }) ); + + panelWin.api.on("clear-network-resources", () => { + finishedQueue = {}; + }); } async function waitForAllNetworkUpdateEvents() { @@ -436,6 +440,15 @@ function waitForNetworkEvents(monitor, getRequests, options = {}) { eventTimings++; maybeResolve(EVENTS.RECEIVED_EVENT_TIMINGS, response.from); } + + function onClearNetworkResources() { + // Reset all counters. + networkEvent = 0; + nonBlockedNetworkEvent = 0; + payloadReady = 0; + eventTimings = 0; + } + function maybeResolve(event, actor) { const { document } = monitor.panelWin; // Wait until networkEvent, payloadReady and event timings finish for each request. @@ -483,6 +496,7 @@ function waitForNetworkEvents(monitor, getRequests, options = {}) { panel.api.off(TEST_EVENTS.NETWORK_EVENT, onNetworkEvent); panel.api.off(EVENTS.PAYLOAD_READY, onPayloadReady); panel.api.off(EVENTS.RECEIVED_EVENT_TIMINGS, onEventTimings); + panel.api.off("clear-network-resources", onClearNetworkResources); executeSoon(resolve); } } @@ -490,6 +504,7 @@ function waitForNetworkEvents(monitor, getRequests, options = {}) { panel.api.on(TEST_EVENTS.NETWORK_EVENT, onNetworkEvent); panel.api.on(EVENTS.PAYLOAD_READY, onPayloadReady); panel.api.on(EVENTS.RECEIVED_EVENT_TIMINGS, onEventTimings); + panel.api.on("clear-network-resources", onClearNetworkResources); }); }