Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit 8658346

Browse files
committed
Backed out changeset 74162d71ef4d (bug 1597704) for failing at browser_insecurePasswordConsoleWarning.js on a CLOSED TREE.
1 parent 75d85af commit 8658346

15 files changed

Lines changed: 103 additions & 60 deletions

caps/BasePrincipal.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
#include "mozilla/dom/BlobURLProtocolHandler.h"
2525
#include "mozilla/dom/ChromeUtils.h"
2626
#include "mozilla/dom/ToJSValue.h"
27-
#include "mozilla/dom/nsMixedContentBlocker.h"
2827

2928
#include "json/json.h"
3029
#include "nsSerializationHelper.h"
@@ -471,21 +470,6 @@ BasePrincipal::IsURIInPrefList(const char* aPref, bool* aResult) {
471470
return NS_OK;
472471
}
473472

474-
NS_IMETHODIMP
475-
BasePrincipal::GetIsOriginPotentiallyTrustworthy(bool* aResult) {
476-
MOZ_ASSERT(NS_IsMainThread());
477-
*aResult = false;
478-
479-
nsCOMPtr<nsIURI> uri;
480-
nsresult rv = GetURI(getter_AddRefs(uri));
481-
if (NS_FAILED(rv) || !uri) {
482-
return NS_OK;
483-
}
484-
485-
*aResult = nsMixedContentBlocker::IsPotentiallyTrustworthyOrigin(uri);
486-
return NS_OK;
487-
}
488-
489473
NS_IMETHODIMP
490474
BasePrincipal::GetAboutModuleFlags(uint32_t* flags) {
491475
*flags = 0;

caps/BasePrincipal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ class BasePrincipal : public nsJSPrincipals {
131131
NS_IMETHOD GetSiteOrigin(nsACString& aOrigin) override;
132132
NS_IMETHOD IsThirdPartyURI(nsIURI* uri, bool* aRes) override;
133133
NS_IMETHOD IsThirdPartyPrincipal(nsIPrincipal* uri, bool* aRes) override;
134-
NS_IMETHOD GetIsOriginPotentiallyTrustworthy(bool* aResult) override;
135134

136135
nsresult ToJSON(nsACString& aJSON);
137136
static already_AddRefed<BasePrincipal> FromJSON(const nsACString& aJSON);

caps/NullPrincipal.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ NullPrincipal::GetURI(nsIURI** aURI) {
141141
uri.forget(aURI);
142142
return NS_OK;
143143
}
144-
NS_IMETHODIMP
145-
NullPrincipal::GetIsOriginPotentiallyTrustworthy(bool* aResult) {
146-
*aResult = false;
147-
return NS_OK;
148-
}
149144

150145
NS_IMETHODIMP
151146
NullPrincipal::GetDomain(nsIURI** aDomain) {

caps/NullPrincipal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ class NullPrincipal final : public BasePrincipal {
5151
NS_IMETHOD QueryInterface(REFNSIID aIID, void** aInstancePtr) override;
5252
uint32_t GetHashValue() override;
5353
NS_IMETHOD GetURI(nsIURI** aURI) override;
54-
NS_IMETHOD GetIsOriginPotentiallyTrustworthy(bool* aResult) override;
5554
NS_IMETHOD GetDomain(nsIURI** aDomain) override;
5655
NS_IMETHOD SetDomain(nsIURI* aDomain) override;
5756
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;

caps/SystemPrincipal.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,6 @@ SystemPrincipal::GetURI(nsIURI** aURI) {
5151
return NS_OK;
5252
}
5353

54-
NS_IMETHODIMP
55-
SystemPrincipal::GetIsOriginPotentiallyTrustworthy(bool* aResult) {
56-
*aResult = true;
57-
return NS_OK;
58-
}
59-
6054
NS_IMETHODIMP
6155
SystemPrincipal::GetDomain(nsIURI** aDomain) {
6256
*aDomain = nullptr;

caps/SystemPrincipal.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class SystemPrincipal final : public BasePrincipal {
4444
NS_IMETHOD SetDomain(nsIURI* aDomain) override;
4545
NS_IMETHOD GetBaseDomain(nsACString& aBaseDomain) override;
4646
NS_IMETHOD GetAddonId(nsAString& aAddonId) override;
47-
NS_IMETHOD GetIsOriginPotentiallyTrustworthy(bool* aResult) override;
4847

4948
virtual nsresult GetScriptLocation(nsACString& aStr) override;
5049

caps/nsIPrincipal.idl

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -231,18 +231,6 @@ interface nsIPrincipal : nsISerializable
231231
*/
232232
bool IsURIInPrefList(in string pref);
233233

234-
/**
235-
* Implementation of
236-
* https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
237-
*
238-
* The value returned by this method feeds into the the Secure Context
239-
* algorithm that determins the value of Window.isSecureContext and
240-
* WorkerGlobalScope.isSecureContext.
241-
*
242-
* This method returns false instead of throwing upon errors.
243-
*/
244-
readonly attribute bool IsOriginPotentiallyTrustworthy;
245-
246234
/**
247235
* Returns the Flags of the Principals
248236
* associated AboutModule, in case there is one.

dom/base/nsContentUtils.cpp

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8891,9 +8891,18 @@ bool nsContentUtils::HttpsStateIsModern(Document* aDocument) {
88918891

88928892
MOZ_ASSERT(principal->GetIsContentPrincipal());
88938893

8894-
bool isTrustworthyOrigin = false;
8895-
principal->GetIsOriginPotentiallyTrustworthy(&isTrustworthyOrigin);
8896-
return isTrustworthyOrigin;
8894+
nsCOMPtr<nsIContentSecurityManager> csm =
8895+
do_GetService(NS_CONTENTSECURITYMANAGER_CONTRACTID);
8896+
NS_WARNING_ASSERTION(csm, "csm is null");
8897+
if (csm) {
8898+
bool isTrustworthyOrigin = false;
8899+
csm->IsOriginPotentiallyTrustworthy(principal, &isTrustworthyOrigin);
8900+
if (isTrustworthyOrigin) {
8901+
return true;
8902+
}
8903+
}
8904+
8905+
return false;
88978906
}
88988907

88998908
/* static */
@@ -8923,9 +8932,15 @@ bool nsContentUtils::ComputeIsSecureContext(nsIChannel* aChannel) {
89238932
return false;
89248933
}
89258934

8926-
bool isTrustworthyOrigin = false;
8927-
principal->GetIsOriginPotentiallyTrustworthy(&isTrustworthyOrigin);
8928-
return isTrustworthyOrigin;
8935+
nsCOMPtr<nsIContentSecurityManager> csm =
8936+
do_GetService(NS_CONTENTSECURITYMANAGER_CONTRACTID);
8937+
NS_WARNING_ASSERTION(csm, "csm is null");
8938+
if (csm) {
8939+
bool isTrustworthyOrigin = false;
8940+
csm->IsOriginPotentiallyTrustworthy(principal, &isTrustworthyOrigin);
8941+
return isTrustworthyOrigin;
8942+
}
8943+
return true;
89298944
}
89308945

89318946
/* static */

dom/base/nsGlobalWindowOuter.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1693,9 +1693,18 @@ bool nsGlobalWindowOuter::ComputeIsSecureContext(Document* aDocument,
16931693
}
16941694
}
16951695

1696-
bool isTrustworthyOrigin = false;
1697-
principal->GetIsOriginPotentiallyTrustworthy(&isTrustworthyOrigin);
1698-
return isTrustworthyOrigin;
1696+
nsCOMPtr<nsIContentSecurityManager> csm =
1697+
do_GetService(NS_CONTENTSECURITYMANAGER_CONTRACTID);
1698+
NS_WARNING_ASSERTION(csm, "csm is null");
1699+
if (csm) {
1700+
bool isTrustworthyOrigin = false;
1701+
csm->IsOriginPotentiallyTrustworthy(principal, &isTrustworthyOrigin);
1702+
if (isTrustworthyOrigin) {
1703+
return true;
1704+
}
1705+
}
1706+
1707+
return false;
16991708
}
17001709

17011710
// We need certain special behavior for remote XUL whitelisted domains, but we

dom/interfaces/security/nsIContentSecurityManager.idl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,15 @@ interface nsIContentSecurityManager : nsISupports
4242
nsIStreamListener performSecurityCheck(in nsIChannel aChannel,
4343
in nsIStreamListener aStreamListener);
4444

45+
/**
46+
* Implementation of
47+
* https://w3c.github.io/webappsec-secure-contexts/#is-origin-trustworthy
48+
*
49+
* The value returned by this method feeds into the the Secure Context
50+
* algorithm that determins the value of Window.isSecureContext and
51+
* WorkerGlobalScope.isSecureContext.
52+
*
53+
* This method returns false instead of throwing upon errors.
54+
*/
55+
boolean isOriginPotentiallyTrustworthy(in nsIPrincipal aPrincipal);
4556
};

0 commit comments

Comments
 (0)