Bug 1838555 - [devtools] Ignore requests with NS_BINDING_ABORTED, since they emmited from the cache r=devtools-reviewers,ochameau

Differential Revision: https://phabricator.services.mozilla.com/D181036
This commit is contained in:
Hubert Boma Manilla 2023-07-04 08:43:36 +00:00
parent 5a74fbcd58
commit b7646d156b
4 changed files with 34 additions and 5 deletions

View File

@ -90,6 +90,23 @@ add_task(async function () {
},
];
// Cancel the 200 cached request, so that the test can also assert
// that the NS_BINDING_ABORTED status is never displayed for cached requests.
const observer = {
QueryInterface: ChromeUtils.generateQI(["nsIObserver"]),
observe(subject, topic, data) {
subject = subject.QueryInterface(Ci.nsIHttpChannel);
if (subject.URI.spec == STATUS_CODES_SJS + "?sts=ok&cached") {
subject.cancel(Cr.NS_BINDING_ABORTED);
Services.obs.removeObserver(
observer,
"http-on-examine-cached-response"
);
}
},
};
Services.obs.addObserver(observer, "http-on-examine-cached-response");
info("Performing requests #1...");
await performRequestsAndWait();

View File

@ -335,7 +335,7 @@ export class NetworkObserver {
} else {
// Handles any early blockings e.g by Web Extensions or by CORS
const { blockingExtension, blockedReason } =
lazy.NetworkUtils.getBlockedReason(channel);
lazy.NetworkUtils.getBlockedReason(channel, httpActivity.fromCache);
this.#createNetworkEvent(subject, { blockedReason, blockingExtension });
}
}
@ -440,7 +440,10 @@ export class NetworkObserver {
serverTimings
);
} else if (topic === "http-on-failed-opening-request") {
const { blockedReason } = lazy.NetworkUtils.getBlockedReason(channel);
const { blockedReason } = lazy.NetworkUtils.getBlockedReason(
channel,
httpActivity.fromCache
);
this.#createNetworkEvent(channel, { blockedReason });
}

View File

@ -532,7 +532,10 @@ export class NetworkResponseListener {
// Check any errors or blocking scenarios which happen late in the cycle
// e.g If a host is not found (NS_ERROR_UNKNOWN_HOST) or CORS blocking.
const { blockingExtension, blockedReason } =
lazy.NetworkUtils.getBlockedReason(this.#httpActivity.channel);
lazy.NetworkUtils.getBlockedReason(
this.#httpActivity.channel,
this.#httpActivity.fromCache
);
this.#httpActivity.owner.addResponseContent(response, {
discardResponseBody: this.#httpActivity.discardResponseBody,

View File

@ -605,7 +605,7 @@ function legacyMatchRequest(channel, filters) {
return false;
}
function getBlockedReason(channel) {
function getBlockedReason(channel, fromCache = false) {
let blockingExtension, blockedReason;
const { status } = channel;
@ -627,7 +627,7 @@ function getBlockedReason(channel) {
// usually the requests (with these errors) might be displayed with various
// other status codes.
const ignoreList = [
// This is emited when the request is already in the cache.
// These are emited when the request is already in the cache.
"NS_ERROR_PARSED_DATA_CACHED",
// This is emited when there is some issues around images e.g When the img.src
// links to a non existent url. This is typically shown as a 404 request.
@ -638,6 +638,12 @@ function getBlockedReason(channel) {
"NS_ERROR_ABORT",
];
// NS_BINDING_ABORTED are emmited when request are abruptly halted, these are valid and should not be ignored.
// They can also be emmited for requests already cache which have the `cached` status, these should be ignored.
if (fromCache) {
ignoreList.push("NS_BINDING_ABORTED");
}
// If the request has not failed or is not blocked by a web extension, check for
// any errors not on the ignore list. e.g When a host is not found (NS_ERROR_UNKNOWN_HOST).
if (