From 5a873324c6733bf89ca9436e6bf3bb4503c5a817 Mon Sep 17 00:00:00 2001 From: Tom Tung Date: Tue, 14 May 2019 16:49:03 +0000 Subject: [PATCH] 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 --- toolkit/components/cleardata/ClearDataService.jsm | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/toolkit/components/cleardata/ClearDataService.jsm b/toolkit/components/cleardata/ClearDataService.jsm index 1eaaf528df18..6315d036b034 100644 --- a/toolkit/components/cleardata/ClearDataService.jsm +++ b/toolkit/components/cleardata/ClearDataService.jsm @@ -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 = () => {