Backed out 22 changesets (bug 1419771) for build bustage build/src/dom/base/FuzzingFunctions.cpp on a CLOSED TREE

Backed out changeset b2b7b46c8ad0 (bug 1419771)
Backed out changeset 0206657d2ea2 (bug 1419771)
Backed out changeset f0f4b98a07b6 (bug 1419771)
Backed out changeset 4b52904694f4 (bug 1419771)
Backed out changeset 9f40cc12d6c6 (bug 1419771)
Backed out changeset f500a61f564c (bug 1419771)
Backed out changeset 0bd9d964df8a (bug 1419771)
Backed out changeset 1397a6bbb446 (bug 1419771)
Backed out changeset 7e77a00fa8b5 (bug 1419771)
Backed out changeset 5f6df771459a (bug 1419771)
Backed out changeset 7624e70b2965 (bug 1419771)
Backed out changeset b9d674bdc723 (bug 1419771)
Backed out changeset 5e44aeda4196 (bug 1419771)
Backed out changeset 601b49f51b41 (bug 1419771)
Backed out changeset d12dc5557982 (bug 1419771)
Backed out changeset 6c863ab2e986 (bug 1419771)
Backed out changeset 0866d79873ab (bug 1419771)
Backed out changeset 8ecc91474621 (bug 1419771)
Backed out changeset 19b14deed8fe (bug 1419771)
Backed out changeset 000c8d5fbc03 (bug 1419771)
Backed out changeset 2e263a2519c5 (bug 1419771)
Backed out changeset b628d9298be8 (bug 1419771)
This commit is contained in:
Gurzau Raul 2017-12-13 23:41:49 +02:00
parent 9a740413a5
commit 321347c110
88 changed files with 670 additions and 365 deletions

View File

@ -1,81 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "DOMPreferences.h"
#include "mozilla/Atomics.h"
#include "mozilla/Preferences.h"
namespace mozilla {
namespace dom {
void
DOMPreferences::Initialize()
{
MOZ_ASSERT(NS_IsMainThread());
// Let's cache all the values on the main-thread.
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
DOMPreferences::DumpEnabled();
#endif
#define PREF(name, pref) DOMPreferences::name();
#include "DOMPreferencesInternal.h"
#undef PREF
}
#define PREF(name, pref) \
/* static */ bool \
DOMPreferences::name() \
{ \
static bool initialized = false; \
static Atomic<bool> cachedValue; \
if (!initialized) { \
initialized = true; \
Preferences::AddAtomicBoolVarCache(&cachedValue, \
pref, false); \
} \
return cachedValue; \
}
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
PREF(DumpEnabled, "browser.dom.window.dump.enabled")
#else
/* static */ bool
DOMPreferences::DumpEnabled()
{
return true;
}
#endif
#include "DOMPreferencesInternal.h"
#undef PREF
#define PREF_WEBIDL(name) \
/* static */ bool \
DOMPreferences::name(JSContext* aCx, JSObject* aObj) \
{ \
return DOMPreferences::name(); \
}
PREF_WEBIDL(ImageBitmapExtensionsEnabled)
PREF_WEBIDL(DOMCachesEnabled)
PREF_WEBIDL(NotificationEnabledInServiceWorkers)
PREF_WEBIDL(NotificationRIEnabled)
PREF_WEBIDL(ServiceWorkersEnabled)
PREF_WEBIDL(StorageManagerEnabled)
PREF_WEBIDL(PromiseRejectionEventsEnabled)
PREF_WEBIDL(PushEnabled)
PREF_WEBIDL(StreamsEnabled)
PREF_WEBIDL(RequestContextEnabled)
PREF_WEBIDL(OffscreenCanvasEnabled)
PREF_WEBIDL(WebkitBlinkDirectoryPickerEnabled)
PREF_WEBIDL(NetworkInformationEnabled)
PREF_WEBIDL(FetchObserverEnabled)
#undef PREF_WEBIDL
} // dom namespace
} // mozilla namespace

View File

@ -1,104 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_dom_DOMPreferences_h
#define mozilla_dom_DOMPreferences_h
namespace mozilla {
namespace dom {
class DOMPreferences final
{
public:
// This must be called on the main-thread.
static void Initialize();
// Returns true if the browser.dom.window.dump.enabled pref is set.
static bool DumpEnabled();
// Returns true if the canvas.imagebitmap_extensions.enabled pref is set.
static bool ImageBitmapExtensionsEnabled();
static bool ImageBitmapExtensionsEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.caches.enabled pref is set.
static bool DOMCachesEnabled();
static bool DOMCachesEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.caches.testing.enabled pref is set.
static bool DOMCachesTestingEnabled();
// Returns true if the dom.performance.enable_user_timing_logging pref is set.
static bool PerformanceLoggingEnabled();
// Returns true if the dom.webnotifications.enabled pref is set.
// Note that you should use NotificationEnabledInServiceWorkers if you need to
// enable Notification API for ServiceWorkers
static bool NotificationEnabled();
// Returns true if the dom.webnotifications.serviceworker.enabled pref is set.
static bool NotificationEnabledInServiceWorkers();
static bool NotificationEnabledInServiceWorkers(JSContext* aCx,
JSObject* aObj);
// Returns true if the dom.webnotifications.requireinteraction.enabled pref is
// set.
static bool NotificationRIEnabled();
static bool NotificationRIEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.serviceWorkers.enabled pref is set.
static bool ServiceWorkersEnabled();
static bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.serviceWorkers.testing.enabled pref is set.
static bool ServiceWorkersTestingEnabled();
// Returns true if the dom.storageManager.enabled pref is set.
static bool StorageManagerEnabled();
static bool StorageManagerEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.promise_rejection_events.enabled pref is set.
static bool PromiseRejectionEventsEnabled();
static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.push.enabled pref is set.
static bool PushEnabled();
static bool PushEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.streams.enabled pref is set.
static bool StreamsEnabled();
static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.requestcontext.enabled pref is set.
static bool RequestContextEnabled();
static bool RequestContextEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the gfx.offscreencanvas.enabled pref is set.
static bool OffscreenCanvasEnabled();
static bool OffscreenCanvasEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.webkitBlink.dirPicker.enabled pref is set.
static bool WebkitBlinkDirectoryPickerEnabled();
static bool WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.netinfo.enabled pref is set.
static bool NetworkInformationEnabled();
static bool NetworkInformationEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the dom.fetchObserver.enabled pref is set.
static bool FetchObserverEnabled();
static bool FetchObserverEnabled(JSContext* aCx, JSObject* aObj);
// Returns true if the privacy.resistFingerprinting pref is set.
static bool ResistFingerprintingEnabled();
// Returns true if the devtools.enabled pref is set.
static bool DevToolsEnabled();
};
} // dom namespace
} // mozilla namespace
#endif // mozilla_dom_DOMPreferences_h

View File

@ -1,26 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
PREF(ImageBitmapExtensionsEnabled, "canvas.imagebitmap_extensions.enabled")
PREF(DOMCachesEnabled, "dom.caches.enabled")
PREF(DOMCachesTestingEnabled, "dom.caches.testing.enabled")
PREF(PerformanceLoggingEnabled, "dom.performance.enable_user_timing_logging")
PREF(NotificationEnabled, "dom.webnotifications.enabled")
PREF(NotificationEnabledInServiceWorkers, "dom.webnotifications.serviceworker.enabled")
PREF(NotificationRIEnabled, "dom.webnotifications.requireinteraction.enabled")
PREF(ServiceWorkersEnabled, "dom.serviceWorkers.enabled")
PREF(ServiceWorkersTestingEnabled, "dom.serviceWorkers.testing.enabled")
PREF(StorageManagerEnabled, "dom.storageManager.enabled")
PREF(PromiseRejectionEventsEnabled, "dom.promise_rejection_events.enabled")
PREF(PushEnabled, "dom.push.enabled")
PREF(StreamsEnabled, "dom.streams.enabled")
PREF(RequestContextEnabled, "dom.requestcontext.enabled")
PREF(OffscreenCanvasEnabled, "gfx.offscreencanvas.enabled")
PREF(WebkitBlinkDirectoryPickerEnabled, "dom.webkitBlink.dirPicker.enabled")
PREF(NetworkInformationEnabled, "dom.netinfo.enabled")
PREF(FetchObserverEnabled, "dom.fetchObserver.enabled")
PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
PREF(DevToolsEnabled, "devtools.enabled")

View File

@ -8,9 +8,6 @@
#define mozilla_dom_FuzzingFunctions #define mozilla_dom_FuzzingFunctions
namespace mozilla { namespace mozilla {
class ErrorResult;
namespace dom { namespace dom {
class GlobalObject; class GlobalObject;

View File

@ -10,10 +10,6 @@
#include "mozIMozIntl.h" #include "mozIMozIntl.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#ifdef XP_WIN
#undef GetLocaleInfo
#endif
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {

View File

@ -10,10 +10,6 @@
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "xpcprivate.h" #include "xpcprivate.h"
#ifdef XP_WIN
#undef GetLocaleInfo
#endif
class nsPIDOMWindowInner; class nsPIDOMWindowInner;
namespace mozilla { namespace mozilla {

View File

@ -171,7 +171,6 @@ EXPORTS.mozilla.dom += [
'DOMMatrix.h', 'DOMMatrix.h',
'DOMParser.h', 'DOMParser.h',
'DOMPoint.h', 'DOMPoint.h',
'DOMPreferences.h',
'DOMQuad.h', 'DOMQuad.h',
'DOMRect.h', 'DOMRect.h',
'DOMRequest.h', 'DOMRequest.h',
@ -249,7 +248,6 @@ UNIFIED_SOURCES += [
'DOMMatrix.cpp', 'DOMMatrix.cpp',
'DOMParser.cpp', 'DOMParser.cpp',
'DOMPoint.cpp', 'DOMPoint.cpp',
'DOMPreferences.cpp',
'DOMQuad.cpp', 'DOMQuad.cpp',
'DOMRect.cpp', 'DOMRect.cpp',
'DOMRequest.cpp', 'DOMRequest.cpp',

View File

@ -295,9 +295,11 @@ bool nsContentUtils::sIsFrameTimingPrefEnabled = false;
bool nsContentUtils::sIsPerformanceTimingEnabled = false; bool nsContentUtils::sIsPerformanceTimingEnabled = false;
bool nsContentUtils::sIsResourceTimingEnabled = false; bool nsContentUtils::sIsResourceTimingEnabled = false;
bool nsContentUtils::sIsPerformanceNavigationTimingEnabled = false; bool nsContentUtils::sIsPerformanceNavigationTimingEnabled = false;
bool nsContentUtils::sIsUserTimingLoggingEnabled = false;
bool nsContentUtils::sIsFormAutofillAutocompleteEnabled = false; bool nsContentUtils::sIsFormAutofillAutocompleteEnabled = false;
bool nsContentUtils::sIsWebComponentsEnabled = false; bool nsContentUtils::sIsWebComponentsEnabled = false;
bool nsContentUtils::sIsCustomElementsEnabled = false; bool nsContentUtils::sIsCustomElementsEnabled = false;
bool nsContentUtils::sDevToolsEnabled = false;
bool nsContentUtils::sSendPerformanceTimingNotifications = false; bool nsContentUtils::sSendPerformanceTimingNotifications = false;
bool nsContentUtils::sUseActivityCursor = false; bool nsContentUtils::sUseActivityCursor = false;
bool nsContentUtils::sAnimationsAPICoreEnabled = false; bool nsContentUtils::sAnimationsAPICoreEnabled = false;
@ -335,6 +337,10 @@ nsIParser* nsContentUtils::sXMLFragmentParser = nullptr;
nsIFragmentContentSink* nsContentUtils::sXMLFragmentSink = nullptr; nsIFragmentContentSink* nsContentUtils::sXMLFragmentSink = nullptr;
bool nsContentUtils::sFragmentParsingActive = false; bool nsContentUtils::sFragmentParsingActive = false;
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
bool nsContentUtils::sDOMWindowDumpEnabled;
#endif
bool nsContentUtils::sDoNotTrackEnabled = false; bool nsContentUtils::sDoNotTrackEnabled = false;
mozilla::LazyLogModule nsContentUtils::sDOMDumpLog("Dump"); mozilla::LazyLogModule nsContentUtils::sDOMDumpLog("Dump");
@ -652,6 +658,9 @@ nsContentUtils::Init()
Preferences::AddBoolVarCache(&sIsPerformanceNavigationTimingEnabled, Preferences::AddBoolVarCache(&sIsPerformanceNavigationTimingEnabled,
"dom.enable_performance_navigation_timing", true); "dom.enable_performance_navigation_timing", true);
Preferences::AddBoolVarCache(&sIsUserTimingLoggingEnabled,
"dom.performance.enable_user_timing_logging", false);
Preferences::AddBoolVarCache(&sIsFrameTimingPrefEnabled, Preferences::AddBoolVarCache(&sIsFrameTimingPrefEnabled,
"dom.enable_frame_timing", false); "dom.enable_frame_timing", false);
@ -664,6 +673,9 @@ nsContentUtils::Init()
Preferences::AddBoolVarCache(&sIsCustomElementsEnabled, Preferences::AddBoolVarCache(&sIsCustomElementsEnabled,
"dom.webcomponents.customelements.enabled", false); "dom.webcomponents.customelements.enabled", false);
Preferences::AddBoolVarCache(&sDevToolsEnabled,
"devtools.enabled");
Preferences::AddIntVarCache(&sPrivacyMaxInnerWidth, Preferences::AddIntVarCache(&sPrivacyMaxInnerWidth,
"privacy.window.maxInnerWidth", "privacy.window.maxInnerWidth",
1000); 1000);
@ -687,6 +699,11 @@ nsContentUtils::Init()
"network.cookie.cookieBehavior", "network.cookie.cookieBehavior",
nsICookieService::BEHAVIOR_ACCEPT); nsICookieService::BEHAVIOR_ACCEPT);
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
Preferences::AddBoolVarCache(&sDOMWindowDumpEnabled,
"browser.dom.window.dump.enabled");
#endif
Preferences::AddBoolVarCache(&sDoNotTrackEnabled, Preferences::AddBoolVarCache(&sDoNotTrackEnabled,
"privacy.donottrackheader.enabled", false); "privacy.donottrackheader.enabled", false);
@ -2374,7 +2391,17 @@ nsContentUtils::IsCallerChrome()
bool bool
nsContentUtils::ShouldResistFingerprinting() nsContentUtils::ShouldResistFingerprinting()
{ {
return DOMPreferences::ResistFingerprintingEnabled(); if (NS_IsMainThread()) {
return nsRFPService::IsResistFingerprintingEnabled();
}
workers::WorkerPrivate* workerPrivate = workers::GetCurrentThreadWorkerPrivate();
if (NS_WARN_IF(!workerPrivate)) {
return false;
}
workerPrivate->AssertIsOnWorkerThread();
return workerPrivate->ResistFingerprintingEnabled();
} }
bool bool
@ -7584,6 +7611,19 @@ nsContentUtils::IsAllowedNonCorsContentType(const nsACString& aHeaderValue)
contentType.LowerCaseEqualsLiteral("multipart/form-data"); contentType.LowerCaseEqualsLiteral("multipart/form-data");
} }
bool
nsContentUtils::DOMWindowDumpEnabled()
{
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
// In optimized builds we check a pref that controls if we should
// enable output from dump() or not, in debug builds it's always
// enabled.
return nsContentUtils::sDOMWindowDumpEnabled;
#else
return true;
#endif
}
bool bool
nsContentUtils::DoNotTrackEnabled() nsContentUtils::DoNotTrackEnabled()
{ {
@ -8896,6 +8936,63 @@ nsContentUtils::GetReferrerPolicyFromHeader(const nsAString& aHeader)
return referrerPolicy; return referrerPolicy;
} }
// static
bool
nsContentUtils::PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.promise_rejection_events.enabled", false);
}
using namespace workers;
// Otherwise, check the pref via the WorkerPrivate
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->PromiseRejectionEventsEnabled();
}
// static
bool
nsContentUtils::PushEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.push.enabled", false);
}
using namespace workers;
// Otherwise, check the pref via the WorkerPrivate
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->PushEnabled();
}
// static
bool
nsContentUtils::StreamsEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.streams.enabled", false);
}
using namespace workers;
// Otherwise, check the pref via the WorkerPrivate
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->StreamsEnabled();
}
// static // static
bool bool
nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel) nsContentUtils::IsNonSubresourceRequest(nsIChannel* aChannel)
@ -11023,6 +11120,21 @@ nsContentUtils::ExtractErrorValues(JSContext* aCx,
#undef EXTRACT_EXN_VALUES #undef EXTRACT_EXN_VALUES
/* static */ bool
nsContentUtils::DevToolsEnabled(JSContext* aCx)
{
if (NS_IsMainThread()) {
return sDevToolsEnabled;
}
workers::WorkerPrivate* workerPrivate = workers::GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->DevToolsEnabled();
}
/* static */ bool /* static */ bool
nsContentUtils::ContentIsLink(nsIContent* aContent) nsContentUtils::ContentIsLink(nsIContent* aContent)
{ {

View File

@ -2276,6 +2276,14 @@ public:
return sIsPerformanceTimingEnabled; return sIsPerformanceTimingEnabled;
} }
/*
* Returns true if user timing API should print to console.
*/
static bool IsUserTimingLoggingEnabled()
{
return sIsUserTimingLoggingEnabled;
}
/* /*
* Returns true if the performance timing APIs are enabled. * Returns true if the performance timing APIs are enabled.
*/ */
@ -2682,6 +2690,11 @@ public:
*/ */
static mozilla::HTMLEditor* GetHTMLEditor(nsPresContext* aPresContext); static mozilla::HTMLEditor* GetHTMLEditor(nsPresContext* aPresContext);
/**
* Returns true if the browser.dom.window.dump.enabled pref is set.
*/
static bool DOMWindowDumpEnabled();
/** /**
* Returns true if the privacy.donottrackheader.enabled pref is set. * Returns true if the privacy.donottrackheader.enabled pref is set.
*/ */
@ -2918,6 +2931,12 @@ public:
*/ */
static mozilla::net::ReferrerPolicy GetReferrerPolicyFromHeader(const nsAString& aHeader); static mozilla::net::ReferrerPolicy GetReferrerPolicyFromHeader(const nsAString& aHeader);
static bool PromiseRejectionEventsEnabled(JSContext* aCx, JSObject* aObj);
static bool PushEnabled(JSContext* aCx, JSObject* aObj);
static bool StreamsEnabled(JSContext* aCx, JSObject* aObj);
static bool IsNonSubresourceRequest(nsIChannel* aChannel); static bool IsNonSubresourceRequest(nsIChannel* aChannel);
static uint32_t CookiesBehavior() static uint32_t CookiesBehavior()
@ -3401,10 +3420,12 @@ private:
static bool sIsPerformanceTimingEnabled; static bool sIsPerformanceTimingEnabled;
static bool sIsResourceTimingEnabled; static bool sIsResourceTimingEnabled;
static bool sIsPerformanceNavigationTimingEnabled; static bool sIsPerformanceNavigationTimingEnabled;
static bool sIsUserTimingLoggingEnabled;
static bool sIsFrameTimingPrefEnabled; static bool sIsFrameTimingPrefEnabled;
static bool sIsFormAutofillAutocompleteEnabled; static bool sIsFormAutofillAutocompleteEnabled;
static bool sIsWebComponentsEnabled; static bool sIsWebComponentsEnabled;
static bool sIsCustomElementsEnabled; static bool sIsCustomElementsEnabled;
static bool sDevToolsEnabled;
static bool sSendPerformanceTimingNotifications; static bool sSendPerformanceTimingNotifications;
static bool sUseActivityCursor; static bool sUseActivityCursor;
static bool sAnimationsAPICoreEnabled; static bool sAnimationsAPICoreEnabled;
@ -3453,6 +3474,9 @@ private:
// bytecode out of the nsCacheInfoChannel. // bytecode out of the nsCacheInfoChannel.
static nsCString* sJSBytecodeMimeType; static nsCString* sJSBytecodeMimeType;
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
static bool sDOMWindowDumpEnabled;
#endif
static bool sDoNotTrackEnabled; static bool sDoNotTrackEnabled;
static mozilla::LazyLogModule sDOMDumpLog; static mozilla::LazyLogModule sDOMDumpLog;

View File

@ -36,7 +36,6 @@
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/ScriptPreloader.h" #include "mozilla/ScriptPreloader.h"
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/MessagePort.h" #include "mozilla/dom/MessagePort.h"
#include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ContentParent.h"
@ -806,7 +805,7 @@ nsFrameMessageManager::ReleaseCachedProcesses()
NS_IMETHODIMP NS_IMETHODIMP
nsFrameMessageManager::Dump(const nsAString& aStr) nsFrameMessageManager::Dump(const nsAString& aStr)
{ {
if (!DOMPreferences::DumpEnabled()) { if (!nsContentUtils::DOMWindowDumpEnabled()) {
return NS_OK; return NS_OK;
} }

View File

@ -17,7 +17,6 @@
#include "nsHistory.h" #include "nsHistory.h"
#include "nsDOMNavigationTiming.h" #include "nsDOMNavigationTiming.h"
#include "nsIDOMStorageManager.h" #include "nsIDOMStorageManager.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/LocalStorage.h" #include "mozilla/dom/LocalStorage.h"
#include "mozilla/dom/Storage.h" #include "mozilla/dom/Storage.h"
#include "mozilla/dom/IdleRequest.h" #include "mozilla/dom/IdleRequest.h"
@ -3383,7 +3382,7 @@ nsGlobalWindowInner::GetFullScreen()
void void
nsGlobalWindowInner::Dump(const nsAString& aStr) nsGlobalWindowInner::Dump(const nsAString& aStr)
{ {
if (!DOMPreferences::DumpEnabled()) { if (!nsContentUtils::DOMWindowDumpEnabled()) {
return; return;
} }
@ -7586,7 +7585,7 @@ nsGlobalWindowInner::CreateImageBitmap(JSContext* aCx,
const Sequence<ChannelPixelLayout>& aLayout, const Sequence<ChannelPixelLayout>& aLayout,
ErrorResult& aRv) ErrorResult& aRv)
{ {
if (!DOMPreferences::ImageBitmapExtensionsEnabled()) { if (!ImageBitmap::ExtensionsEnabled(aCx)) {
aRv.Throw(NS_ERROR_TYPE_ERR); aRv.Throw(NS_ERROR_TYPE_ERR);
return nullptr; return nullptr;
} }

View File

@ -37,7 +37,6 @@
#include "nsSize.h" #include "nsSize.h"
#include "mozilla/FlushType.h" #include "mozilla/FlushType.h"
#include "prclist.h" #include "prclist.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/StorageEvent.h" #include "mozilla/dom/StorageEvent.h"
#include "mozilla/dom/StorageEventBinding.h" #include "mozilla/dom/StorageEventBinding.h"

24
dom/cache/Cache.cpp vendored
View File

@ -17,7 +17,6 @@
#include "mozilla/dom/cache/CacheChild.h" #include "mozilla/dom/cache/CacheChild.h"
#include "mozilla/dom/cache/CacheWorkerHolder.h" #include "mozilla/dom/cache/CacheWorkerHolder.h"
#include "mozilla/dom/cache/ReadStream.h" #include "mozilla/dom/cache/ReadStream.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
@ -518,6 +517,29 @@ Cache::Keys(JSContext* aCx, const Optional<RequestOrUSVString>& aRequest,
return ExecuteOp(args, aRv); return ExecuteOp(args, aRv);
} }
// static
bool
Cache::PrefEnabled(JSContext* aCx, JSObject* aObj)
{
using mozilla::dom::workers::WorkerPrivate;
using mozilla::dom::workers::GetWorkerPrivateFromContext;
// If we're on the main thread, then check the pref directly.
if (NS_IsMainThread()) {
bool enabled = false;
Preferences::GetBool("dom.caches.enabled", &enabled);
return enabled;
}
// Otherwise check the pref via the work private helper
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->DOMCachesEnabled();
}
nsISupports* nsISupports*
Cache::GetParentObject() const Cache::GetParentObject() const
{ {

2
dom/cache/Cache.h vendored
View File

@ -68,6 +68,8 @@ public:
const CacheQueryOptions& aParams, ErrorResult& aRv); const CacheQueryOptions& aParams, ErrorResult& aRv);
// binding methods // binding methods
static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
nsISupports* GetParentObject() const; nsISupports* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto) override; virtual JSObject* WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto) override;

View File

@ -9,7 +9,6 @@
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "mozilla/dom/CacheBinding.h" #include "mozilla/dom/CacheBinding.h"
#include "mozilla/dom/CacheStorageBinding.h" #include "mozilla/dom/CacheStorageBinding.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/InternalRequest.h" #include "mozilla/dom/InternalRequest.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "mozilla/dom/Response.h" #include "mozilla/dom/Response.h"
@ -162,7 +161,7 @@ CacheStorage::CreateOnMainThread(Namespace aNamespace, nsIGlobalObject* aGlobal,
bool testingEnabled = aForceTrustedOrigin || bool testingEnabled = aForceTrustedOrigin ||
Preferences::GetBool("dom.caches.testing.enabled", false) || Preferences::GetBool("dom.caches.testing.enabled", false) ||
DOMPreferences::ServiceWorkersTestingEnabled(); Preferences::GetBool("dom.serviceWorkers.testing.enabled", false);
if (!IsTrusted(principalInfo, testingEnabled)) { if (!IsTrusted(principalInfo, testingEnabled)) {
NS_WARNING("CacheStorage not supported on untrusted origins."); NS_WARNING("CacheStorage not supported on untrusted origins.");
@ -220,8 +219,8 @@ CacheStorage::CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
// origin checks. The ServiceWorker has its own trusted origin checks // origin checks. The ServiceWorker has its own trusted origin checks
// that are better than ours. In addition, we don't have information // that are better than ours. In addition, we don't have information
// about the window any more, so we can't do our own checks. // about the window any more, so we can't do our own checks.
bool testingEnabled = DOMPreferences::DOMCachesTestingEnabled() || bool testingEnabled = aWorkerPrivate->DOMCachesTestingEnabled() ||
DOMPreferences::ServiceWorkersTestingEnabled() || aWorkerPrivate->ServiceWorkersTestingEnabled() ||
aWorkerPrivate->ServiceWorkersTestingInWindow() || aWorkerPrivate->ServiceWorkersTestingInWindow() ||
aWorkerPrivate->IsServiceWorker(); aWorkerPrivate->IsServiceWorker();
@ -445,6 +444,13 @@ CacheStorage::Keys(ErrorResult& aRv)
return promise.forget(); return promise.forget();
} }
// static
bool
CacheStorage::PrefEnabled(JSContext* aCx, JSObject* aObj)
{
return Cache::PrefEnabled(aCx, aObj);
}
// static // static
already_AddRefed<CacheStorage> already_AddRefed<CacheStorage>
CacheStorage::Constructor(const GlobalObject& aGlobal, CacheStorage::Constructor(const GlobalObject& aGlobal,

View File

@ -73,6 +73,8 @@ public:
nsIPrincipal* aPrincipal, ErrorResult& aRv); nsIPrincipal* aPrincipal, ErrorResult& aRv);
// binding methods // binding methods
static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
nsISupports* GetParentObject() const; nsISupports* GetParentObject() const;
virtual JSObject* WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto) override; virtual JSObject* WrapObject(JSContext* aContext, JS::Handle<JSObject*> aGivenProto) override;

View File

@ -6,7 +6,6 @@
#include "mozilla/dom/ImageBitmap.h" #include "mozilla/dom/ImageBitmap.h"
#include "mozilla/CheckedInt.h" #include "mozilla/CheckedInt.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/ImageBitmapBinding.h" #include "mozilla/dom/ImageBitmapBinding.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "mozilla/dom/StructuredCloneTags.h" #include "mozilla/dom/StructuredCloneTags.h"
@ -1435,6 +1434,18 @@ ImageBitmap::WriteStructuredClone(JSStructuredCloneWriter* aWriter,
return true; return true;
} }
/*static*/ bool
ImageBitmap::ExtensionsEnabled(JSContext* aCx, JSObject*)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("canvas.imagebitmap_extensions.enabled");
} else {
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
MOZ_ASSERT(workerPrivate);
return workerPrivate->ImageBitmapExtensionsEnabled();
}
}
// ImageBitmap extensions. // ImageBitmap extensions.
ImageBitmapFormat ImageBitmapFormat
ImageBitmap::FindOptimalFormat(const Optional<Sequence<ImageBitmapFormat>>& aPossibleFormats, ImageBitmap::FindOptimalFormat(const Optional<Sequence<ImageBitmapFormat>>& aPossibleFormats,

View File

@ -152,6 +152,12 @@ public:
nsTArray<RefPtr<gfx::DataSourceSurface>>& aClonedSurfaces, nsTArray<RefPtr<gfx::DataSourceSurface>>& aClonedSurfaces,
ImageBitmap* aImageBitmap); ImageBitmap* aImageBitmap);
// Mozilla Extensions
// aObj is an optional argument that isn't used by ExtensionsEnabled() and
// only exists because the bindings layer insists on passing it to us. All
// other consumers of this function should only call it passing one argument.
static bool ExtensionsEnabled(JSContext* aCx, JSObject* aObj = nullptr);
friend CreateImageBitmapFromBlob; friend CreateImageBitmapFromBlob;
friend CreateImageBitmapFromBlobTask; friend CreateImageBitmapFromBlobTask;
friend CreateImageBitmapFromBlobWorkerTask; friend CreateImageBitmapFromBlobWorkerTask;

View File

@ -6,7 +6,6 @@
#include "OffscreenCanvas.h" #include "OffscreenCanvas.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/OffscreenCanvasBinding.h" #include "mozilla/dom/OffscreenCanvasBinding.h"
#include "mozilla/dom/WorkerPrivate.h" #include "mozilla/dom/WorkerPrivate.h"
#include "mozilla/dom/WorkerScope.h" #include "mozilla/dom/WorkerScope.h"
@ -333,6 +332,18 @@ OffscreenCanvas::CreateFromCloneData(nsIGlobalObject* aGlobal, OffscreenCanvasCl
return wc.forget(); return wc.forget();
} }
/* static */ bool
OffscreenCanvas::PrefEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("gfx.offscreencanvas.enabled");
} else {
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
MOZ_ASSERT(workerPrivate);
return workerPrivate->OffscreenCanvasEnabled();
}
}
/* static */ bool /* static */ bool
OffscreenCanvas::PrefEnabledOnWorkerThread(JSContext* aCx, JSObject* aObj) OffscreenCanvas::PrefEnabledOnWorkerThread(JSContext* aCx, JSObject* aObj)
{ {
@ -340,7 +351,7 @@ OffscreenCanvas::PrefEnabledOnWorkerThread(JSContext* aCx, JSObject* aObj)
return true; return true;
} }
return DOMPreferences::OffscreenCanvasEnabled(aCx, aObj); return PrefEnabled(aCx, aObj);
} }
NS_IMPL_CYCLE_COLLECTION_INHERITED(OffscreenCanvas, DOMEventTargetHelper, mCurrentContext) NS_IMPL_CYCLE_COLLECTION_INHERITED(OffscreenCanvas, DOMEventTargetHelper, mCurrentContext)

View File

@ -9,7 +9,6 @@
#include "gfxTypes.h" #include "gfxTypes.h"
#include "mozilla/DOMEventTargetHelper.h" #include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/layers/LayersTypes.h" #include "mozilla/layers/LayersTypes.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "CanvasRenderingContextHelper.h" #include "CanvasRenderingContextHelper.h"
@ -131,6 +130,8 @@ public:
static already_AddRefed<OffscreenCanvas> static already_AddRefed<OffscreenCanvas>
CreateFromCloneData(nsIGlobalObject* aGlobal, OffscreenCanvasCloneData* aData); CreateFromCloneData(nsIGlobalObject* aGlobal, OffscreenCanvasCloneData* aData);
static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
// Return true on main-thread, and return gfx.offscreencanvas.enabled // Return true on main-thread, and return gfx.offscreencanvas.enabled
// on worker thread. // on worker thread.
static bool PrefEnabledOnWorkerThread(JSContext* aCx, JSObject* aObj); static bool PrefEnabledOnWorkerThread(JSContext* aCx, JSObject* aObj);

View File

@ -8,7 +8,6 @@
#include "mozilla/dom/ConsoleBinding.h" #include "mozilla/dom/ConsoleBinding.h"
#include "mozilla/dom/BlobBinding.h" #include "mozilla/dom/BlobBinding.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/Exceptions.h" #include "mozilla/dom/Exceptions.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/FunctionBinding.h" #include "mozilla/dom/FunctionBinding.h"
@ -1055,7 +1054,7 @@ Console::ProfileMethodInternal(JSContext* aCx, const nsAString& aAction,
const Sequence<JS::Value>& aData) const Sequence<JS::Value>& aData)
{ {
// Make all Console API no-op if DevTools aren't enabled. // Make all Console API no-op if DevTools aren't enabled.
if (!DOMPreferences::DevToolsEnabled()) { if (!nsContentUtils::DevToolsEnabled(aCx)) {
return; return;
} }
@ -1208,7 +1207,7 @@ Console::MethodInternal(JSContext* aCx, MethodName aMethodName,
const Sequence<JS::Value>& aData) const Sequence<JS::Value>& aData)
{ {
// Make all Console API no-op if DevTools aren't enabled. // Make all Console API no-op if DevTools aren't enabled.
if (!DOMPreferences::DevToolsEnabled()) { if (!nsContentUtils::DevToolsEnabled(aCx)) {
return; return;
} }
AssertIsOnOwningThread(); AssertIsOnOwningThread();

View File

@ -26,6 +26,24 @@ NS_INTERFACE_MAP_END_INHERITING(DOMEventTargetHelper)
NS_IMPL_ADDREF_INHERITED(FetchObserver, DOMEventTargetHelper) NS_IMPL_ADDREF_INHERITED(FetchObserver, DOMEventTargetHelper)
NS_IMPL_RELEASE_INHERITED(FetchObserver, DOMEventTargetHelper) NS_IMPL_RELEASE_INHERITED(FetchObserver, DOMEventTargetHelper)
/* static */ bool
FetchObserver::IsEnabled(JSContext* aCx, JSObject* aGlobal)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.fetchObserver.enabled", false);
}
using namespace workers;
// Otherwise, check the pref via the WorkerPrivate
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->FetchObserverEnabled();
}
FetchObserver::FetchObserver(nsIGlobalObject* aGlobal, FetchObserver::FetchObserver(nsIGlobalObject* aGlobal,
AbortSignal* aSignal) AbortSignal* aSignal)
: DOMEventTargetHelper(aGlobal) : DOMEventTargetHelper(aGlobal)

View File

@ -21,6 +21,9 @@ public:
NS_DECL_ISUPPORTS_INHERITED NS_DECL_ISUPPORTS_INHERITED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FetchObserver, DOMEventTargetHelper) NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(FetchObserver, DOMEventTargetHelper)
static bool
IsEnabled(JSContext* aCx, JSObject* aGlobal);
FetchObserver(nsIGlobalObject* aGlobal, AbortSignal* aSignal); FetchObserver(nsIGlobalObject* aGlobal, AbortSignal* aSignal);
JSObject* JSObject*

View File

@ -77,6 +77,25 @@ Request::~Request()
{ {
} }
// static
bool
Request::RequestContextEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.requestcontext.enabled", false);
}
using namespace workers;
// Otherwise, check the pref via the WorkerPrivate
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->RequestContextEnabled();
}
already_AddRefed<InternalRequest> already_AddRefed<InternalRequest>
Request::GetInternalRequest() Request::GetInternalRequest()
{ {

View File

@ -35,6 +35,9 @@ public:
Request(nsIGlobalObject* aOwner, InternalRequest* aRequest, Request(nsIGlobalObject* aOwner, InternalRequest* aRequest,
AbortSignal* aSignal); AbortSignal* aSignal);
static bool
RequestContextEnabled(JSContext* aCx, JSObject* aObj);
JSObject* JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override
{ {

View File

@ -47,6 +47,24 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(Directory)
NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsISupports)
NS_INTERFACE_MAP_END NS_INTERFACE_MAP_END
/* static */ bool
Directory::WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.webkitBlink.dirPicker.enabled", false);
}
// aCx can be null when this function is called by something else than WebIDL
// binding code.
workers::WorkerPrivate* workerPrivate =
workers::GetCurrentThreadWorkerPrivate();
if (!workerPrivate) {
return false;
}
return workerPrivate->WebkitBlinkDirectoryPickerEnabled();
}
/* static */ already_AddRefed<Directory> /* static */ already_AddRefed<Directory>
Directory::Constructor(const GlobalObject& aGlobal, Directory::Constructor(const GlobalObject& aGlobal,
const nsAString& aRealPath, const nsAString& aRealPath,

View File

@ -29,6 +29,9 @@ public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Directory) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(Directory)
static bool
WebkitBlinkDirectoryPickerEnabled(JSContext* aCx, JSObject* aObj);
static already_AddRefed<Directory> static already_AddRefed<Directory>
Constructor(const GlobalObject& aGlobal, Constructor(const GlobalObject& aGlobal,
const nsAString& aRealPath, const nsAString& aRealPath,

View File

@ -36,7 +36,6 @@
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "mozilla/dom/Directory.h" #include "mozilla/dom/Directory.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
namespace mozilla { namespace mozilla {
@ -488,7 +487,7 @@ FSMultipartFormData::AddNameBlobOrNullPair(const nsAString& aName, Blob* aBlob)
if (file) { if (file) {
nsAutoString relativePath; nsAutoString relativePath;
file->GetRelativePath(relativePath); file->GetRelativePath(relativePath);
if (DOMPreferences::WebkitBlinkDirectoryPickerEnabled() && if (Directory::WebkitBlinkDirectoryPickerEnabled(nullptr, nullptr) &&
!relativePath.IsEmpty()) { !relativePath.IsEmpty()) {
filename16 = relativePath; filename16 = relativePath;
} }
@ -547,7 +546,7 @@ nsresult
FSMultipartFormData::AddNameDirectoryPair(const nsAString& aName, FSMultipartFormData::AddNameDirectoryPair(const nsAString& aName,
Directory* aDirectory) Directory* aDirectory)
{ {
if (!DOMPreferences::WebkitBlinkDirectoryPickerEnabled()) { if (!Directory::WebkitBlinkDirectoryPickerEnabled(nullptr, nullptr)) {
return NS_OK; return NS_OK;
} }

View File

@ -11,7 +11,6 @@
#include "mozilla/DebugOnly.h" #include "mozilla/DebugOnly.h"
#include "mozilla/dom/Date.h" #include "mozilla/dom/Date.h"
#include "mozilla/dom/Directory.h" #include "mozilla/dom/Directory.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/HTMLFormSubmission.h" #include "mozilla/dom/HTMLFormSubmission.h"
#include "mozilla/dom/FileSystemUtils.h" #include "mozilla/dom/FileSystemUtils.h"
#include "mozilla/dom/GetFilesHelper.h" #include "mozilla/dom/GetFilesHelper.h"
@ -686,7 +685,7 @@ HTMLInputElement::nsFilePickerShownCallback::Done(int16_t aResult)
RefPtr<DispatchChangeEventCallback> dispatchChangeEventCallback = RefPtr<DispatchChangeEventCallback> dispatchChangeEventCallback =
new DispatchChangeEventCallback(mInput); new DispatchChangeEventCallback(mInput);
if (DOMPreferences::WebkitBlinkDirectoryPickerEnabled() && if (IsWebkitDirPickerEnabled() &&
mInput->HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)) { mInput->HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)) {
ErrorResult error; ErrorResult error;
GetFilesHelper* helper = mInput->GetOrCreateGetFilesHelper(true, error); GetFilesHelper* helper = mInput->GetOrCreateGetFilesHelper(true, error);
@ -2747,7 +2746,7 @@ HTMLInputElement::GetDisplayFileName(nsAString& aValue) const
if (mFileData->mFilesOrDirectories.IsEmpty()) { if (mFileData->mFilesOrDirectories.IsEmpty()) {
if ((IsDirPickerEnabled() && Allowdirs()) || if ((IsDirPickerEnabled() && Allowdirs()) ||
(DOMPreferences::WebkitBlinkDirectoryPickerEnabled() && (IsWebkitDirPickerEnabled() &&
HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) { HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) {
nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES, nsContentUtils::GetLocalizedString(nsContentUtils::eFORMS_PROPERTIES,
"NoDirSelected", value); "NoDirSelected", value);
@ -2840,7 +2839,7 @@ HTMLInputElement::MozSetDndFilesAndDirectories(const nsTArray<OwningFileOrDirect
RefPtr<DispatchChangeEventCallback> dispatchChangeEventCallback = RefPtr<DispatchChangeEventCallback> dispatchChangeEventCallback =
new DispatchChangeEventCallback(this); new DispatchChangeEventCallback(this);
if (DOMPreferences::WebkitBlinkDirectoryPickerEnabled() && if (IsWebkitDirPickerEnabled() &&
HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)) { HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)) {
ErrorResult rv; ErrorResult rv;
GetFilesHelper* helper = GetOrCreateGetFilesHelper(true /* recursionFlag */, GetFilesHelper* helper = GetOrCreateGetFilesHelper(true /* recursionFlag */,
@ -2922,7 +2921,7 @@ HTMLInputElement::GetFiles()
} }
if (IsDirPickerEnabled() && Allowdirs() && if (IsDirPickerEnabled() && Allowdirs() &&
(!DOMPreferences::WebkitBlinkDirectoryPickerEnabled() || (!IsWebkitDirPickerEnabled() ||
!HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) { !HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory))) {
return nullptr; return nullptr;
} }
@ -4173,7 +4172,7 @@ HTMLInputElement::MaybeInitPickers(EventChainPostVisitor& aVisitor)
if (target && if (target &&
target->FindFirstNonChromeOnlyAccessContent() == this && target->FindFirstNonChromeOnlyAccessContent() == this &&
((IsDirPickerEnabled() && Allowdirs()) || ((IsDirPickerEnabled() && Allowdirs()) ||
(DOMPreferences::WebkitBlinkDirectoryPickerEnabled() && (IsWebkitDirPickerEnabled() &&
HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)))) { HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory)))) {
type = FILE_PICKER_DIRECTORY; type = FILE_PICKER_DIRECTORY;
} }
@ -5634,6 +5633,21 @@ HTMLInputElement::IsDateTimeTypeSupported(uint8_t aDateTimeInputType)
IsInputDateTimeOthersEnabled()); IsInputDateTimeOthersEnabled());
} }
/* static */ bool
HTMLInputElement::IsWebkitDirPickerEnabled()
{
static bool sWebkitDirPickerEnabled = false;
static bool sWebkitDirPickerPrefCached = false;
if (!sWebkitDirPickerPrefCached) {
sWebkitDirPickerPrefCached = true;
Preferences::AddBoolVarCache(&sWebkitDirPickerEnabled,
"dom.webkitBlink.dirPicker.enabled",
false);
}
return sWebkitDirPickerEnabled;
}
/* static */ bool /* static */ bool
HTMLInputElement::IsWebkitFileSystemEnabled() HTMLInputElement::IsWebkitFileSystemEnabled()
{ {

View File

@ -1727,6 +1727,13 @@ private:
static bool static bool
IsDateTimeTypeSupported(uint8_t aDateTimeInputType); IsDateTimeTypeSupported(uint8_t aDateTimeInputType);
/**
* Checks preference "dom.webkitBlink.dirPicker.enabled" to determine if
* webkitdirectory should be supported.
*/
static bool
IsWebkitDirPickerEnabled();
/** /**
* Checks preference "dom.webkitBlink.filesystem.enabled" to determine if * Checks preference "dom.webkitBlink.filesystem.enabled" to determine if
* webkitEntries should be supported. * webkitEntries should be supported.

View File

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "ImageDocument.h" #include "ImageDocument.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/ImageDocumentBinding.h" #include "mozilla/dom/ImageDocumentBinding.h"
#include "mozilla/dom/HTMLImageElement.h" #include "mozilla/dom/HTMLImageElement.h"
#include "nsRect.h" #include "nsRect.h"
@ -50,7 +49,7 @@
//XXX A hack needed for Firefox's site specific zoom. //XXX A hack needed for Firefox's site specific zoom.
static bool IsSiteSpecific() static bool IsSiteSpecific()
{ {
return !mozilla::dom::DOMPreferences::ResistFingerprintingEnabled() && return !mozilla::Preferences::GetBool("privacy.resistFingerprinting", false) &&
mozilla::Preferences::GetBool("browser.zoom.siteSpecific", false); mozilla::Preferences::GetBool("browser.zoom.siteSpecific", false);
} }

View File

@ -8,7 +8,6 @@
#include "mozilla/dom/PTabContext.h" #include "mozilla/dom/PTabContext.h"
#include "mozilla/dom/TabParent.h" #include "mozilla/dom/TabParent.h"
#include "mozilla/dom/TabChild.h" #include "mozilla/dom/TabChild.h"
#include "mozilla/dom/DOMPreferences.h"
#include "nsIScriptSecurityManager.h" #include "nsIScriptSecurityManager.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
@ -247,7 +246,7 @@ MaybeInvalidTabContext::MaybeInvalidTabContext(const IPCTabContext& aParams)
// It is meant as a temporary solution until service workers can // It is meant as a temporary solution until service workers can
// provide a TabChild equivalent. Don't allow this on b2g since // provide a TabChild equivalent. Don't allow this on b2g since
// it might be used to escalate privileges. // it might be used to escalate privileges.
if (!DOMPreferences::ServiceWorkersEnabled()) { if (!Preferences::GetBool("dom.serviceWorkers.enabled", false)) {
mInvalidReason = "ServiceWorkers should be enabled."; mInvalidReason = "ServiceWorkers should be enabled.";
return; return;
} }

View File

@ -106,6 +106,18 @@ Connection::Update(ConnectionType aType, bool aIsWifi, uint32_t aDHCPGateway,
} }
} }
/* static */ bool
Connection::IsEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.netinfo.enabled");
}
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
MOZ_ASSERT(workerPrivate);
return workerPrivate->NetworkInformationEnabled();
}
/* static */ Connection* /* static */ Connection*
Connection::CreateForWindow(nsPIDOMWindowInner* aWindow) Connection::CreateForWindow(nsPIDOMWindowInner* aWindow)
{ {

View File

@ -37,6 +37,8 @@ public:
NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper) NS_REALLY_FORWARD_NSIDOMEVENTTARGET(DOMEventTargetHelper)
static bool IsEnabled(JSContext* aCx, JSObject* aObj);
static Connection* static Connection*
CreateForWindow(nsPIDOMWindowInner* aWindow); CreateForWindow(nsPIDOMWindowInner* aWindow);

View File

@ -19,7 +19,6 @@
#include "mozilla/dom/AppNotificationServiceOptionsBinding.h" #include "mozilla/dom/AppNotificationServiceOptionsBinding.h"
#include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/ContentChild.h" #include "mozilla/dom/ContentChild.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/NotificationEvent.h" #include "mozilla/dom/NotificationEvent.h"
#include "mozilla/dom/PermissionMessageUtils.h" #include "mozilla/dom/PermissionMessageUtils.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
@ -894,22 +893,39 @@ NotificationTask::Run()
return NS_OK; return NS_OK;
} }
bool
Notification::RequireInteractionEnabled(JSContext* aCx, JSObject* aOjb)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.webnotifications.requireinteraction.enabled", false);
}
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->DOMWorkerNotificationRIEnabled();
}
// static // static
bool bool
Notification::PrefEnabled(JSContext* aCx, JSObject* aObj) Notification::PrefEnabled(JSContext* aCx, JSObject* aObj)
{ {
if (!NS_IsMainThread()) { if (NS_IsMainThread()) {
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx); return Preferences::GetBool("dom.webnotifications.enabled", false);
if (!workerPrivate) {
return false;
}
if (workerPrivate->IsServiceWorker()) {
return DOMPreferences::NotificationEnabledInServiceWorkers();
}
} }
return DOMPreferences::NotificationEnabled(); WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
if (workerPrivate->IsServiceWorker()) {
return workerPrivate->DOMServiceWorkerNotificationEnabled();
}
return workerPrivate->DOMWorkerNotificationEnabled();
} }
// static // static
@ -1724,7 +1740,7 @@ Notification::ShowInternal()
bool inPrivateBrowsing = IsInPrivateBrowsing(); bool inPrivateBrowsing = IsInPrivateBrowsing();
bool requireInteraction = mRequireInteraction; bool requireInteraction = mRequireInteraction;
if (!DOMPreferences::NotificationRIEnabled()) { if (!Preferences::GetBool("dom.webnotifications.requireinteraction.enabled", false)) {
requireInteraction = false; requireInteraction = false;
} }

View File

@ -152,6 +152,7 @@ public:
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Notification, DOMEventTargetHelper) NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(Notification, DOMEventTargetHelper)
NS_DECL_NSIOBSERVER NS_DECL_NSIOBSERVER
static bool RequireInteractionEnabled(JSContext* aCx, JSObject* aObj);
static bool PrefEnabled(JSContext* aCx, JSObject* aObj); static bool PrefEnabled(JSContext* aCx, JSObject* aObj);
// Returns if Notification.get() is allowed for the current global. // Returns if Notification.get() is allowed for the current global.
static bool IsGetEnabled(JSContext* aCx, JSObject* aObj); static bool IsGetEnabled(JSContext* aCx, JSObject* aObj);

View File

@ -6,7 +6,6 @@
#include "PerformanceMainThread.h" #include "PerformanceMainThread.h"
#include "PerformanceNavigation.h" #include "PerformanceNavigation.h"
#include "mozilla/dom/DOMPreferences.h"
#include "nsICacheInfoChannel.h" #include "nsICacheInfoChannel.h"
namespace mozilla { namespace mozilla {
@ -283,7 +282,7 @@ PerformanceMainThread::InsertUserEntry(PerformanceEntry* aEntry)
nsAutoCString uri; nsAutoCString uri;
uint64_t markCreationEpoch = 0; uint64_t markCreationEpoch = 0;
if (DOMPreferences::PerformanceLoggingEnabled() || if (nsContentUtils::IsUserTimingLoggingEnabled() ||
nsContentUtils::SendPerformanceTimingNotifications()) { nsContentUtils::SendPerformanceTimingNotifications()) {
nsresult rv = NS_ERROR_FAILURE; nsresult rv = NS_ERROR_FAILURE;
nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner(); nsCOMPtr<nsPIDOMWindowInner> owner = GetOwner();
@ -297,7 +296,7 @@ PerformanceMainThread::InsertUserEntry(PerformanceEntry* aEntry)
} }
markCreationEpoch = static_cast<uint64_t>(PR_Now() / PR_USEC_PER_MSEC); markCreationEpoch = static_cast<uint64_t>(PR_Now() / PR_USEC_PER_MSEC);
if (DOMPreferences::PerformanceLoggingEnabled()) { if (nsContentUtils::IsUserTimingLoggingEnabled()) {
Performance::LogEntry(aEntry, uri); Performance::LogEntry(aEntry, uri);
} }
} }

View File

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "PerformanceWorker.h" #include "PerformanceWorker.h"
#include "mozilla/dom/DOMPreferences.h"
#include "WorkerPrivate.h" #include "WorkerPrivate.h"
namespace mozilla { namespace mozilla {
@ -27,7 +26,7 @@ PerformanceWorker::~PerformanceWorker()
void void
PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry) PerformanceWorker::InsertUserEntry(PerformanceEntry* aEntry)
{ {
if (DOMPreferences::PerformanceLoggingEnabled()) { if (mWorkerPrivate->PerformanceLoggingEnabled()) {
nsAutoCString uri; nsAutoCString uri;
nsCOMPtr<nsIURI> scriptURI = mWorkerPrivate->GetResolvedScriptURI(); nsCOMPtr<nsIURI> scriptURI = mWorkerPrivate->GetResolvedScriptURI();
if (!scriptURI || NS_FAILED(scriptURI->GetHost(uri))) { if (!scriptURI || NS_FAILED(scriptURI->GetHost(uri))) {

View File

@ -32,9 +32,9 @@
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/TypedArray.h" #include "mozilla/dom/TypedArray.h"
#include "mozilla/dom/DOMPreferences.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
class nsIGlobalObject; class nsIGlobalObject;

View File

@ -10,13 +10,13 @@
#include "jsapi.h" #include "jsapi.h"
#include "nsCOMPtr.h" #include "nsCOMPtr.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
#include "mozilla/AlreadyAddRefed.h" #include "mozilla/AlreadyAddRefed.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/RefPtr.h" #include "mozilla/RefPtr.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/PushSubscriptionBinding.h" #include "mozilla/dom/PushSubscriptionBinding.h"
#include "mozilla/dom/PushSubscriptionOptionsBinding.h" #include "mozilla/dom/PushSubscriptionOptionsBinding.h"
#include "mozilla/dom/TypedArray.h" #include "mozilla/dom/TypedArray.h"

View File

@ -8,9 +8,9 @@
#define mozilla_dom_PushSubscriptionOptions_h #define mozilla_dom_PushSubscriptionOptions_h
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
#include "nsTArray.h" #include "nsTArray.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "mozilla/dom/DOMPreferences.h"
class nsIGlobalObject; class nsIGlobalObject;

View File

@ -6,7 +6,6 @@
#include "StorageManager.h" #include "StorageManager.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/PromiseWorkerProxy.h" #include "mozilla/dom/PromiseWorkerProxy.h"
#include "mozilla/dom/quota/QuotaManagerService.h" #include "mozilla/dom/quota/QuotaManagerService.h"
#include "mozilla/dom/StorageManagerBinding.h" #include "mozilla/dom/StorageManagerBinding.h"
@ -866,6 +865,20 @@ StorageManager::Estimate(ErrorResult& aRv)
aRv); aRv);
} }
// static
bool
StorageManager::PrefEnabled(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.storageManager.enabled");
}
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
MOZ_ASSERT(workerPrivate);
return workerPrivate->StorageManagerEnabled();
}
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(StorageManager, mOwner) NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(StorageManager, mOwner)
NS_IMPL_CYCLE_COLLECTING_ADDREF(StorageManager) NS_IMPL_CYCLE_COLLECTING_ADDREF(StorageManager)

View File

@ -25,6 +25,10 @@ class StorageManager final
nsCOMPtr<nsIGlobalObject> mOwner; nsCOMPtr<nsIGlobalObject> mOwner;
public: public:
// Return dom.quota.storageManager.enabled on main/worker thread.
static bool
PrefEnabled(JSContext* aCx, JSObject* aObj);
explicit explicit
StorageManager(nsIGlobalObject* aGlobal); StorageManager(nsIGlobalObject* aGlobal);

View File

@ -11,7 +11,7 @@
// https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#cache // https://slightlyoff.github.io/ServiceWorker/spec/service_worker/index.html#cache
[Exposed=(Window,Worker), [Exposed=(Window,Worker),
Func="mozilla::dom::DOMPreferences::DOMCachesEnabled"] Func="mozilla::dom::cache::Cache::PrefEnabled"]
interface Cache { interface Cache {
[NewObject] [NewObject]
Promise<Response> match(RequestInfo request, optional CacheQueryOptions options); Promise<Response> match(RequestInfo request, optional CacheQueryOptions options);

View File

@ -14,7 +14,7 @@ interface Principal;
[Exposed=(Window,Worker), [Exposed=(Window,Worker),
ChromeConstructor(CacheStorageNamespace namespace, Principal principal), ChromeConstructor(CacheStorageNamespace namespace, Principal principal),
Func="mozilla::dom::DOMPreferences::DOMCachesEnabled"] Func="mozilla::dom::cache::CacheStorage::PrefEnabled"]
interface CacheStorage { interface CacheStorage {
[NewObject] [NewObject]
Promise<Response> match(RequestInfo request, optional CacheQueryOptions options); Promise<Response> match(RequestInfo request, optional CacheQueryOptions options);

View File

@ -16,7 +16,7 @@ enum FetchState {
}; };
[Exposed=(Window,Worker), [Exposed=(Window,Worker),
Func="mozilla::dom::DOMPreferences::FetchObserverEnabled"] Func="FetchObserver::IsEnabled"]
interface FetchObserver : EventTarget { interface FetchObserver : EventTarget {
readonly attribute FetchState state; readonly attribute FetchState state;

View File

@ -34,7 +34,7 @@ partial interface File {
[GetterThrows, Deprecated="FileLastModifiedDate"] [GetterThrows, Deprecated="FileLastModifiedDate"]
readonly attribute Date lastModifiedDate; readonly attribute Date lastModifiedDate;
[BinaryName="relativePath", Func="mozilla::dom::DOMPreferences::WebkitBlinkDirectoryPickerEnabled"] [BinaryName="relativePath", Func="mozilla::dom::Directory::WebkitBlinkDirectoryPickerEnabled"]
readonly attribute USVString webkitRelativePath; readonly attribute USVString webkitRelativePath;
[GetterThrows, ChromeOnly, NeedsCallerType] [GetterThrows, ChromeOnly, NeedsCallerType]

View File

@ -403,10 +403,10 @@ dictionary ChannelPixelLayout {
typedef sequence<ChannelPixelLayout> ImagePixelLayout; typedef sequence<ChannelPixelLayout> ImagePixelLayout;
partial interface ImageBitmap { partial interface ImageBitmap {
[Throws, Func="mozilla::dom::DOMPreferences::ImageBitmapExtensionsEnabled"] [Throws, Func="mozilla::dom::ImageBitmap::ExtensionsEnabled"]
ImageBitmapFormat findOptimalFormat (optional sequence<ImageBitmapFormat> aPossibleFormats); ImageBitmapFormat findOptimalFormat (optional sequence<ImageBitmapFormat> aPossibleFormats);
[Throws, Func="mozilla::dom::DOMPreferences::ImageBitmapExtensionsEnabled"] [Throws, Func="mozilla::dom::ImageBitmap::ExtensionsEnabled"]
long mappedDataLength (ImageBitmapFormat aFormat); long mappedDataLength (ImageBitmapFormat aFormat);
[Throws, Func="mozilla::dom::DOMPreferences::ImageBitmapExtensionsEnabled"] [Throws, Func="mozilla::dom::ImageBitmap::ExtensionsEnabled"]
Promise<ImagePixelLayout> mapDataInto (ImageBitmapFormat aFormat, BufferSource aBuffer, long aOffset); Promise<ImagePixelLayout> mapDataInto (ImageBitmapFormat aFormat, BufferSource aBuffer, long aOffset);
}; };

View File

@ -89,7 +89,7 @@ interface NavigatorContentUtils {
[SecureContext, NoInterfaceObject, Exposed=(Window,Worker)] [SecureContext, NoInterfaceObject, Exposed=(Window,Worker)]
interface NavigatorStorage { interface NavigatorStorage {
[Func="mozilla::dom::DOMPreferences::StorageManagerEnabled"] [Func="mozilla::dom::StorageManager::PrefEnabled"]
readonly attribute StorageManager storage; readonly attribute StorageManager storage;
}; };

View File

@ -18,7 +18,7 @@ enum ConnectionType {
"unknown" "unknown"
}; };
[Func="mozilla::dom::DOMPreferences::NetworkInformationEnabled", [Func="mozilla::dom::network::Connection::IsEnabled",
Exposed=(Window,Worker)] Exposed=(Window,Worker)]
interface NetworkInformation : EventTarget { interface NetworkInformation : EventTarget {
readonly attribute ConnectionType type; readonly attribute ConnectionType type;

View File

@ -51,7 +51,7 @@ interface Notification : EventTarget {
[Pure] [Pure]
readonly attribute DOMString? icon; readonly attribute DOMString? icon;
[Constant, Func="mozilla::dom::DOMPreferences::NotificationRIEnabled"] [Constant, Func="mozilla::dom::Notification::RequireInteractionEnabled"]
readonly attribute boolean requireInteraction; readonly attribute boolean requireInteraction;
[Constant] [Constant]

View File

@ -9,7 +9,7 @@
[Constructor(unsigned long width, unsigned long height), [Constructor(unsigned long width, unsigned long height),
Exposed=(Window,Worker), Exposed=(Window,Worker),
Func="mozilla::dom::DOMPreferences::OffscreenCanvasEnabled"] Func="mozilla::dom::OffscreenCanvas::PrefEnabled"]
interface OffscreenCanvas : EventTarget { interface OffscreenCanvas : EventTarget {
[Pure, SetterThrows] [Pure, SetterThrows]
attribute unsigned long width; attribute unsigned long width;

View File

@ -6,7 +6,7 @@
[Constructor(DOMString type, PromiseRejectionEventInit eventInitDict), [Constructor(DOMString type, PromiseRejectionEventInit eventInitDict),
Exposed=(Window,Worker), Exposed=(Window,Worker),
Func="mozilla::dom::DOMPreferences::PromiseRejectionEventsEnabled"] Func="nsContentUtils::PromiseRejectionEventsEnabled"]
interface PromiseRejectionEvent : Event interface PromiseRejectionEvent : Event
{ {
[BinaryName="rejectedPromise"] [BinaryName="rejectedPromise"]

View File

@ -8,7 +8,7 @@
*/ */
[Constructor(DOMString type, optional PushEventInit eventInitDict), [Constructor(DOMString type, optional PushEventInit eventInitDict),
Func="mozilla::dom::DOMPreferences::PushEnabled", Func="nsContentUtils::PushEnabled",
Exposed=ServiceWorker] Exposed=ServiceWorker]
interface PushEvent : ExtendableEvent { interface PushEvent : ExtendableEvent {
readonly attribute PushMessageData? data; readonly attribute PushMessageData? data;

View File

@ -22,7 +22,7 @@ interface PushManagerImpl {
Promise<PushPermissionState> permissionState(optional PushSubscriptionOptionsInit options); Promise<PushPermissionState> permissionState(optional PushSubscriptionOptionsInit options);
}; };
[Exposed=(Window,Worker), Func="mozilla::dom::DOMPreferences::PushEnabled", [Exposed=(Window,Worker), Func="nsContentUtils::PushEnabled",
ChromeConstructor(DOMString scope)] ChromeConstructor(DOMString scope)]
interface PushManager { interface PushManager {
[Throws, UseCounter] [Throws, UseCounter]

View File

@ -7,7 +7,7 @@
* https://w3c.github.io/push-api/ * https://w3c.github.io/push-api/
*/ */
[Func="mozilla::dom::DOMPreferences::PushEnabled", [Func="nsContentUtils::PushEnabled",
Exposed=ServiceWorker] Exposed=ServiceWorker]
interface PushMessageData interface PushMessageData
{ {

View File

@ -36,7 +36,7 @@ dictionary PushSubscriptionInit
BufferSource? appServerKey; BufferSource? appServerKey;
}; };
[Exposed=(Window,Worker), Func="mozilla::dom::DOMPreferences::PushEnabled", [Exposed=(Window,Worker), Func="nsContentUtils::PushEnabled",
ChromeConstructor(PushSubscriptionInit initDict)] ChromeConstructor(PushSubscriptionInit initDict)]
interface PushSubscription interface PushSubscription
{ {

View File

@ -7,7 +7,7 @@
* https://w3c.github.io/push-api/ * https://w3c.github.io/push-api/
*/ */
[Exposed=(Window,Worker), Func="mozilla::dom::DOMPreferences::PushEnabled"] [Exposed=(Window,Worker), Func="nsContentUtils::PushEnabled"]
interface PushSubscriptionOptions interface PushSubscriptionOptions
{ {
[SameObject, Throws] [SameObject, Throws]

View File

@ -17,7 +17,7 @@ interface Request {
readonly attribute USVString url; readonly attribute USVString url;
[SameObject] readonly attribute Headers headers; [SameObject] readonly attribute Headers headers;
[Func="mozilla::dom::DOMPreferences::RequestContextEnabled"] [Func="mozilla::dom::Request::RequestContextEnabled"]
readonly attribute RequestContext context; readonly attribute RequestContext context;
readonly attribute USVString referrer; readonly attribute USVString referrer;
readonly attribute ReferrerPolicy referrerPolicy; readonly attribute ReferrerPolicy referrerPolicy;
@ -61,7 +61,7 @@ dictionary RequestInit {
AbortSignal? signal; AbortSignal? signal;
[Func="mozilla::dom::DOMPreferences::FetchObserverEnabled"] [Func="FetchObserver::IsEnabled"]
ObserverCallback observe; ObserverCallback observe;
}; };

View File

@ -35,7 +35,7 @@ Response implements Body;
// This should be part of Body but we don't want to expose body to request yet. // This should be part of Body but we don't want to expose body to request yet.
// See bug 1387483. // See bug 1387483.
partial interface Response { partial interface Response {
[GetterThrows, Func="mozilla::dom::DOMPreferences::StreamsEnabled"] [GetterThrows, Func="nsContentUtils::StreamsEnabled"]
readonly attribute ReadableStream? body; readonly attribute ReadableStream? body;
}; };

View File

@ -9,7 +9,7 @@
* https://notifications.spec.whatwg.org/ * https://notifications.spec.whatwg.org/
*/ */
[Func="mozilla::dom::DOMPreferences::ServiceWorkersEnabled", [Func="mozilla::dom::ServiceWorkerRegistration::Visible",
Exposed=(Window,Worker)] Exposed=(Window,Worker)]
interface ServiceWorkerRegistration : EventTarget { interface ServiceWorkerRegistration : EventTarget {
[Unforgeable] readonly attribute ServiceWorker? installing; [Unforgeable] readonly attribute ServiceWorker? installing;
@ -38,14 +38,14 @@ enum ServiceWorkerUpdateViaCache {
// https://w3c.github.io/push-api/ // https://w3c.github.io/push-api/
partial interface ServiceWorkerRegistration { partial interface ServiceWorkerRegistration {
[Throws, Exposed=(Window,Worker), Func="mozilla::dom::DOMPreferences::PushEnabled"] [Throws, Exposed=(Window,Worker), Func="nsContentUtils::PushEnabled"]
readonly attribute PushManager pushManager; readonly attribute PushManager pushManager;
}; };
// https://notifications.spec.whatwg.org/ // https://notifications.spec.whatwg.org/
partial interface ServiceWorkerRegistration { partial interface ServiceWorkerRegistration {
[Throws, Func="mozilla::dom::DOMPreferences::NotificationEnabledInServiceWorkers"] [Throws, Func="mozilla::dom::ServiceWorkerRegistration::NotificationAPIVisible"]
Promise<void> showNotification(DOMString title, optional NotificationOptions options); Promise<void> showNotification(DOMString title, optional NotificationOptions options);
[Throws, Func="mozilla::dom::DOMPreferences::NotificationEnabledInServiceWorkers"] [Throws, Func="mozilla::dom::ServiceWorkerRegistration::NotificationAPIVisible"]
Promise<sequence<Notification>> getNotifications(optional GetNotificationOptions filter); Promise<sequence<Notification>> getNotifications(optional GetNotificationOptions filter);
}; };

View File

@ -10,7 +10,7 @@
[SecureContext, [SecureContext,
Exposed=(Window,Worker), Exposed=(Window,Worker),
Func="mozilla::dom::DOMPreferences::StorageManagerEnabled"] Func="mozilla::dom::StorageManager::PrefEnabled"]
interface StorageManager { interface StorageManager {
[Throws] [Throws]
Promise<boolean> persisted(); Promise<boolean> persisted();

View File

@ -803,7 +803,7 @@ WebGLRenderingContext implements WebGLRenderingContextBase;
// Reference: https://wiki.whatwg.org/wiki/OffscreenCanvas // Reference: https://wiki.whatwg.org/wiki/OffscreenCanvas
[Exposed=(Window,Worker)] [Exposed=(Window,Worker)]
partial interface WebGLRenderingContext { partial interface WebGLRenderingContext {
[Func="mozilla::dom::DOMPreferences::OffscreenCanvasEnabled"] [Func="mozilla::dom::OffscreenCanvas::PrefEnabled"]
void commit(); void commit();
}; };

View File

@ -62,7 +62,7 @@ partial interface WindowOrWorkerGlobalScope {
// https://w3c.github.io/ServiceWorker/#self-caches // https://w3c.github.io/ServiceWorker/#self-caches
partial interface WindowOrWorkerGlobalScope { partial interface WindowOrWorkerGlobalScope {
[Throws, Func="mozilla::dom::DOMPreferences::DOMCachesEnabled", SameObject] [Throws, Func="mozilla::dom::cache::CacheStorage::PrefEnabled", SameObject]
readonly attribute CacheStorage caches; readonly attribute CacheStorage caches;
}; };

View File

@ -16,6 +16,6 @@ WorkerNavigator implements NavigatorStorage;
// http://wicg.github.io/netinfo/#extensions-to-the-navigator-interface // http://wicg.github.io/netinfo/#extensions-to-the-navigator-interface
[Exposed=(Worker)] [Exposed=(Worker)]
partial interface WorkerNavigator { partial interface WorkerNavigator {
[Func="mozilla::dom::DOMPreferences::NetworkInformationEnabled", Throws] [Func="mozilla::dom::network::Connection::IsEnabled", Throws]
readonly attribute NetworkInformation connection; readonly attribute NetworkInformation connection;
}; };

View File

@ -1442,6 +1442,7 @@ struct RuntimeService::IdleThreadInfo
// This is only touched on the main thread. Initialized in Init() below. // This is only touched on the main thread. Initialized in Init() below.
JSSettings RuntimeService::sDefaultJSSettings; JSSettings RuntimeService::sDefaultJSSettings;
bool RuntimeService::sDefaultPreferences[WORKERPREF_COUNT] = { false };
RuntimeService::RuntimeService() RuntimeService::RuntimeService()
: mMutex("RuntimeService::mMutex"), mObserved(false), : mMutex("RuntimeService::mMutex"), mObserved(false),
@ -1965,17 +1966,17 @@ RuntimeService::Init()
PREF_JS_OPTIONS_PREFIX PREF_GCZEAL)) || PREF_JS_OPTIONS_PREFIX PREF_GCZEAL)) ||
#endif #endif
#define WORKER_SIMPLE_PREF(name, getter, NAME) \
NS_FAILED(Preferences::RegisterCallbackAndCall( \
WorkerPrefChanged, \
name, \
reinterpret_cast<void*>(WORKERPREF_##NAME))) ||
#define WORKER_PREF(name, callback) \ #define WORKER_PREF(name, callback) \
NS_FAILED(Preferences::RegisterCallbackAndCall( \ NS_FAILED(Preferences::RegisterCallbackAndCall( \
callback, \ callback, \
name)) || name)) ||
WORKER_PREF("intl.accept_languages", PrefLanguagesChanged) #include "WorkerPrefs.h"
WORKER_PREF("general.appname.override", AppNameOverrideChanged) #undef WORKER_SIMPLE_PREF
WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
WORKER_PREF("general.platform.override", PlatformOverrideChanged)
#ifdef JS_GC_ZEAL
WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)
#endif
#undef WORKER_PREF #undef WORKER_PREF
NS_FAILED(Preferences::RegisterPrefixCallbackAndCall( NS_FAILED(Preferences::RegisterPrefixCallbackAndCall(
@ -2261,17 +2262,17 @@ RuntimeService::Cleanup()
NS_FAILED(Preferences::UnregisterPrefixCallback(LoadContextOptions, NS_FAILED(Preferences::UnregisterPrefixCallback(LoadContextOptions,
PREF_WORKERS_OPTIONS_PREFIX)) || PREF_WORKERS_OPTIONS_PREFIX)) ||
#define WORKER_SIMPLE_PREF(name, getter, NAME) \
NS_FAILED(Preferences::UnregisterCallback( \
WorkerPrefChanged, \
name, \
reinterpret_cast<void*>(WORKERPREF_##NAME))) ||
#define WORKER_PREF(name, callback) \ #define WORKER_PREF(name, callback) \
NS_FAILED(Preferences::UnregisterCallback( \ NS_FAILED(Preferences::UnregisterCallback( \
callback, \ callback, \
name)) || name)) ||
WORKER_PREF("intl.accept_languages", PrefLanguagesChanged) #include "WorkerPrefs.h"
WORKER_PREF("general.appname.override", AppNameOverrideChanged) #undef WORKER_SIMPLE_PREF
WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
WORKER_PREF("general.platform.override", PlatformOverrideChanged)
#ifdef JS_GC_ZEAL
WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)
#endif
#undef WORKER_PREF #undef WORKER_PREF
#ifdef JS_GC_ZEAL #ifdef JS_GC_ZEAL
@ -2671,6 +2672,12 @@ RuntimeService::UpdatePlatformOverridePreference(const nsAString& aValue)
mNavigatorProperties.mPlatformOverridden = aValue; mNavigatorProperties.mPlatformOverridden = aValue;
} }
void
RuntimeService::UpdateAllWorkerPreference(WorkerPreference aPref, bool aValue)
{
BROADCAST_ALL_WORKERS(UpdatePreference, aPref, aValue);
}
void void
RuntimeService::UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages) RuntimeService::UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages)
{ {
@ -2790,6 +2797,34 @@ RuntimeService::Observe(nsISupports* aSubject, const char* aTopic,
return NS_OK; return NS_OK;
} }
/* static */ void
RuntimeService::WorkerPrefChanged(const char* aPrefName, void* aClosure)
{
AssertIsOnMainThread();
const WorkerPreference key =
static_cast<WorkerPreference>(reinterpret_cast<uintptr_t>(aClosure));
switch (key) {
#define WORKER_SIMPLE_PREF(name, getter, NAME) case WORKERPREF_##NAME:
#define WORKER_PREF(name, callback)
#include "WorkerPrefs.h"
#undef WORKER_SIMPLE_PREF
#undef WORKER_PREF
sDefaultPreferences[key] = Preferences::GetBool(aPrefName, false);
break;
default:
MOZ_ASSERT_UNREACHABLE("Invalid pref key");
break;
}
RuntimeService* rts = RuntimeService::GetService();
if (rts) {
rts->UpdateAllWorkerPreference(key, sDefaultPreferences[key]);
}
}
bool bool
LogViolationDetailsRunnable::MainThreadRun() LogViolationDetailsRunnable::MainThreadRun()
{ {

View File

@ -91,6 +91,7 @@ class RuntimeService final : public nsIObserver
nsCOMPtr<nsITimer> mIdleThreadTimer; nsCOMPtr<nsITimer> mIdleThreadTimer;
static JSSettings sDefaultJSSettings; static JSSettings sDefaultJSSettings;
static bool sDefaultPreferences[WORKERPREF_COUNT];
public: public:
struct NavigatorProperties struct NavigatorProperties
@ -172,6 +173,13 @@ public:
aSettings = sDefaultJSSettings; aSettings = sDefaultJSSettings;
} }
static void
GetDefaultPreferences(bool aPreferences[WORKERPREF_COUNT])
{
AssertIsOnMainThread();
memcpy(aPreferences, sDefaultPreferences, WORKERPREF_COUNT * sizeof(bool));
}
static void static void
SetDefaultContextOptions(const JS::ContextOptions& aContextOptions) SetDefaultContextOptions(const JS::ContextOptions& aContextOptions)
{ {
@ -194,6 +202,9 @@ public:
void void
UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages); UpdateAllWorkerLanguages(const nsTArray<nsString>& aLanguages);
void
UpdateAllWorkerPreference(WorkerPreference aPref, bool aValue);
static void static void
SetDefaultJSGCSettings(JSGCParamKey aKey, uint32_t aValue) SetDefaultJSGCSettings(JSGCParamKey aKey, uint32_t aValue)
{ {
@ -259,6 +270,9 @@ private:
static void static void
ShutdownIdleThreads(nsITimer* aTimer, void* aClosure); ShutdownIdleThreads(nsITimer* aTimer, void* aClosure);
static void
WorkerPrefChanged(const char* aPrefName, void* aClosure);
nsresult nsresult
CreateSharedWorkerFromLoadInfo(JSContext* aCx, CreateSharedWorkerFromLoadInfo(JSContext* aCx,
WorkerLoadInfo* aLoadInfo, WorkerLoadInfo* aLoadInfo,

View File

@ -12,7 +12,7 @@
#include "ServiceWorkerPrivate.h" #include "ServiceWorkerPrivate.h"
#include "WorkerPrivate.h" #include "WorkerPrivate.h"
#include "mozilla/dom/DOMPreferences.h" #include "mozilla/Preferences.h"
#include "mozilla/dom/ClientIPCTypes.h" #include "mozilla/dom/ClientIPCTypes.h"
#include "mozilla/dom/ClientState.h" #include "mozilla/dom/ClientState.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
@ -33,7 +33,7 @@ bool
ServiceWorkerVisible(JSContext* aCx, JSObject* aObj) ServiceWorkerVisible(JSContext* aCx, JSObject* aObj)
{ {
if (NS_IsMainThread()) { if (NS_IsMainThread()) {
return DOMPreferences::ServiceWorkersEnabled(); return Preferences::GetBool("dom.serviceWorkers.enabled", false);
} }
return IS_INSTANCE_OF(ServiceWorkerGlobalScope, aObj); return IS_INSTANCE_OF(ServiceWorkerGlobalScope, aObj);

View File

@ -12,12 +12,12 @@
#include "nsIURL.h" #include "nsIURL.h"
#include "nsNetUtil.h" #include "nsNetUtil.h"
#include "nsPIDOMWindow.h" #include "nsPIDOMWindow.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
#include "nsServiceManagerUtils.h" #include "nsServiceManagerUtils.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/Navigator.h" #include "mozilla/dom/Navigator.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "mozilla/dom/ServiceWorkerContainerBinding.h" #include "mozilla/dom/ServiceWorkerContainerBinding.h"
@ -53,7 +53,7 @@ ServiceWorkerContainer::IsEnabled(JSContext* aCx, JSObject* aGlobal)
return false; return false;
} }
return DOMPreferences::ServiceWorkersEnabled(); return Preferences::GetBool("dom.serviceWorkers.enabled", false);
} }
ServiceWorkerContainer::ServiceWorkerContainer(nsPIDOMWindowInner* aWindow) ServiceWorkerContainer::ServiceWorkerContainer(nsPIDOMWindowInner* aWindow)

View File

@ -40,7 +40,6 @@
#include "mozilla/dom/ClientHandle.h" #include "mozilla/dom/ClientHandle.h"
#include "mozilla/dom/ClientManager.h" #include "mozilla/dom/ClientManager.h"
#include "mozilla/dom/ContentParent.h" #include "mozilla/dom/ContentParent.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/ErrorEvent.h" #include "mozilla/dom/ErrorEvent.h"
#include "mozilla/dom/Headers.h" #include "mozilla/dom/Headers.h"
#include "mozilla/dom/InternalHeaders.h" #include "mozilla/dom/InternalHeaders.h"
@ -757,7 +756,7 @@ ServiceWorkerManager::Register(mozIDOMWindow* aWindow,
outerWindow->GetServiceWorkersTestingEnabled(); outerWindow->GetServiceWorkersTestingEnabled();
bool authenticatedOrigin; bool authenticatedOrigin;
if (DOMPreferences::ServiceWorkersTestingEnabled() || if (Preferences::GetBool("dom.serviceWorkers.testing.enabled") ||
serviceWorkersTestingEnabled) { serviceWorkersTestingEnabled) {
authenticatedOrigin = true; authenticatedOrigin = true;
} else { } else {

View File

@ -25,7 +25,6 @@
#include "WorkerRunnable.h" #include "WorkerRunnable.h"
#include "WorkerScope.h" #include "WorkerScope.h"
#include "mozilla/Assertions.h" #include "mozilla/Assertions.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/Client.h" #include "mozilla/dom/Client.h"
#include "mozilla/dom/ClientIPCTypes.h" #include "mozilla/dom/ClientIPCTypes.h"
#include "mozilla/dom/FetchUtil.h" #include "mozilla/dom/FetchUtil.h"
@ -1958,7 +1957,7 @@ ServiceWorkerPrivate::TerminateWorker()
mIdleWorkerTimer->Cancel(); mIdleWorkerTimer->Cancel();
mIdleKeepAliveToken = nullptr; mIdleKeepAliveToken = nullptr;
if (mWorkerPrivate) { if (mWorkerPrivate) {
if (DOMPreferences::ServiceWorkersTestingEnabled()) { if (Preferences::GetBool("dom.serviceWorkers.testing.enabled")) {
nsCOMPtr<nsIObserverService> os = services::GetObserverService(); nsCOMPtr<nsIObserverService> os = services::GetObserverService();
if (os) { if (os) {
os->NotifyObservers(nullptr, "service-worker-shutdown", nullptr); os->NotifyObservers(nullptr, "service-worker-shutdown", nullptr);

View File

@ -7,7 +7,6 @@
#include "ServiceWorkerRegistration.h" #include "ServiceWorkerRegistration.h"
#include "ipc/ErrorIPCUtils.h" #include "ipc/ErrorIPCUtils.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/Notification.h" #include "mozilla/dom/Notification.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseWindowProxy.h" #include "mozilla/dom/PromiseWindowProxy.h"
@ -15,6 +14,7 @@
#include "mozilla/dom/PushManagerBinding.h" #include "mozilla/dom/PushManagerBinding.h"
#include "mozilla/dom/PushManager.h" #include "mozilla/dom/PushManager.h"
#include "mozilla/dom/ServiceWorkerRegistrationBinding.h" #include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
#include "mozilla/Preferences.h"
#include "mozilla/Services.h" #include "mozilla/Services.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
#include "nsCycleCollectionParticipant.h" #include "nsCycleCollectionParticipant.h"
@ -38,6 +38,38 @@ using namespace mozilla::dom::workers;
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
/* static */ bool
ServiceWorkerRegistration::Visible(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.serviceWorkers.enabled", false);
}
// Otherwise check the pref via the work private helper
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->ServiceWorkersEnabled();
}
/* static */ bool
ServiceWorkerRegistration::NotificationAPIVisible(JSContext* aCx, JSObject* aObj)
{
if (NS_IsMainThread()) {
return Preferences::GetBool("dom.webnotifications.serviceworker.enabled", false);
}
// Otherwise check the pref via the work private helper
WorkerPrivate* workerPrivate = GetWorkerPrivateFromContext(aCx);
if (!workerPrivate) {
return false;
}
return workerPrivate->DOMServiceWorkerNotificationEnabled();
}
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
// Main Thread implementation // Main Thread implementation

View File

@ -8,11 +8,11 @@
#define mozilla_dom_ServiceWorkerRegistration_h #define mozilla_dom_ServiceWorkerRegistration_h
#include "mozilla/DOMEventTargetHelper.h" #include "mozilla/DOMEventTargetHelper.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/ServiceWorkerBinding.h" #include "mozilla/dom/ServiceWorkerBinding.h"
#include "mozilla/dom/ServiceWorkerCommon.h" #include "mozilla/dom/ServiceWorkerCommon.h"
#include "mozilla/dom/ServiceWorkerRegistrationBinding.h" #include "mozilla/dom/ServiceWorkerRegistrationBinding.h"
#include "mozilla/dom/workers/bindings/WorkerHolder.h" #include "mozilla/dom/workers/bindings/WorkerHolder.h"
#include "nsContentUtils.h" // Required for nsContentUtils::PushEnabled
// Support for Notification API extension. // Support for Notification API extension.
#include "mozilla/dom/NotificationBinding.h" #include "mozilla/dom/NotificationBinding.h"
@ -61,6 +61,13 @@ public:
IMPL_EVENT_HANDLER(updatefound) IMPL_EVENT_HANDLER(updatefound)
static bool
Visible(JSContext* aCx, JSObject* aObj);
static bool
NotificationAPIVisible(JSContext* aCx, JSObject* aObj);
static already_AddRefed<ServiceWorkerRegistration> static already_AddRefed<ServiceWorkerRegistration>
CreateForMainThread(nsPIDOMWindowInner* aWindow, CreateForMainThread(nsPIDOMWindowInner* aWindow,
const nsAString& aScope); const nsAString& aScope);

View File

@ -5,7 +5,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseWorkerProxy.h" #include "mozilla/dom/PromiseWorkerProxy.h"
#include "mozilla/dom/StorageManager.h" #include "mozilla/dom/StorageManager.h"
@ -82,11 +81,11 @@ WorkerNavigator::GetAppName(nsString& aAppName, CallerType aCallerType) const
MOZ_ASSERT(workerPrivate); MOZ_ASSERT(workerPrivate);
if ((!mProperties.mAppNameOverridden.IsEmpty() || if ((!mProperties.mAppNameOverridden.IsEmpty() ||
DOMPreferences::ResistFingerprintingEnabled()) && workerPrivate->ResistFingerprintingEnabled()) &&
!workerPrivate->UsesSystemPrincipal()) { !workerPrivate->UsesSystemPrincipal()) {
// We will spoof this value when 'privacy.resistFingerprinting' is true. // We will spoof this value when 'privacy.resistFingerprinting' is true.
// See nsRFPService.h for spoofed value. // See nsRFPService.h for spoofed value.
aAppName = DOMPreferences::ResistFingerprintingEnabled() ? aAppName = workerPrivate->ResistFingerprintingEnabled() ?
NS_LITERAL_STRING(SPOOFED_APPNAME) : mProperties.mAppNameOverridden; NS_LITERAL_STRING(SPOOFED_APPNAME) : mProperties.mAppNameOverridden;
} else { } else {
aAppName = mProperties.mAppName; aAppName = mProperties.mAppName;
@ -101,11 +100,11 @@ WorkerNavigator::GetAppVersion(nsString& aAppVersion, CallerType aCallerType,
MOZ_ASSERT(workerPrivate); MOZ_ASSERT(workerPrivate);
if ((!mProperties.mAppVersionOverridden.IsEmpty() || if ((!mProperties.mAppVersionOverridden.IsEmpty() ||
DOMPreferences::ResistFingerprintingEnabled()) && workerPrivate->ResistFingerprintingEnabled()) &&
!workerPrivate->UsesSystemPrincipal()) { !workerPrivate->UsesSystemPrincipal()) {
// We will spoof this value when 'privacy.resistFingerprinting' is true. // We will spoof this value when 'privacy.resistFingerprinting' is true.
// See nsRFPService.h for spoofed value. // See nsRFPService.h for spoofed value.
aAppVersion = DOMPreferences::ResistFingerprintingEnabled() ? aAppVersion = workerPrivate->ResistFingerprintingEnabled() ?
NS_LITERAL_STRING(SPOOFED_APPVERSION) : mProperties.mAppVersionOverridden; NS_LITERAL_STRING(SPOOFED_APPVERSION) : mProperties.mAppVersionOverridden;
} else { } else {
aAppVersion = mProperties.mAppVersion; aAppVersion = mProperties.mAppVersion;
@ -120,11 +119,11 @@ WorkerNavigator::GetPlatform(nsString& aPlatform, CallerType aCallerType,
MOZ_ASSERT(workerPrivate); MOZ_ASSERT(workerPrivate);
if ((!mProperties.mPlatformOverridden.IsEmpty() || if ((!mProperties.mPlatformOverridden.IsEmpty() ||
DOMPreferences::ResistFingerprintingEnabled()) && workerPrivate->ResistFingerprintingEnabled()) &&
!workerPrivate->UsesSystemPrincipal()) { !workerPrivate->UsesSystemPrincipal()) {
// We will spoof this value when 'privacy.resistFingerprinting' is true. // We will spoof this value when 'privacy.resistFingerprinting' is true.
// See nsRFPService.h for spoofed value. // See nsRFPService.h for spoofed value.
aPlatform = DOMPreferences::ResistFingerprintingEnabled() ? aPlatform = workerPrivate->ResistFingerprintingEnabled() ?
NS_LITERAL_STRING(SPOOFED_PLATFORM) : mProperties.mPlatformOverridden; NS_LITERAL_STRING(SPOOFED_PLATFORM) : mProperties.mPlatformOverridden;
} else { } else {
aPlatform = mProperties.mPlatform; aPlatform = mProperties.mPlatform;

53
dom/workers/WorkerPrefs.h Normal file
View File

@ -0,0 +1,53 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// This is the list of the preferences that are exposed to workers.
// The format is as follows:
//
// WORKER_SIMPLE_PREF("foo.bar", FooBar, FOO_BAR, UpdaterFunction)
//
// * First argument is the name of the pref.
// * The name of the getter function. This defines a FindName()
// function that returns the value of the pref on WorkerPrivate.
// * The macro version of the name. This defines a WORKERPREF_FOO_BAR
// macro in Workers.h.
// * The name of the function that updates the new value of a pref.
//
// WORKER_PREF("foo.bar", UpdaterFunction)
//
// * First argument is the name of the pref.
// * The name of the function that updates the new value of a pref.
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
WORKER_SIMPLE_PREF("browser.dom.window.dump.enabled", DumpEnabled, DUMP)
#endif
WORKER_SIMPLE_PREF("canvas.imagebitmap_extensions.enabled", ImageBitmapExtensionsEnabled, IMAGEBITMAP_EXTENSIONS_ENABLED)
WORKER_SIMPLE_PREF("dom.caches.enabled", DOMCachesEnabled, DOM_CACHES)
WORKER_SIMPLE_PREF("dom.caches.testing.enabled", DOMCachesTestingEnabled, DOM_CACHES_TESTING)
WORKER_SIMPLE_PREF("dom.performance.enable_user_timing_logging", PerformanceLoggingEnabled, PERFORMANCE_LOGGING_ENABLED)
WORKER_SIMPLE_PREF("dom.webnotifications.enabled", DOMWorkerNotificationEnabled, DOM_WORKERNOTIFICATION)
WORKER_SIMPLE_PREF("dom.webnotifications.serviceworker.enabled", DOMServiceWorkerNotificationEnabled, DOM_SERVICEWORKERNOTIFICATION)
WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerNotificationRIEnabled, DOM_WORKERNOTIFICATIONRI)
WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
WORKER_SIMPLE_PREF("dom.promise_rejection_events.enabled", PromiseRejectionEventsEnabled, PROMISE_REJECTION_EVENTS_ENABLED)
WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
WORKER_SIMPLE_PREF("dom.streams.enabled", StreamsEnabled, STREAMS_ENABLED)
WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)
WORKER_SIMPLE_PREF("dom.webkitBlink.dirPicker.enabled", WebkitBlinkDirectoryPickerEnabled, DOM_WEBKITBLINK_DIRPICKER_WEBKITBLINK)
WORKER_SIMPLE_PREF("dom.netinfo.enabled", NetworkInformationEnabled, NETWORKINFORMATION_ENABLED)
WORKER_SIMPLE_PREF("dom.fetchObserver.enabled", FetchObserverEnabled, FETCHOBSERVER_ENABLED)
WORKER_SIMPLE_PREF("privacy.resistFingerprinting", ResistFingerprintingEnabled, RESISTFINGERPRINTING_ENABLED)
WORKER_SIMPLE_PREF("devtools.enabled", DevToolsEnabled, DEVTOOLS_ENABLED)
WORKER_PREF("intl.accept_languages", PrefLanguagesChanged)
WORKER_PREF("general.appname.override", AppNameOverrideChanged)
WORKER_PREF("general.appversion.override", AppVersionOverrideChanged)
WORKER_PREF("general.platform.override", PlatformOverrideChanged)
#ifdef JS_GC_ZEAL
WORKER_PREF("dom.workers.options.gcZeal", LoadGCZealOptions)
#endif

View File

@ -1377,6 +1377,28 @@ private:
} }
}; };
class UpdatePreferenceRunnable final : public WorkerControlRunnable
{
WorkerPreference mPref;
bool mValue;
public:
UpdatePreferenceRunnable(WorkerPrivate* aWorkerPrivate,
WorkerPreference aPref,
bool aValue)
: WorkerControlRunnable(aWorkerPrivate, WorkerThreadUnchangedBusyCount),
mPref(aPref),
mValue(aValue)
{ }
virtual bool
WorkerRun(JSContext* aCx, WorkerPrivate* aWorkerPrivate) override
{
aWorkerPrivate->UpdatePreferenceInternal(mPref, mValue);
return true;
}
};
class UpdateLanguagesRunnable final : public WorkerRunnable class UpdateLanguagesRunnable final : public WorkerRunnable
{ {
nsTArray<nsString> mLanguages; nsTArray<nsString> mLanguages;
@ -3490,6 +3512,20 @@ WorkerPrivateParent<Derived>::UpdateContextOptions(
} }
} }
template <class Derived>
void
WorkerPrivateParent<Derived>::UpdatePreference(WorkerPreference aPref, bool aValue)
{
AssertIsOnParentThread();
MOZ_ASSERT(aPref >= 0 && aPref < WORKERPREF_COUNT);
RefPtr<UpdatePreferenceRunnable> runnable =
new UpdatePreferenceRunnable(ParentAsWorkerPrivate(), aPref, aValue);
if (!runnable->Dispatch()) {
NS_WARNING("Failed to update worker preferences!");
}
}
template <class Derived> template <class Derived>
void void
WorkerPrivateParent<Derived>::UpdateLanguages(const nsTArray<nsString>& aLanguages) WorkerPrivateParent<Derived>::UpdateLanguages(const nsTArray<nsString>& aLanguages)
@ -4504,10 +4540,12 @@ WorkerPrivate::WorkerPrivate(WorkerPrivate* aParent,
{ {
if (aParent) { if (aParent) {
aParent->AssertIsOnWorkerThread(); aParent->AssertIsOnWorkerThread();
aParent->GetAllPreferences(mPreferences);
mOnLine = aParent->OnLine(); mOnLine = aParent->OnLine();
} }
else { else {
AssertIsOnMainThread(); AssertIsOnMainThread();
RuntimeService::GetDefaultPreferences(mPreferences);
mOnLine = !NS_IsOffline(); mOnLine = !NS_IsOffline();
} }
@ -6825,6 +6863,19 @@ WorkerPrivate::UpdateLanguagesInternal(const nsTArray<nsString>& aLanguages)
} }
} }
void
WorkerPrivate::UpdatePreferenceInternal(WorkerPreference aPref, bool aValue)
{
AssertIsOnWorkerThread();
MOZ_ASSERT(aPref >= 0 && aPref < WORKERPREF_COUNT);
mPreferences[aPref] = aValue;
for (uint32_t index = 0; index < mChildWorkers.Length(); index++) {
mChildWorkers[index]->UpdatePreference(aPref, aValue);
}
}
void void
WorkerPrivate::UpdateJSWorkerMemoryParameterInternal(JSContext* aCx, WorkerPrivate::UpdateJSWorkerMemoryParameterInternal(JSContext* aCx,
JSGCParamKey aKey, JSGCParamKey aKey,

View File

@ -409,6 +409,9 @@ public:
void void
UpdateLanguages(const nsTArray<nsString>& aLanguages); UpdateLanguages(const nsTArray<nsString>& aLanguages);
void
UpdatePreference(WorkerPreference aPref, bool aValue);
void void
UpdateJSWorkerMemoryParameter(JSGCParamKey key, uint32_t value); UpdateJSWorkerMemoryParameter(JSGCParamKey key, uint32_t value);
@ -1076,6 +1079,7 @@ class WorkerPrivate : public WorkerPrivateParent<WorkerPrivate>
bool mIdleGCTimerRunning; bool mIdleGCTimerRunning;
bool mWorkerScriptExecutedSuccessfully; bool mWorkerScriptExecutedSuccessfully;
bool mFetchHandlerWasAdded; bool mFetchHandlerWasAdded;
bool mPreferences[WORKERPREF_COUNT];
bool mOnLine; bool mOnLine;
protected: protected:
@ -1282,6 +1286,9 @@ public:
void void
UpdateLanguagesInternal(const nsTArray<nsString>& aLanguages); UpdateLanguagesInternal(const nsTArray<nsString>& aLanguages);
void
UpdatePreferenceInternal(WorkerPreference aPref, bool aValue);
void void
UpdateJSWorkerMemoryParameterInternal(JSContext* aCx, JSGCParamKey key, uint32_t aValue); UpdateJSWorkerMemoryParameterInternal(JSContext* aCx, JSGCParamKey key, uint32_t aValue);
@ -1404,6 +1411,18 @@ public:
bool bool
RegisterDebuggerBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal); RegisterDebuggerBindings(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
#define WORKER_SIMPLE_PREF(name, getter, NAME) \
bool \
getter() const \
{ \
AssertIsOnWorkerThread(); \
return mPreferences[WORKERPREF_##NAME]; \
}
#define WORKER_PREF(name, callback)
#include "WorkerPrefs.h"
#undef WORKER_SIMPLE_PREF
#undef WORKER_PREF
bool bool
OnLine() const OnLine() const
{ {
@ -1564,6 +1583,13 @@ private:
const Sequence<JSObject*>& aTransferable, const Sequence<JSObject*>& aTransferable,
ErrorResult& aRv); ErrorResult& aRv);
void
GetAllPreferences(bool aPreferences[WORKERPREF_COUNT]) const
{
AssertIsOnWorkerThread();
memcpy(aPreferences, mPreferences, WORKERPREF_COUNT * sizeof(bool));
}
// If the worker shutdown status is equal or greater then aFailStatus, this // If the worker shutdown status is equal or greater then aFailStatus, this
// operation will fail and nullptr will be returned. See WorkerHolder.h for // operation will fail and nullptr will be returned. See WorkerHolder.h for
// more information about the correct value to use. // more information about the correct value to use.

View File

@ -12,7 +12,6 @@
#include "mozilla/dom/Clients.h" #include "mozilla/dom/Clients.h"
#include "mozilla/dom/Console.h" #include "mozilla/dom/Console.h"
#include "mozilla/dom/DedicatedWorkerGlobalScopeBinding.h" #include "mozilla/dom/DedicatedWorkerGlobalScopeBinding.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/Fetch.h" #include "mozilla/dom/Fetch.h"
#include "mozilla/dom/FunctionBinding.h" #include "mozilla/dom/FunctionBinding.h"
#include "mozilla/dom/IDBFactory.h" #include "mozilla/dom/IDBFactory.h"
@ -371,7 +370,7 @@ WorkerGlobalScope::Dump(const Optional<nsAString>& aString) const
} }
#if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP)) #if !(defined(DEBUG) || defined(MOZ_ENABLE_JS_DUMP))
if (!DOMPreferences::DumpEnabled()) { if (!mWorkerPrivate->DumpEnabled()) {
return; return;
} }
#endif #endif
@ -480,7 +479,7 @@ WorkerGlobalScope::CreateImageBitmap(JSContext* aCx,
const Sequence<ChannelPixelLayout>& aLayout, const Sequence<ChannelPixelLayout>& aLayout,
ErrorResult& aRv) ErrorResult& aRv)
{ {
if (!DOMPreferences::ImageBitmapExtensionsEnabled()) { if (!ImageBitmap::ExtensionsEnabled(aCx)) {
aRv.Throw(NS_ERROR_TYPE_ERR); aRv.Throw(NS_ERROR_TYPE_ERR);
return nullptr; return nullptr;
} }

View File

@ -186,6 +186,16 @@ struct JSSettings
} }
}; };
enum WorkerPreference
{
#define WORKER_SIMPLE_PREF(name, getter, NAME) WORKERPREF_ ## NAME,
#define WORKER_PREF(name, callback)
#include "mozilla/dom/WorkerPrefs.h"
#undef WORKER_SIMPLE_PREF
#undef WORKER_PREF
WORKERPREF_COUNT
};
// Implemented in WorkerPrivate.cpp // Implemented in WorkerPrivate.cpp
struct WorkerLoadInfo struct WorkerLoadInfo

View File

@ -19,6 +19,7 @@ EXPORTS.mozilla.dom += [
'ServiceWorkerRegistration.h', 'ServiceWorkerRegistration.h',
'WorkerLocation.h', 'WorkerLocation.h',
'WorkerNavigator.h', 'WorkerNavigator.h',
'WorkerPrefs.h',
'WorkerPrivate.h', 'WorkerPrivate.h',
'WorkerRunnable.h', 'WorkerRunnable.h',
'WorkerScope.h', 'WorkerScope.h',

View File

@ -7,7 +7,7 @@
#include "WorkletGlobalScope.h" #include "WorkletGlobalScope.h"
#include "mozilla/dom/WorkletGlobalScopeBinding.h" #include "mozilla/dom/WorkletGlobalScopeBinding.h"
#include "mozilla/dom/Console.h" #include "mozilla/dom/Console.h"
#include "mozilla/dom/DOMPreferences.h" #include "nsContentUtils.h"
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -70,7 +70,7 @@ WorkletGlobalScope::GetConsole(ErrorResult& aRv)
void void
WorkletGlobalScope::Dump(const Optional<nsAString>& aString) const WorkletGlobalScope::Dump(const Optional<nsAString>& aString) const
{ {
if (!DOMPreferences::DumpEnabled()) { if (!nsContentUtils::DOMWindowDumpEnabled()) {
return; return;
} }

View File

@ -50,7 +50,6 @@
#include "mozilla/MacroForEach.h" #include "mozilla/MacroForEach.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
#include "mozilla/ScriptPreloader.h" #include "mozilla/ScriptPreloader.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/ScriptSettings.h" #include "mozilla/dom/ScriptSettings.h"
#include "mozilla/UniquePtrExtensions.h" #include "mozilla/UniquePtrExtensions.h"
#include "mozilla/Unused.h" #include "mozilla/Unused.h"
@ -89,7 +88,7 @@ static LazyLogModule gJSCLLog("JSComponentLoader");
static bool static bool
Dump(JSContext* cx, unsigned argc, Value* vp) Dump(JSContext* cx, unsigned argc, Value* vp)
{ {
if (!mozilla::dom::DOMPreferences::DumpEnabled()) { if (!nsContentUtils::DOMWindowDumpEnabled()) {
return true; return true;
} }

View File

@ -32,7 +32,6 @@
#include "mozilla/dom/cache/CacheStorage.h" #include "mozilla/dom/cache/CacheStorage.h"
#include "mozilla/dom/CSSBinding.h" #include "mozilla/dom/CSSBinding.h"
#include "mozilla/dom/DirectoryBinding.h" #include "mozilla/dom/DirectoryBinding.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/IndexedDatabaseManager.h" #include "mozilla/dom/IndexedDatabaseManager.h"
#include "mozilla/dom/Fetch.h" #include "mozilla/dom/Fetch.h"
#include "mozilla/dom/FileBinding.h" #include "mozilla/dom/FileBinding.h"
@ -115,7 +114,7 @@ xpc::NewSandboxConstructor()
static bool static bool
SandboxDump(JSContext* cx, unsigned argc, Value* vp) SandboxDump(JSContext* cx, unsigned argc, Value* vp)
{ {
if (!DOMPreferences::DumpEnabled()) { if (!nsContentUtils::DOMWindowDumpEnabled()) {
return true; return true;
} }

View File

@ -9,6 +9,7 @@
#include "xpcprivate.h" #include "xpcprivate.h"
#include "jsprf.h" #include "jsprf.h"
#include "nsArrayEnumerator.h" #include "nsArrayEnumerator.h"
#include "nsContentUtils.h"
#include "nsINamed.h" #include "nsINamed.h"
#include "nsIScriptError.h" #include "nsIScriptError.h"
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
@ -19,7 +20,6 @@
#include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/DOMException.h" #include "mozilla/dom/DOMException.h"
#include "mozilla/dom/DOMExceptionBinding.h" #include "mozilla/dom/DOMExceptionBinding.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/jsipc/CrossProcessObjectWrappers.h" #include "mozilla/jsipc/CrossProcessObjectWrappers.h"
#include "jsapi.h" #include "jsapi.h"
@ -948,7 +948,7 @@ nsXPCWrappedJSClass::CheckForException(XPCCallContext & ccx,
} }
if (reportable) { if (reportable) {
if (DOMPreferences::DumpEnabled()) { if (nsContentUtils::DOMWindowDumpEnabled()) {
static const char line[] = static const char line[] =
"************************************************************\n"; "************************************************************\n";
static const char preamble[] = static const char preamble[] =

View File

@ -23,7 +23,6 @@
#include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/DOMException.h" #include "mozilla/dom/DOMException.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/Exceptions.h" #include "mozilla/dom/Exceptions.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
@ -270,7 +269,7 @@ xpc::ErrorBase::AppendErrorDetailsTo(nsCString& error)
void void
xpc::ErrorNote::LogToStderr() xpc::ErrorNote::LogToStderr()
{ {
if (!DOMPreferences::DumpEnabled()) if (!nsContentUtils::DOMWindowDumpEnabled())
return; return;
nsAutoCString error; nsAutoCString error;
@ -284,7 +283,7 @@ xpc::ErrorNote::LogToStderr()
void void
xpc::ErrorReport::LogToStderr() xpc::ErrorReport::LogToStderr()
{ {
if (!DOMPreferences::DumpEnabled()) if (!nsContentUtils::DOMWindowDumpEnabled())
return; return;
nsAutoCString error; nsAutoCString error;

View File

@ -319,9 +319,6 @@ nsLayoutStatics::Initialize()
mozilla::dom::IPCBlobInputStreamStorage::Initialize(); mozilla::dom::IPCBlobInputStreamStorage::Initialize();
mozilla::dom::U2FTokenManager::Initialize(); mozilla::dom::U2FTokenManager::Initialize();
mozilla::dom::DOMPreferences::Initialize();
return NS_OK; return NS_OK;
} }

View File

@ -12,7 +12,6 @@
#include "mozilla/dom/NodeInfo.h" #include "mozilla/dom/NodeInfo.h"
#include "mozilla/dom/Element.h" #include "mozilla/dom/Element.h"
#include "mozilla/dom/DataTransfer.h" #include "mozilla/dom/DataTransfer.h"
#include "mozilla/dom/DOMPreferences.h"
#include "mozilla/dom/HTMLButtonElement.h" #include "mozilla/dom/HTMLButtonElement.h"
#include "mozilla/dom/HTMLInputElement.h" #include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/Preferences.h" #include "mozilla/Preferences.h"
@ -355,7 +354,7 @@ nsFileControlFrame::DnDListener::GetBlobImplForWebkitDirectory(nsIDOMFileList* a
HTMLInputElement* inputElement = HTMLInputElement* inputElement =
HTMLInputElement::FromContent(mFrame->GetContent()); HTMLInputElement::FromContent(mFrame->GetContent());
bool webkitDirPicker = bool webkitDirPicker =
DOMPreferences::WebkitBlinkDirectoryPickerEnabled() && Preferences::GetBool("dom.webkitBlink.dirPicker.enabled", false) &&
inputElement->HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory); inputElement->HasAttr(kNameSpaceID_None, nsGkAtoms::webkitdirectory);
if (!webkitDirPicker) { if (!webkitDirPicker) {
return NS_OK; return NS_OK;

View File

@ -4989,16 +4989,6 @@ Preferences::AddAtomicUintVarCache(Atomic<uint32_t, Order>* aCache,
template nsresult template nsresult
Preferences::AddAtomicBoolVarCache(Atomic<bool, Relaxed>*, const char*, bool); Preferences::AddAtomicBoolVarCache(Atomic<bool, Relaxed>*, const char*, bool);
template nsresult
Preferences::AddAtomicBoolVarCache(Atomic<bool, ReleaseAcquire>*,
const char*,
bool);
template nsresult
Preferences::AddAtomicBoolVarCache(Atomic<bool, SequentiallyConsistent>*,
const char*,
bool);
template nsresult template nsresult
Preferences::AddAtomicIntVarCache(Atomic<int32_t, Relaxed>*, Preferences::AddAtomicIntVarCache(Atomic<int32_t, Relaxed>*,
const char*, const char*,