Merge remote-tracking branch 'origin/tracking' into custom

This commit is contained in:
roytam1 2023-12-21 10:19:16 +08:00
commit a907bc3c17
10 changed files with 85 additions and 36 deletions

View file

@ -2548,16 +2548,22 @@ WebSocket::Close(const Optional<uint16_t>& aCode,
return;
}
// If the webSocket is not closed we MUST have a mImpl.
MOZ_ASSERT(mImpl);
// If we don't have mImpl, we are in a shutting down worker where we are still
// in CONNECTING state, but already disconnected internally.
if (!mImpl) {
MOZ_ASSERT(readyState == CONNECTING);
SetReadyState(CLOSING);
return;
}
RefPtr<WebSocketImpl> impl = mImpl;
if (readyState == CONNECTING) {
mImpl->FailConnection(closeCode, closeReason);
impl->FailConnection(closeCode, closeReason);
return;
}
MOZ_ASSERT(readyState == OPEN);
mImpl->CloseConnection(closeCode, closeReason);
impl->CloseConnection(closeCode, closeReason);
}
//-----------------------------------------------------------------------------

View file

@ -827,6 +827,16 @@ nsCSPContext::SendReports(nsISupports* aBlockedContentSource,
{
NS_ENSURE_ARG_MAX(aViolatedPolicyIndex, mPolicies.Length() - 1);
if (!CSPService::sCSPReportingEnabled) {
// Reporting is pref-disabled. Don't do any actual work and return success.
nsContentUtils::ReportToConsoleNonLocalized(
NS_LITERAL_STRING("CSP violation report not sent: reports have been disabled contrary to spec."),
nsIScriptError::warningFlag,
NS_LITERAL_CSTRING("Content Security Policy"),
nullptr);
return NS_OK;
}
dom::CSPReport report;
nsresult rv;

View file

@ -25,12 +25,15 @@ using namespace mozilla;
/* Keeps track of whether or not CSP is enabled */
bool CSPService::sCSPEnabled = true;
/* Keeps track of whether or not CSP reporting is enabled */
bool CSPService::sCSPReportingEnabled = true;
static LazyLogModule gCspPRLog("CSP");
CSPService::CSPService()
{
Preferences::AddBoolVarCache(&sCSPEnabled, "security.csp.enable");
Preferences::AddBoolVarCache(&sCSPReportingEnabled, "security.csp.reporting.enabled");
}
CSPService::~CSPService()

View file

@ -14,8 +14,8 @@
#define CSPSERVICE_CONTRACTID "@mozilla.org/cspservice;1"
#define CSPSERVICE_CID \
{ 0x8d2f40b2, 0x4875, 0x4c95, \
{ 0x97, 0xd9, 0x3f, 0x7d, 0xca, 0x2c, 0xb4, 0x60 } }
{ 0x83d284d6, 0xf280, 0x48ae, \
{ 0xa5, 0x6b, 0x0f, 0x28, 0x11, 0x29, 0x83, 0x1b } }
class CSPService : public nsIContentPolicy,
public nsIChannelEventSink
{
@ -26,6 +26,7 @@ public:
CSPService();
static bool sCSPEnabled;
static bool sCSPReportingEnabled;
protected:
virtual ~CSPService();