Bug 1939538 - teach ContentPrincipal::GetSpecialBaseDomain not to bother for chrome/resource/ui URLs, r=ckerschb
Differential Revision: https://phabricator.services.mozilla.com/D233017
This commit is contained in:
@@ -397,6 +397,15 @@ static nsresult GetSpecialBaseDomain(const nsCOMPtr<nsIURI>& aURI,
|
||||
return aURI->GetSpec(aBaseDomain);
|
||||
}
|
||||
|
||||
// For local resources we can't get a meaningful base domain.
|
||||
bool isUIResource = false;
|
||||
if (NS_SUCCEEDED(NS_URIChainHasFlags(
|
||||
aURI, nsIProtocolHandler::URI_IS_UI_RESOURCE, &isUIResource)) &&
|
||||
isUIResource) {
|
||||
*aHandled = true;
|
||||
return aURI->GetPrePath(aBaseDomain);
|
||||
}
|
||||
|
||||
if (aURI->SchemeIs("indexeddb")) {
|
||||
*aHandled = true;
|
||||
return aURI->GetSpec(aBaseDomain);
|
||||
|
||||
@@ -182,3 +182,8 @@ Assert.equal(
|
||||
ipv6Principal.siteOriginNoSuffix,
|
||||
"https://[2001:db8::ff00:42:8329]"
|
||||
);
|
||||
|
||||
// Checks for non-http URIs not using the TLD service.
|
||||
let resourceURI = Services.io.newURI("resource://test.example.com/test");
|
||||
let resourcePrincipal = scriptSecMan.createContentPrincipal(resourceURI, {});
|
||||
Assert.equal(resourcePrincipal.siteOrigin, "resource://test.example.com");
|
||||
|
||||
Reference in New Issue
Block a user