Bug 1535298 - Capture and ignore the exception for not having a host from a principal URI; r=janv,johannh
authorTom Tung <shes050117@gmail.com>
Tue, 14 May 2019 16:49:03 +0000
changeset 532627 9437ce7f56f17a5f38e3c64f165005845a50fc69
parent 532626 fd66f241a8bda8a748dfe741802a4fecf7040c10
child 532628 e1437ba34a4afff6cee82968503144f15e9e1949
push id11270
push userrgurzau@mozilla.com
push dateWed, 15 May 2019 15:07:19 +0000
treeherdermozilla-beta@571bc76da583 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjanv, johannh
bugs1535298
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
toolkit/components/cleardata/ClearDataService.jsm
--- a/toolkit/components/cleardata/ClearDataService.jsm
+++ b/toolkit/components/cleardata/ClearDataService.jsm
@@ -404,18 +404,27 @@ const QuotaCleaner = {
             Services.qms.listInitializedOrigins(aRequest => {
               if (aRequest.resultCode != Cr.NS_OK) {
                 aReject({message: "Delete by host failed"});
                 return;
               }
 
               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 = () => {
                       if (clearRequest.resultCode == Cr.NS_OK) {
                         aResolve();
                       } else {
                         aReject({message: "Delete by host failed"});
                       }