зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1777457 - [devtools] Update netmonitor test helpers when resources are cleared r=nchevobbe
There are potentially several sources for the recent netmonitor intermittent failures. One of them is that we have several helpers to "wait" for requests, and they have a logic so that when they spot a request, they will wait for the request to be completed. However if a navigation occurs in the middle, the corresponding resource will be cleared and the updates will not be processed. So here we emit a test-only event when the netmonitor attempts to clear resources, so that test helpers can update accordingly. Differential Revision: https://phabricator.services.mozilla.com/D152726
This commit is contained in:
Родитель
dc2ab68604
Коммит
6173cfaf92
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче