Skip to content

Commit acf12ca

Browse files
committed
fix: cookie banner silence console error logs
1 parent 7f6b144 commit acf12ca

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

toolkit/components/cookiebanners/CookieBannerParent.sys.mjs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,17 @@ export class CookieBannerParent extends JSWindowActorParent {
188188
mode = perDomainMode;
189189
}
190190
} catch (e) {
191-
// getPerSitePref could throw with NS_ERROR_NOT_AVAILABLE if the service
192-
// is disabled. We will fallback to global pref setting if any errors
193-
// occur.
194-
if (e.result == Cr.NS_ERROR_NOT_AVAILABLE) {
195-
console.error("The cookie banner handling service is not available");
196-
} else {
191+
// getDomainPref can throw in a few expected cases where we should
192+
// silently fall back to the global pref:
193+
// - NS_ERROR_NOT_AVAILABLE: service disabled.
194+
// - NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS: hosts like localhost, IPs,
195+
// or eTLDs without enough labels for a base domain.
196+
// - NS_ERROR_HOST_IS_IP_ADDRESS: IP literal hosts.
197+
if (
198+
e.result != Cr.NS_ERROR_NOT_AVAILABLE &&
199+
e.result != Cr.NS_ERROR_INSUFFICIENT_DOMAIN_LEVELS &&
200+
e.result != Cr.NS_ERROR_HOST_IS_IP_ADDRESS
201+
) {
197202
console.error("Fail on getting domain pref:", e);
198203
}
199204
}

0 commit comments

Comments
 (0)