Option network websocket disable
parent
bfa5bc3fcb
commit
6cc9f5845f
|
@ -960,6 +960,11 @@ WebSocket::Constructor(const GlobalObject& aGlobal,
|
|||
const nsAString& aUrl,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
if (!PrefEnabled()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Sequence<nsString> protocols;
|
||||
return WebSocket::ConstructorCommon(aGlobal, aUrl, protocols, nullptr,
|
||||
EmptyCString(), aRv);
|
||||
|
@ -1483,6 +1488,11 @@ WebSocketImpl::Init(JSContext* aCx,
|
|||
AssertIsOnMainThread();
|
||||
MOZ_ASSERT(aPrincipal);
|
||||
|
||||
if (!WebSocket::PrefEnabled()) {
|
||||
aRv.Throw(NS_ERROR_DOM_SECURITY_ERR);
|
||||
return;
|
||||
}
|
||||
|
||||
mService = WebSocketEventService::GetOrCreate();
|
||||
|
||||
// We need to keep the implementation alive in case the init disconnects it
|
||||
|
@ -2054,6 +2064,11 @@ WebSocket::CreateAndDispatchCloseEvent(bool aWasClean,
|
|||
return DispatchDOMEvent(nullptr, event, nullptr, nullptr);
|
||||
}
|
||||
|
||||
bool
|
||||
WebSocket::PrefEnabled()
|
||||
{
|
||||
return Preferences::GetBool("network.websocket.enabled", true);
|
||||
}
|
||||
nsresult
|
||||
WebSocketImpl::ParseURL(const nsAString& aURL)
|
||||
{
|
||||
|
|
|
@ -63,7 +63,7 @@ public:
|
|||
public: // static helpers:
|
||||
|
||||
// Determine if preferences allow WebSocket
|
||||
static bool PrefEnabled(JSContext* aCx = nullptr, JSObject* aGlobal = nullptr);
|
||||
static bool PrefEnabled();
|
||||
|
||||
public: // WebIDL interface:
|
||||
|
||||
|
|
|
@ -1646,6 +1646,9 @@ pref("network.sts.max_time_for_events_between_two_polls", 100);
|
|||
pref("network.sts.max_time_for_pr_close_during_shutdown", 5000);
|
||||
// </http>
|
||||
|
||||
// <ws>: WebSocket
|
||||
pref("network.websocket.enabled", true);
|
||||
|
||||
// 2147483647 == PR_INT32_MAX == ~2 GB
|
||||
pref("network.websocket.max-message-size", 2147483647);
|
||||
|
||||
|
|
Loading…
Reference in New Issue