Skip to content

Commit

Permalink
Backed out changeset ae75c4984b1b (bug 1620292) for causing bustages …
Browse files Browse the repository at this point in the history
…in BasePrincipal.h CLOSED TREE
  • Loading branch information
nerli1 committed Mar 6, 2020
1 parent 69d07ec commit cae18cf
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 34 deletions.
15 changes: 0 additions & 15 deletions caps/BasePrincipal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,21 +972,6 @@ BasePrincipal::GetLocalStorageQuotaKey(nsACString& aKey) {
return NS_OK;
}

NS_IMETHODIMP
BasePrincipal::GetIsScriptAllowedByPolicy(bool* aIsScriptAllowedByPolicy) {
*aIsScriptAllowedByPolicy = false;
nsCOMPtr<nsIURI> prinURI;
nsresult rv = GetURI(getter_AddRefs(prinURI));
if (NS_FAILED(rv) || !prinURI) {
return NS_OK;
}
nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
if (!ssm) {
return NS_ERROR_UNEXPECTED;
}
return ssm->PolicyAllowsScript(prinURI, aIsScriptAllowedByPolicy);
}

bool SiteIdentifier::Equals(const SiteIdentifier& aOther) const {
MOZ_ASSERT(IsInitialized());
MOZ_ASSERT(aOther.IsInitialized());
Expand Down
1 change: 0 additions & 1 deletion caps/BasePrincipal.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ class BasePrincipal : public nsJSPrincipals {
bool* aRes) override;
NS_IMETHOD CreateReferrerInfo(mozilla::dom::ReferrerPolicy aReferrerPolicy,
nsIReferrerInfo** _retval) override;
NS_IMETHOD GetIsScriptAllowedByPolicy(bool* aIsScriptAllowedByPolicy);
nsresult ToJSON(nsACString& aJSON);
static already_AddRefed<BasePrincipal> FromJSON(const nsACString& aJSON);
// Method populates a passed Json::Value with serializable fields
Expand Down
6 changes: 0 additions & 6 deletions caps/nsIPrincipal.idl
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,6 @@ interface nsIPrincipal : nsISerializable
*/
[infallible] readonly attribute boolean isOnion;

/*
* Returns true if the Domain Policy allows js execution
* for the Principals URI
*/
readonly attribute boolean isScriptAllowedByPolicy;

/**
* Returns if the principal is for an IP address.
*/
Expand Down
26 changes: 14 additions & 12 deletions js/xpconnect/src/XPCJSRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,21 +455,23 @@ Scriptability::Scriptability(JS::Realm* realm)
mDocShellAllowsScript(true),
mScriptBlockedByPolicy(false) {
nsIPrincipal* prin = nsJSPrincipals::get(JS::GetRealmPrincipals(realm));

mImmuneToScriptPolicy = PrincipalImmuneToScriptPolicy(prin);
if (mImmuneToScriptPolicy) {
return;
}

// If we're not immune, we should have a real principal with a URI.
// Check the principal against the new-style domain policy.
bool policyAllows;
nsresult rv = prin->GetIsScriptAllowedByPolicy(&policyAllows);
if (NS_SUCCEEDED(rv)) {
mScriptBlockedByPolicy = !policyAllows;
return;
// Check the URI against the new-style domain policy.
if (!mImmuneToScriptPolicy) {
nsCOMPtr<nsIURI> codebase;
nsresult rv = prin->GetURI(getter_AddRefs(codebase));
bool policyAllows;
if (NS_SUCCEEDED(rv) && codebase &&
NS_SUCCEEDED(nsXPConnect::SecurityManager()->PolicyAllowsScript(
codebase, &policyAllows))) {
mScriptBlockedByPolicy = !policyAllows;
} else {
// Something went wrong - be safe and block script.
mScriptBlockedByPolicy = true;
}
}
// Something went wrong - be safe and block script.
mScriptBlockedByPolicy = true;
}

bool Scriptability::Allowed() {
Expand Down

0 comments on commit cae18cf

Please sign in to comment.