Bug 1819279 - [devtools] Switch to a block list of known errors instead of an ignore list r=jdescottes

This patch switches from an ignore list of errors to a block list of the errors
we clearly want to block. We are likely going to regress a lot by missing errors from the ignore list
which shouldn't be blocked as revealed by this BUG. Instead let just block the errors we know about and
let other erros through as most of them are shown with error codes and do not need to be blocked.

Differential Revision: https://phabricator.services.mozilla.com/D171352
This commit is contained in:
Hubert Boma Manilla 2023-03-01 18:58:18 +00:00
parent f81ae9ef75
commit 1660f43787
2 changed files with 8 additions and 11 deletions

View File

@ -33,10 +33,12 @@ add_task(async function() {
1,
"The beacon should be recorded."
);
const request = getSortedRequests(store.getState())[0];
is(request.method, "POST", "The method is correct.");
ok(request.url.endsWith("beacon_request"), "The URL is correct.");
is(request.status, "404", "The status is correct.");
is(request.blockedReason, 0, "The request is not blocked");
return teardown(monitor);
});

View File

@ -483,22 +483,17 @@ function getBlockedReason(channel) {
// "cancelledByExtension" doesn't have to be available.
}
const ignoreList = [
// This is emmited when the request is already in the cache.
"NS_ERROR_PARSED_DATA_CACHED",
// This is emmited when there is some issues around imgages e.g When the img.src
// links to a non existent url. This is typically shown as a 404 request.
"NS_IMAGELIB_ERROR_FAILURE",
// This is emmited when there is a redirect. They are shown as 301 requests.
"NS_BINDING_REDIRECTED",
const blockList = [
// This is emitted when a host is not found
"NS_ERROR_UNKNOWN_HOST",
];
// 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 the request is not already blocked (by a web extension) but has a failed status, check if
// the error matches any on the block list.
if (
blockedReason == 0 &&
!Components.isSuccessCode(status) &&
!ignoreList.includes(ChromeUtils.getXPCOMErrorName(status))
blockList.includes(ChromeUtils.getXPCOMErrorName(status))
) {
blockedReason = ChromeUtils.getXPCOMErrorName(status);
}