; let principals = await new Promise(resolve => { Services.qms.listOrigins().callback = request => { progress.step = "principals-quota-manager-listOrigins"; if (request.resultCode != Cr.NS_OK) { // We are probably shutting down. We don't want to propagate the // error, rejecting the promise. resolve([]); return; } let principalsMap = new Map(); for (const origin of request.result) { let principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin( origin ); if (PrincipalsCollector.isSupportedPrincipal(principal)) { principalsMap.set(principal.origin, principal); } } progress.step = "principals-quota-manager-completed"; resolve(principalsMap); }; }).catch(ex => { console.error("QuotaManagerService promise failed: ", ex); return []; }); progress.step = "principals-service-workers"; let serviceWorkers = lazy.serviceWorkerManager.getAllRegistrations(); for (let i = 0; i < serviceWorkers.length; i++) { let sw = serviceWorkers.queryElementAt( i, Ci.nsIServiceWorkerRegistrationInfo ); // We don't need to check the scheme. SW are just exposed to http/https URLs. principals.set(sw.principal.origin, sw.principal); } // Let's take the list of unique hosts+OA from cookies. progress.step = "principals-cookies"; let cookies = Services.cookies.cookies; let hosts = new Set(); for (let cookie of cookies) { hosts.add( cookie.rawHost + ChromeUtils.originAttributesToSuffix(cookie.originAttributes) ); } progress.step = "principals-host-cookie"; hosts.forEach(host => { // Cookies and permissions are handled by origin/host. Doesn't matter if we // use http: or https: schema here. let principal; try { principal = Services.scriptSecurityManager.createContentPrincipalFromOrigin( "https://" + host ); } catch (e) { log( `ERROR: Could not create content principal for host '${host}' ${e.message}` ); } if (principal) { principals.set(principal.origin, principal); } }); principals = Array.from(principals.values()); progress.step = "total-principals:" + principals.length; return principals; } } PK