Bug 1535298 - Capture and ignore the exception for not having a host from a principal URI; r=janv,johannh

Protocols, likes about:, moz-extension, ... etc, don't have a host. Thus, an
exception will be returned if they are accessed. To avoid from that, this patch
catches this bug a try-catch.

Differential Revision: https://phabricator.services.mozilla.com/D29821

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Tom Tung 2019-05-14 16:49:03 +00:00
parent 476bb2dc86
commit 5a873324c6

View File

@ -409,8 +409,17 @@ const QuotaCleaner = {
let promises = [];
for (let item of aRequest.result) {
let principal = Services.scriptSecurityManager.createCodebasePrincipalFromOrigin(item.origin);
if (Services.eTLD.hasRootDomain(principal.URI.host, aHost)) {
let principal = Services.scriptSecurityManager
.createCodebasePrincipalFromOrigin(item.origin);
let host;
try {
host = principal.URI.host;
} catch (e) {
// There is no host for the given principal.
continue;
}
if (Services.eTLD.hasRootDomain(host, aHost)) {
promises.push(new Promise((aResolve, aReject) => {
let clearRequest = Services.qms.clearStoragesForPrincipal(principal, null, "ls");
clearRequest.callback = () => {