diff --git a/dom/base/nsGlobalWindowInner.cpp b/dom/base/nsGlobalWindowInner.cpp index b6fe6a09eb41..67cb41d19dab 100644 --- a/dom/base/nsGlobalWindowInner.cpp +++ b/dom/base/nsGlobalWindowInner.cpp @@ -3253,14 +3253,6 @@ bool nsGlobalWindowInner::CachesEnabled(JSContext* aCx, JSObject*) { if (!StaticPrefs::dom_caches_enabled()) { return false; } - if (StaticPrefs::dom_caches_hide_in_pbmode_enabled()) { - if (const nsCOMPtr global = - xpc::CurrentNativeGlobal(aCx)) { - if (global->GetStorageAccess() == StorageAccess::ePrivateBrowsing) { - return false; - } - } - } if (!JS::GetIsSecureContext(js::GetContextRealm(aCx))) { return StaticPrefs::dom_caches_testing_enabled() || StaticPrefs::dom_serviceWorkers_testing_enabled(); diff --git a/dom/base/test/chrome/chrome.ini b/dom/base/test/chrome/chrome.ini index da932a0df4fc..2f11aed22f84 100644 --- a/dom/base/test/chrome/chrome.ini +++ b/dom/base/test/chrome/chrome.ini @@ -21,7 +21,7 @@ support-files = window_swapFrameLoaders.xhtml prefs = gfx.font_rendering.fallback.async=false - + [test_bug120684.xhtml] [test_bug206691.xhtml] [test_bug289714.xhtml] @@ -82,6 +82,3 @@ support-files = file_title.xhtml [test_swapFrameLoaders.xhtml] skip-if = os == 'mac' # bug 1674413 [test_bug1339722.html] -[test_hide_in_pbmode.html] -support-files = - file_hide_in_pbmode.js diff --git a/dom/base/test/chrome/file_hide_in_pbmode.js b/dom/base/test/chrome/file_hide_in_pbmode.js deleted file mode 100644 index a6bf8761232a..000000000000 --- a/dom/base/test/chrome/file_hide_in_pbmode.js +++ /dev/null @@ -1,68 +0,0 @@ -/* global importScripts */ - -const isWorker = typeof DedicatedWorkerGlobalScope === "function"; - -function check(content, expected, item) { - const exposed = expected ? "is exposed without" : "is not exposed with"; - const worker = isWorker ? "in worker" : "in window"; - is( - content.eval(`!!globalThis.${item}`), - expected, - `${item} ${exposed} pbmode ${worker}` - ); -} - -function checkCaches(content, expected) { - check(content, expected, "caches"); - check(content, expected, "Cache"); - check(content, expected, "CacheStorage"); -} - -function checkIDB(content, expected) { - check(content, expected, "indexedDB"); - check(content, expected, "IDBCursor"); - check(content, expected, "IDBDatabase"); - check(content, expected, "IDBFactory"); - check(content, expected, "IDBIndex"); - check(content, expected, "IDBKeyRange"); - check(content, expected, "IDBObjectStore"); - check(content, expected, "IDBOpenDBRequest"); - check(content, expected, "IDBRequest"); - check(content, expected, "IDBTransaction"); - check(content, expected, "IDBVersionChangeEvent"); -} - -function checkSW(content, expected) { - if (isWorker) { - // Currently not supported. Bug 1131324 - return; - } - check(content, expected, "navigator.serviceWorker"); - check(content, expected, "ServiceWorker"); - check(content, expected, "ServiceWorkerContainer"); - check(content, expected, "ServiceWorkerRegistration"); - check(content, expected, "NavigationPreloadManager"); - check(content, expected, "PushManager"); - check(content, expected, "PushSubscription"); - check(content, expected, "PushSubscriptionOptions"); -} - -function checkAll(content, expected) { - checkCaches(content, expected); - checkIDB(content, expected); - checkSW(content, expected); -} - -if (isWorker) { - importScripts("/tests/SimpleTest/WorkerSimpleTest.js"); - - globalThis.onmessage = ev => { - const { expected } = ev.data; - checkAll(globalThis, expected); - postMessage({ - kind: "info", - next: true, - description: "Worker test finished", - }); - }; -} diff --git a/dom/base/test/chrome/test_hide_in_pbmode.html b/dom/base/test/chrome/test_hide_in_pbmode.html deleted file mode 100644 index 263eba105c8e..000000000000 --- a/dom/base/test/chrome/test_hide_in_pbmode.html +++ /dev/null @@ -1,70 +0,0 @@ - -Test for hiding features in Private Browsing - - - - - diff --git a/dom/indexedDB/IDBFactory.cpp b/dom/indexedDB/IDBFactory.cpp index cf293ec5a115..29da76b6a264 100644 --- a/dom/indexedDB/IDBFactory.cpp +++ b/dom/indexedDB/IDBFactory.cpp @@ -359,21 +359,6 @@ bool IDBFactory::AllowedForPrincipal(nsIPrincipal* aPrincipal, return !aPrincipal->GetIsNullPrincipal(); } -bool IDBFactory::IsEnabled(JSContext* aCx, JSObject* aGlobal) { - if (StaticPrefs::dom_indexedDB_privateBrowsing_enabled()) { - return true; - } - if (StaticPrefs::dom_indexedDB_hide_in_pbmode_enabled()) { - if (const nsCOMPtr global = - xpc::CurrentNativeGlobal(aCx)) { - if (global->GetStorageAccess() == StorageAccess::ePrivateBrowsing) { - return false; - } - } - } - return true; -} - void IDBFactory::UpdateActiveTransactionCount(int32_t aDelta) { AssertIsOnOwningThread(); MOZ_DIAGNOSTIC_ASSERT(aDelta > 0 || (mActiveTransactionCount + aDelta) < diff --git a/dom/indexedDB/IDBFactory.h b/dom/indexedDB/IDBFactory.h index 97a0d97859c6..75f05fb19cb1 100644 --- a/dom/indexedDB/IDBFactory.h +++ b/dom/indexedDB/IDBFactory.h @@ -97,8 +97,6 @@ class IDBFactory final : public nsISupports, public nsWrapperCache { static bool AllowedForPrincipal(nsIPrincipal* aPrincipal, bool* aIsSystemPrincipal = nullptr); - static bool IsEnabled(JSContext* aCx, JSObject* aGlobal); - void AssertIsOnOwningThread() const { NS_ASSERT_OWNINGTHREAD(IDBFactory); } nsISerialEventTarget* EventTarget() const { diff --git a/dom/push/PushManager.cpp b/dom/push/PushManager.cpp index 426f965f0f5d..3f3a80d852c8 100644 --- a/dom/push/PushManager.cpp +++ b/dom/push/PushManager.cpp @@ -16,7 +16,6 @@ #include "mozilla/dom/PushSubscriptionOptionsBinding.h" #include "mozilla/dom/PushUtil.h" #include "mozilla/dom/RootedDictionary.h" -#include "mozilla/dom/ServiceWorker.h" #include "mozilla/dom/WorkerRunnable.h" #include "mozilla/dom/WorkerScope.h" @@ -410,10 +409,6 @@ already_AddRefed PushManager::Constructor(GlobalObject& aGlobal, return ret.forget(); } -bool PushManager::IsEnabled(JSContext* aCx, JSObject* aGlobal) { - return StaticPrefs::dom_push_enabled() && ServiceWorkerVisible(aCx, aGlobal); -} - already_AddRefed PushManager::Subscribe( const PushSubscriptionOptionsInit& aOptions, ErrorResult& aRv) { if (mImpl) { diff --git a/dom/push/PushManager.h b/dom/push/PushManager.h index b599530185b4..fd2aa38e7dd0 100644 --- a/dom/push/PushManager.h +++ b/dom/push/PushManager.h @@ -74,8 +74,6 @@ class PushManager final : public nsISupports, public nsWrapperCache { const nsAString& aScope, ErrorResult& aRv); - static bool IsEnabled(JSContext* aCx, JSObject* aGlobal); - already_AddRefed PerformSubscriptionActionFromWorker( SubscriptionAction aAction, ErrorResult& aRv); diff --git a/dom/serviceworkers/NavigationPreloadManager.cpp b/dom/serviceworkers/NavigationPreloadManager.cpp index 4a426ba9b072..c1f56a7dbc0d 100644 --- a/dom/serviceworkers/NavigationPreloadManager.cpp +++ b/dom/serviceworkers/NavigationPreloadManager.cpp @@ -7,14 +7,14 @@ #include "NavigationPreloadManager.h" #include "ServiceWorkerUtils.h" #include "nsNetUtil.h" -#include "mozilla/StaticPrefs_dom.h" #include "mozilla/dom/NavigationPreloadManagerBinding.h" #include "mozilla/dom/Promise.h" -#include "mozilla/dom/ServiceWorker.h" #include "mozilla/ipc/MessageChannel.h" namespace mozilla::dom { +using mozilla::ipc::ResponseRejectReason; + NS_IMPL_CYCLE_COLLECTING_ADDREF(NavigationPreloadManager) NS_IMPL_CYCLE_COLLECTING_RELEASE(NavigationPreloadManager) @@ -30,11 +30,6 @@ bool NavigationPreloadManager::IsValidHeader(const nsACString& aHeader) { return NS_IsReasonableHTTPHeaderValue(aHeader); } -bool NavigationPreloadManager::IsEnabled(JSContext* aCx, JSObject* aGlobal) { - return StaticPrefs::dom_serviceWorkers_navigationPreload_enabled() && - ServiceWorkerVisible(aCx, aGlobal); -} - NavigationPreloadManager::NavigationPreloadManager( nsCOMPtr&& aGlobal, RefPtr& aInner) diff --git a/dom/serviceworkers/NavigationPreloadManager.h b/dom/serviceworkers/NavigationPreloadManager.h index b7515ba2c93c..53a8d2b2adb0 100644 --- a/dom/serviceworkers/NavigationPreloadManager.h +++ b/dom/serviceworkers/NavigationPreloadManager.h @@ -28,8 +28,6 @@ class NavigationPreloadManager final : public nsISupports, static bool IsValidHeader(const nsACString& aHeader); - static bool IsEnabled(JSContext* aCx, JSObject* aGlobal); - NavigationPreloadManager(nsCOMPtr&& aGlobal, RefPtr& aInner); diff --git a/dom/serviceworkers/ServiceWorker.cpp b/dom/serviceworkers/ServiceWorker.cpp index 4070c81f5aa4..9d59aad2d51f 100644 --- a/dom/serviceworkers/ServiceWorker.cpp +++ b/dom/serviceworkers/ServiceWorker.cpp @@ -19,11 +19,9 @@ #include "mozilla/dom/ClientIPCTypes.h" #include "mozilla/dom/ClientState.h" #include "mozilla/dom/MessagePortBinding.h" -#include "mozilla/dom/Navigator.h" #include "mozilla/dom/Promise.h" #include "mozilla/dom/ServiceWorkerGlobalScopeBinding.h" #include "mozilla/dom/WorkerPrivate.h" -#include "mozilla/BasePrincipal.h" #include "mozilla/StaticPrefs_dom.h" #include "mozilla/StorageAccess.h" @@ -31,67 +29,17 @@ # undef PostMessage #endif +using mozilla::ErrorResult; +using namespace mozilla::dom; + namespace mozilla::dom { -static bool IsServiceWorkersTestingEnabledInWindow(JSObject* const aGlobal) { - if (const nsCOMPtr innerWindow = - Navigator::GetWindowFromGlobal(aGlobal)) { - if (auto* bc = innerWindow->GetBrowsingContext()) { - return bc->Top()->ServiceWorkersTestingEnabled(); - } - } - return false; -} - -bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aGlobal) { - MOZ_ASSERT(NS_IsMainThread()); - - if (!StaticPrefs::dom_serviceWorkers_enabled()) { - return false; - } - - if (StaticPrefs::dom_serviceWorkers_hide_in_pbmode_enabled()) { - if (const nsCOMPtr global = - xpc::CurrentNativeGlobal(aCx)) { - if (global->GetStorageAccess() == StorageAccess::ePrivateBrowsing) { - return false; - } - } - } - - // Allow a webextension principal to register a service worker script with - // a moz-extension url only if 'extensions.service_worker_register.allowed' - // is true. - if (!StaticPrefs::extensions_serviceWorkerRegister_allowed()) { - nsIPrincipal* principal = nsContentUtils::SubjectPrincipal(aCx); - if (principal && BasePrincipal::Cast(principal)->AddonPolicy()) { - return false; - } - } - - if (IsSecureContextOrObjectIsFromSecureContext(aCx, aGlobal)) { - return true; - } - - return StaticPrefs::dom_serviceWorkers_testing_enabled() || - IsServiceWorkersTestingEnabledInWindow(aGlobal); -} - -bool ServiceWorkerVisible(JSContext* aCx, JSObject* aGlobal) { +bool ServiceWorkerVisible(JSContext* aCx, JSObject* aObj) { if (NS_IsMainThread()) { - // We want to expose ServiceWorker interface only when - // navigator.serviceWorker is available. Currently it may not be available - // with some reasons: - // 1. navigator.serviceWorker is not supported in workers. (bug 1131324) - // 2. `dom.serviceWorkers.hide_in_pbmode.enabled` wants to hide it in - // private browsing mode. - return ServiceWorkersEnabled(aCx, aGlobal); + return StaticPrefs::dom_serviceWorkers_enabled(); } - // We are already in ServiceWorker and interfaces need to be exposed for e.g. - // globalThis.registration.serviceWorker. Note that navigator.serviceWorker - // is still not supported. (bug 1131324) - return IS_INSTANCE_OF(ServiceWorkerGlobalScope, aGlobal); + return IS_INSTANCE_OF(ServiceWorkerGlobalScope, aObj); } // static diff --git a/dom/serviceworkers/ServiceWorker.h b/dom/serviceworkers/ServiceWorker.h index 7bfa33a6c95a..2c07b7ba69cf 100644 --- a/dom/serviceworkers/ServiceWorker.h +++ b/dom/serviceworkers/ServiceWorker.h @@ -30,9 +30,7 @@ struct StructuredSerializeOptions; } \ } -bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aGlobal); - -bool ServiceWorkerVisible(JSContext* aCx, JSObject* aGlobal); +bool ServiceWorkerVisible(JSContext* aCx, JSObject* aObj); class ServiceWorker final : public DOMEventTargetHelper { public: diff --git a/dom/serviceworkers/ServiceWorkerContainer.cpp b/dom/serviceworkers/ServiceWorkerContainer.cpp index eeb5862f7680..1594bab28852 100644 --- a/dom/serviceworkers/ServiceWorkerContainer.cpp +++ b/dom/serviceworkers/ServiceWorkerContainer.cpp @@ -20,6 +20,7 @@ #include "nsCycleCollectionParticipant.h" #include "nsServiceManagerUtils.h" +#include "mozilla/BasePrincipal.h" #include "mozilla/LoadInfo.h" #include "mozilla/SchedulerGroup.h" #include "mozilla/StaticPrefs_extensions.h" @@ -58,6 +59,63 @@ NS_IMPL_RELEASE_INHERITED(ServiceWorkerContainer, DOMEventTargetHelper) NS_IMPL_CYCLE_COLLECTION_INHERITED(ServiceWorkerContainer, DOMEventTargetHelper, mControllerWorker, mReadyPromise) +namespace { + +bool IsInPrivateBrowsing(JSContext* const aCx) { + if (const nsCOMPtr global = xpc::CurrentNativeGlobal(aCx)) { + if (const nsCOMPtr principal = global->PrincipalOrNull()) { + return principal->GetPrivateBrowsingId() > 0; + } + } + return false; +} + +bool IsServiceWorkersTestingEnabledInWindow(JSObject* const aGlobal) { + if (const nsCOMPtr innerWindow = + Navigator::GetWindowFromGlobal(aGlobal)) { + if (auto* bc = innerWindow->GetBrowsingContext()) { + return bc->Top()->ServiceWorkersTestingEnabled(); + } + } + return false; +} + +} // namespace + +/* static */ +bool ServiceWorkerContainer::IsEnabled(JSContext* aCx, JSObject* aGlobal) { + MOZ_ASSERT(NS_IsMainThread()); + + // FIXME: Why does this need to root? Shouldn't the caller root aGlobal for + // us? + JS::Rooted global(aCx, aGlobal); + + if (!StaticPrefs::dom_serviceWorkers_enabled()) { + return false; + } + + if (IsInPrivateBrowsing(aCx)) { + return false; + } + + // Allow a webextension principal to register a service worker script with + // a moz-extension url only if 'extensions.service_worker_register.allowed' + // is true. + if (!StaticPrefs::extensions_serviceWorkerRegister_allowed()) { + nsIPrincipal* principal = nsContentUtils::SubjectPrincipal(aCx); + if (principal && BasePrincipal::Cast(principal)->AddonPolicy()) { + return false; + } + } + + if (IsSecureContextOrObjectIsFromSecureContext(aCx, global)) { + return true; + } + + return StaticPrefs::dom_serviceWorkers_testing_enabled() || + IsServiceWorkersTestingEnabledInWindow(global); +} + // static already_AddRefed ServiceWorkerContainer::Create( nsIGlobalObject* aGlobal) { diff --git a/dom/tests/mochitest/general/test_interfaces.js b/dom/tests/mochitest/general/test_interfaces.js index 8f395cd6a888..eb632b36850c 100644 --- a/dom/tests/mochitest/general/test_interfaces.js +++ b/dom/tests/mochitest/general/test_interfaces.js @@ -942,11 +942,14 @@ var interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "PublicKeyCredential" }, // IMPORTANT: Do not change this list without review from a DOM peer! - "PushManager", + { name: "PushManager", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! - "PushSubscription", + { name: "PushSubscription", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! - "PushSubscriptionOptions", + { + name: "PushSubscriptionOptions", + insecureContext: true, + }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "RadioNodeList", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! @@ -1026,11 +1029,11 @@ var interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "Selection", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! - "ServiceWorker", + { name: "ServiceWorker", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! - "ServiceWorkerContainer", + { name: "ServiceWorkerContainer", insecureContext: false }, // IMPORTANT: Do not change this list without review from a DOM peer! - "ServiceWorkerRegistration", + { name: "ServiceWorkerRegistration", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "ScopedCredential", insecureContext: true, disabled: true }, // IMPORTANT: Do not change this list without review from a DOM peer! diff --git a/dom/webidl/IDBCursor.webidl b/dom/webidl/IDBCursor.webidl index 988148b5b4d9..0784ac144022 100644 --- a/dom/webidl/IDBCursor.webidl +++ b/dom/webidl/IDBCursor.webidl @@ -14,7 +14,7 @@ enum IDBCursorDirection { "prevunique" }; -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBCursor { readonly attribute (IDBObjectStore or IDBIndex) source; @@ -45,7 +45,7 @@ interface IDBCursor { IDBRequest delete (); }; -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBCursorWithValue : IDBCursor { [Throws] readonly attribute any value; diff --git a/dom/webidl/IDBDatabase.webidl b/dom/webidl/IDBDatabase.webidl index 0f28886f8f92..a35281eb1f66 100644 --- a/dom/webidl/IDBDatabase.webidl +++ b/dom/webidl/IDBDatabase.webidl @@ -10,7 +10,7 @@ * liability, trademark and document use rules apply. */ -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBDatabase : EventTarget { readonly attribute DOMString name; readonly attribute unsigned long long version; diff --git a/dom/webidl/IDBFactory.webidl b/dom/webidl/IDBFactory.webidl index 9434a7e12c95..57826b231728 100644 --- a/dom/webidl/IDBFactory.webidl +++ b/dom/webidl/IDBFactory.webidl @@ -23,7 +23,7 @@ dictionary IDBOpenDBOptions * http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBFactory * for more information. */ -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBFactory { [Throws, NeedsCallerType] IDBOpenDBRequest diff --git a/dom/webidl/IDBIndex.webidl b/dom/webidl/IDBIndex.webidl index 54d9b5d178c3..ff2f215d8381 100644 --- a/dom/webidl/IDBIndex.webidl +++ b/dom/webidl/IDBIndex.webidl @@ -18,7 +18,7 @@ dictionary IDBIndexParameters { DOMString? locale = null; }; -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBIndex { [SetterThrows] attribute DOMString name; diff --git a/dom/webidl/IDBKeyRange.webidl b/dom/webidl/IDBKeyRange.webidl index d36dd854b0d3..92469aeb049a 100644 --- a/dom/webidl/IDBKeyRange.webidl +++ b/dom/webidl/IDBKeyRange.webidl @@ -9,7 +9,7 @@ * liability, trademark and document use rules apply. */ -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBKeyRange { [Throws] readonly attribute any lower; diff --git a/dom/webidl/IDBObjectStore.webidl b/dom/webidl/IDBObjectStore.webidl index 3ae08de871b7..105f3501f234 100644 --- a/dom/webidl/IDBObjectStore.webidl +++ b/dom/webidl/IDBObjectStore.webidl @@ -12,7 +12,7 @@ dictionary IDBObjectStoreParameters { boolean autoIncrement = false; }; -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBObjectStore { [SetterThrows] attribute DOMString name; diff --git a/dom/webidl/IDBOpenDBRequest.webidl b/dom/webidl/IDBOpenDBRequest.webidl index 48c3add1c560..8668009a6b78 100644 --- a/dom/webidl/IDBOpenDBRequest.webidl +++ b/dom/webidl/IDBOpenDBRequest.webidl @@ -7,7 +7,7 @@ * https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBOpenDBRequest */ -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBOpenDBRequest : IDBRequest { attribute EventHandler onblocked; diff --git a/dom/webidl/IDBRequest.webidl b/dom/webidl/IDBRequest.webidl index 408942dae87f..029368bc7d19 100644 --- a/dom/webidl/IDBRequest.webidl +++ b/dom/webidl/IDBRequest.webidl @@ -13,7 +13,7 @@ enum IDBRequestReadyState { "done" }; -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBRequest : EventTarget { [Throws] readonly attribute any result; diff --git a/dom/webidl/IDBTransaction.webidl b/dom/webidl/IDBTransaction.webidl index 1bfb458d3b55..3b832427b19d 100644 --- a/dom/webidl/IDBTransaction.webidl +++ b/dom/webidl/IDBTransaction.webidl @@ -19,7 +19,7 @@ enum IDBTransactionMode { "versionchange" }; -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBTransaction : EventTarget { [Throws] readonly attribute IDBTransactionMode mode; diff --git a/dom/webidl/IDBVersionChangeEvent.webidl b/dom/webidl/IDBVersionChangeEvent.webidl index d331f6966d43..d35030164f16 100644 --- a/dom/webidl/IDBVersionChangeEvent.webidl +++ b/dom/webidl/IDBVersionChangeEvent.webidl @@ -15,7 +15,7 @@ dictionary IDBVersionChangeEventInit : EventInit { unsigned long long? newVersion = null; }; -[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"] +[Exposed=(Window,Worker)] interface IDBVersionChangeEvent : Event { constructor(DOMString type, optional IDBVersionChangeEventInit eventInitDict = {}); diff --git a/dom/webidl/NavigationPreloadManager.webidl b/dom/webidl/NavigationPreloadManager.webidl index 6d28a8b97d93..f58bcb745822 100644 --- a/dom/webidl/NavigationPreloadManager.webidl +++ b/dom/webidl/NavigationPreloadManager.webidl @@ -7,7 +7,7 @@ * https://w3c.github.io/ServiceWorker/#navigation-preload-manager */ -[Func="NavigationPreloadManager::IsEnabled", SecureContext, +[Pref="dom.serviceWorkers.navigationPreload.enabled", SecureContext, Exposed=(Window,Worker)] interface NavigationPreloadManager { [NewObject] diff --git a/dom/webidl/Navigator.webidl b/dom/webidl/Navigator.webidl index 46e005a2a366..064c2ac1f8b3 100644 --- a/dom/webidl/Navigator.webidl +++ b/dom/webidl/Navigator.webidl @@ -263,7 +263,7 @@ partial interface Navigator { // Service Workers/Navigation Controllers partial interface Navigator { - [Func="ServiceWorkersEnabled", SameObject] + [Func="ServiceWorkerContainer::IsEnabled", SameObject] readonly attribute ServiceWorkerContainer serviceWorker; }; diff --git a/dom/webidl/PushManager.webidl b/dom/webidl/PushManager.webidl index ff99e294b535..fcd04db4c71f 100644 --- a/dom/webidl/PushManager.webidl +++ b/dom/webidl/PushManager.webidl @@ -26,7 +26,7 @@ interface PushManagerImpl { Promise permissionState(optional PushSubscriptionOptionsInit options = {}); }; -[Exposed=(Window,Worker), Func="PushManager::IsEnabled"] +[Exposed=(Window,Worker), Pref="dom.push.enabled"] interface PushManager { [Throws, ChromeOnly] constructor(DOMString scope); diff --git a/dom/webidl/PushSubscription.webidl b/dom/webidl/PushSubscription.webidl index 6acb13d10a96..4b2155c45dea 100644 --- a/dom/webidl/PushSubscription.webidl +++ b/dom/webidl/PushSubscription.webidl @@ -41,7 +41,7 @@ dictionary PushSubscriptionInit EpochTimeStamp? expirationTime = null; }; -[Exposed=(Window,Worker), Func="ServiceWorkerVisible"] +[Exposed=(Window,Worker), Pref="dom.push.enabled"] interface PushSubscription { [Throws, ChromeOnly] diff --git a/dom/webidl/PushSubscriptionOptions.webidl b/dom/webidl/PushSubscriptionOptions.webidl index b0a421008f28..07b36aa011ba 100644 --- a/dom/webidl/PushSubscriptionOptions.webidl +++ b/dom/webidl/PushSubscriptionOptions.webidl @@ -7,7 +7,7 @@ * https://w3c.github.io/push-api/ */ -[Exposed=(Window,Worker), Func="ServiceWorkerVisible"] +[Exposed=(Window,Worker), Pref="dom.push.enabled"] interface PushSubscriptionOptions { [SameObject, Throws] diff --git a/dom/webidl/ServiceWorkerContainer.webidl b/dom/webidl/ServiceWorkerContainer.webidl index d490a7d12642..3b03b4fde8f3 100644 --- a/dom/webidl/ServiceWorkerContainer.webidl +++ b/dom/webidl/ServiceWorkerContainer.webidl @@ -8,7 +8,7 @@ * */ -[Func="ServiceWorkersEnabled", +[Func="ServiceWorkerContainer::IsEnabled", Exposed=Window] interface ServiceWorkerContainer : EventTarget { // FIXME(nsm): diff --git a/dom/webidl/ServiceWorkerRegistration.webidl b/dom/webidl/ServiceWorkerRegistration.webidl index 9a994f2593e9..9987b7e456aa 100644 --- a/dom/webidl/ServiceWorkerRegistration.webidl +++ b/dom/webidl/ServiceWorkerRegistration.webidl @@ -9,7 +9,7 @@ * https://notifications.spec.whatwg.org/ */ -[Func="ServiceWorkerVisible", +[Pref="dom.serviceWorkers.enabled", Exposed=(Window,Worker)] interface ServiceWorkerRegistration : EventTarget { readonly attribute ServiceWorker? installing; diff --git a/dom/webidl/WindowOrWorkerGlobalScope.webidl b/dom/webidl/WindowOrWorkerGlobalScope.webidl index 66be3f7e7619..af4f88e7a70b 100644 --- a/dom/webidl/WindowOrWorkerGlobalScope.webidl +++ b/dom/webidl/WindowOrWorkerGlobalScope.webidl @@ -69,9 +69,9 @@ partial interface mixin WindowOrWorkerGlobalScope { // http://w3c.github.io/IndexedDB/#factory-interface partial interface mixin WindowOrWorkerGlobalScope { - // readonly attribute IDBFactory indexedDB; // bug 1776789 - [Throws, Func="IDBFactory::IsEnabled"] - readonly attribute IDBFactory? indexedDB; + // readonly attribute IDBFactory indexedDB; + [Throws] + readonly attribute IDBFactory? indexedDB; }; // https://w3c.github.io/ServiceWorker/#self-caches diff --git a/dom/workers/test/test_worker_interfaces.js b/dom/workers/test/test_worker_interfaces.js index c86d008474b8..498cbbf810ca 100644 --- a/dom/workers/test/test_worker_interfaces.js +++ b/dom/workers/test/test_worker_interfaces.js @@ -224,6 +224,8 @@ var interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "MessagePort", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! + "NavigationPreloadManager", + // IMPORTANT: Do not change this list without review from a DOM peer! { name: "NetworkInformation", insecureContext: true, disabled: true }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "Notification", insecureContext: true }, @@ -250,6 +252,14 @@ var interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "PromiseRejectionEvent", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! + { name: "PushManager", insecureContext: true }, + // IMPORTANT: Do not change this list without review from a DOM peer! + { name: "PushSubscription", insecureContext: true }, + // IMPORTANT: Do not change this list without review from a DOM peer! + { + name: "PushSubscriptionOptions", + insecureContext: true, + }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "ReadableByteStreamController", insecureContext: true }, // IMPORTANT: Do not change this list without review from a DOM peer! @@ -275,6 +285,8 @@ var interfaceNamesInGlobalScope = [ // IMPORTANT: Do not change this list without review from a DOM peer! { name: "Scheduler", insecureContext: true, nightly: true }, // IMPORTANT: Do not change this list without review from a DOM peer! + { name: "ServiceWorkerRegistration", insecureContext: true }, + // IMPORTANT: Do not change this list without review from a DOM peer! { name: "StorageManager", fennec: false }, // IMPORTANT: Do not change this list without review from a DOM peer! { name: "SubtleCrypto" }, diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index a58cb80a5710..b292328d43b2 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -2051,12 +2051,6 @@ value: false mirror: always -# Disable CacheStorage in private browsing mode. -- name: dom.caches.hide_in_pbmode.enabled - type: RelaxedAtomicBool - value: @IS_NIGHTLY_BUILD@ - mirror: always - # Disable capture attribute for input elements; only supported on GeckoView. - name: dom.capture.enabled type: bool @@ -2540,18 +2534,12 @@ value: false mirror: always -# Enable indexedDB in private browsing mode with encryption +# Enable indexedDB in private browsing mode. - name: dom.indexedDB.privateBrowsing.enabled type: RelaxedAtomicBool value: false mirror: always -# Disable IndexedDB in private browsing mode. -- name: dom.indexedDB.hide_in_pbmode.enabled - type: RelaxedAtomicBool - value: @IS_NIGHTLY_BUILD@ - mirror: always - - name: dom.input_events.beforeinput.enabled type: bool value: true @@ -3606,12 +3594,6 @@ value: false mirror: always -# Disable ServiceWorker in private browsing mode. -- name: dom.serviceWorkers.hide_in_pbmode.enabled - type: RelaxedAtomicBool - value: true - mirror: always - - name: dom.workers.requestAnimationFrame type: RelaxedAtomicBool value: true diff --git a/testing/web-platform/meta/notifications/idlharness.https.any.js.ini b/testing/web-platform/meta/notifications/idlharness.https.any.js.ini index 088d6cc4b176..4409af2dfbae 100644 --- a/testing/web-platform/meta/notifications/idlharness.https.any.js.ini +++ b/testing/web-platform/meta/notifications/idlharness.https.any.js.ini @@ -91,12 +91,6 @@ prefs: [dom.webnotifications.requireinteraction.enabled:true, dom.webnotificatio [Notification interface: attribute badge] expected: FAIL - [ServiceWorkerRegistration interface: operation showNotification(DOMString, optional NotificationOptions)] - expected: FAIL - - [ServiceWorkerRegistration interface: operation getNotifications(optional GetNotificationOptions)] - expected: FAIL - [idlharness.https.any.sharedworker.html] [Notification interface: attribute image] @@ -132,8 +126,3 @@ prefs: [dom.webnotifications.requireinteraction.enabled:true, dom.webnotificatio [Notification interface: attribute badge] expected: FAIL - [ServiceWorkerRegistration interface: operation showNotification(DOMString, optional NotificationOptions)] - expected: FAIL - - [ServiceWorkerRegistration interface: operation getNotifications(optional GetNotificationOptions)] - expected: FAIL diff --git a/testing/web-platform/meta/push-api/idlharness.https.any.js.ini b/testing/web-platform/meta/push-api/idlharness.https.any.js.ini index bba73f170186..b22811f77502 100644 --- a/testing/web-platform/meta/push-api/idlharness.https.any.js.ini +++ b/testing/web-platform/meta/push-api/idlharness.https.any.js.ini @@ -33,86 +33,13 @@ [PushManager interface: attribute supportedContentEncodings] expected: FAIL - [PushManager interface: existence and properties of interface object] - expected: FAIL - - [PushManager interface object name] - expected: FAIL - - [PushManager interface: existence and properties of interface prototype object] - expected: FAIL - - [PushManager interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [PushManager interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [PushManager interface: operation subscribe(optional PushSubscriptionOptionsInit)] - expected: FAIL - - [PushManager interface: operation getSubscription()] - expected: FAIL - - [PushManager interface: operation permissionState(optional PushSubscriptionOptionsInit)] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute pushManager] - expected: FAIL - - [PushSubscription interface: existence and properties of interface object] - expected: FAIL - - [PushSubscription interface object name] - expected: FAIL - - [PushSubscription interface: existence and properties of interface prototype object] - expected: FAIL - - [PushSubscription interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [PushSubscription interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [PushSubscription interface: attribute endpoint] - expected: FAIL - [PushSubscription interface: attribute expirationTime] - expected: FAIL - - [PushSubscription interface: attribute options] - expected: FAIL - - [PushSubscription interface: operation getKey(PushEncryptionKeyName)] - expected: FAIL - - [PushSubscription interface: operation unsubscribe()] - expected: FAIL - - [PushSubscription interface: operation toJSON()] - expected: FAIL - - [PushSubscriptionOptions interface: existence and properties of interface object] - expected: FAIL - - [PushSubscriptionOptions interface object length] - expected: FAIL - - [PushSubscriptionOptions interface object name] - expected: FAIL - - [PushSubscriptionOptions interface: existence and properties of interface prototype object] - expected: FAIL - - [PushSubscriptionOptions interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [PushSubscriptionOptions interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [PushSubscriptionOptions interface: attribute applicationServerKey] - expected: FAIL + expected: + if (os == "mac") and debug: PASS + if (os == "android") and swgl: PASS + if (os == "linux") and debug: PASS + if os == "win": PASS + [PASS, FAIL] [idlharness.https.any.serviceworker.html] @@ -186,83 +113,10 @@ [PushManager interface: attribute supportedContentEncodings] expected: FAIL - [PushManager interface: existence and properties of interface object] - expected: FAIL - - [PushManager interface object name] - expected: FAIL - - [PushManager interface: existence and properties of interface prototype object] - expected: FAIL - - [PushManager interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [PushManager interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [PushManager interface: operation subscribe(optional PushSubscriptionOptionsInit)] - expected: FAIL - - [PushManager interface: operation getSubscription()] - expected: FAIL - - [PushManager interface: operation permissionState(optional PushSubscriptionOptionsInit)] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute pushManager] - expected: FAIL - - [PushSubscription interface: existence and properties of interface object] - expected: FAIL - - [PushSubscription interface object name] - expected: FAIL - - [PushSubscription interface: existence and properties of interface prototype object] - expected: FAIL - - [PushSubscription interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [PushSubscription interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [PushSubscription interface: attribute endpoint] - expected: FAIL - [PushSubscription interface: attribute expirationTime] - expected: FAIL - - [PushSubscription interface: attribute options] - expected: FAIL - - [PushSubscription interface: operation getKey(PushEncryptionKeyName)] - expected: FAIL - - [PushSubscription interface: operation unsubscribe()] - expected: FAIL - - [PushSubscription interface: operation toJSON()] - expected: FAIL - - [PushSubscriptionOptions interface: existence and properties of interface object] - expected: FAIL - - [PushSubscriptionOptions interface object length] - expected: FAIL - - [PushSubscriptionOptions interface object name] - expected: FAIL - - [PushSubscriptionOptions interface: existence and properties of interface prototype object] - expected: FAIL - - [PushSubscriptionOptions interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [PushSubscriptionOptions interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [PushSubscriptionOptions interface: attribute applicationServerKey] - expected: FAIL + expected: + if (os == "mac") and debug: PASS + if (os == "linux") and debug: PASS + if (os == "android") and swgl: PASS + if os == "win": PASS + [PASS, FAIL] diff --git a/testing/web-platform/meta/service-workers/idlharness.https.any.js.ini b/testing/web-platform/meta/service-workers/idlharness.https.any.js.ini index 54e19023cafe..050caf1b278b 100644 --- a/testing/web-platform/meta/service-workers/idlharness.https.any.js.ini +++ b/testing/web-platform/meta/service-workers/idlharness.https.any.js.ini @@ -122,81 +122,6 @@ [ServiceWorker interface: operation postMessage(any, optional StructuredSerializeOptions)] expected: FAIL - [ServiceWorkerRegistration interface: existence and properties of interface object] - expected: FAIL - - [ServiceWorkerRegistration interface object length] - expected: FAIL - - [ServiceWorkerRegistration interface object name] - expected: FAIL - - [ServiceWorkerRegistration interface: existence and properties of interface prototype object] - expected: FAIL - - [ServiceWorkerRegistration interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [ServiceWorkerRegistration interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute installing] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute waiting] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute active] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute navigationPreload] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute scope] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute updateViaCache] - expected: FAIL - - [ServiceWorkerRegistration interface: operation update()] - expected: FAIL - - [ServiceWorkerRegistration interface: operation unregister()] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute onupdatefound] - expected: FAIL - - [NavigationPreloadManager interface: existence and properties of interface object] - expected: FAIL - - [NavigationPreloadManager interface object length] - expected: FAIL - - [NavigationPreloadManager interface object name] - expected: FAIL - - [NavigationPreloadManager interface: existence and properties of interface prototype object] - expected: FAIL - - [NavigationPreloadManager interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [NavigationPreloadManager interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [NavigationPreloadManager interface: operation enable()] - expected: FAIL - - [NavigationPreloadManager interface: operation disable()] - expected: FAIL - - [NavigationPreloadManager interface: operation setHeaderValue(ByteString)] - expected: FAIL - - [NavigationPreloadManager interface: operation getState()] - expected: FAIL - [idlharness.https.any.worker.html] [ServiceWorkerContainer interface: operation startMessages()] @@ -322,87 +247,11 @@ [ServiceWorker interface: operation postMessage(any, optional StructuredSerializeOptions)] expected: FAIL - [ServiceWorkerRegistration interface: existence and properties of interface object] - expected: FAIL - - [ServiceWorkerRegistration interface object length] - expected: FAIL - - [ServiceWorkerRegistration interface object name] - expected: FAIL - - [ServiceWorkerRegistration interface: existence and properties of interface prototype object] - expected: FAIL - - [ServiceWorkerRegistration interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [ServiceWorkerRegistration interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute installing] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute waiting] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute active] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute navigationPreload] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute scope] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute updateViaCache] - expected: FAIL - - [ServiceWorkerRegistration interface: operation update()] - expected: FAIL - - [ServiceWorkerRegistration interface: operation unregister()] - expected: FAIL - - [ServiceWorkerRegistration interface: attribute onupdatefound] - expected: FAIL - - [NavigationPreloadManager interface: existence and properties of interface object] - expected: FAIL - - [NavigationPreloadManager interface object length] - expected: FAIL - - [NavigationPreloadManager interface object name] - expected: FAIL - - [NavigationPreloadManager interface: existence and properties of interface prototype object] - expected: FAIL - - [NavigationPreloadManager interface: existence and properties of interface prototype object's "constructor" property] - expected: FAIL - - [NavigationPreloadManager interface: existence and properties of interface prototype object's @@unscopables property] - expected: FAIL - - [NavigationPreloadManager interface: operation enable()] - expected: FAIL - - [NavigationPreloadManager interface: operation disable()] - expected: FAIL - - [NavigationPreloadManager interface: operation setHeaderValue(ByteString)] - expected: FAIL - - [NavigationPreloadManager interface: operation getState()] - expected: FAIL - [idlharness.https.any.html] [CacheStorage interface object length] expected: FAIL - [idlharness.https.any.serviceworker.html] [ServiceWorker interface: serviceWorker must inherit property "scriptURL" with the proper type] expected: FAIL diff --git a/toolkit/components/antitracking/StorageAccess.cpp b/toolkit/components/antitracking/StorageAccess.cpp index eb80b0be8f61..d8061d097f45 100644 --- a/toolkit/components/antitracking/StorageAccess.cpp +++ b/toolkit/components/antitracking/StorageAccess.cpp @@ -235,16 +235,7 @@ StorageAccess StorageAllowedForWindow(nsPIDOMWindowInner* aWindow, *aRejectedReason); } - // No document? Try checking Private Browsing Mode without document - if (const nsCOMPtr global = aWindow->AsGlobal()) { - if (const nsCOMPtr principal = global->PrincipalOrNull()) { - if (principal->GetPrivateBrowsingId() > 0) { - return StorageAccess::ePrivateBrowsing; - } - } - } - - // Everything failed? Let's return a generic rejected reason. + // No document? Let's return a generic rejected reason. return StorageAccess::eDeny; } diff --git a/toolkit/components/antitracking/test/browser/browser_blockingIndexedDb.js b/toolkit/components/antitracking/test/browser/browser_blockingIndexedDb.js index 6cfcee89b4d1..c386612df1a6 100644 --- a/toolkit/components/antitracking/test/browser/browser_blockingIndexedDb.js +++ b/toolkit/components/antitracking/test/browser/browser_blockingIndexedDb.js @@ -26,8 +26,7 @@ AntiTracking.runTestInNormalAndPrivateMode( resolve() ); }); - }, - [["dom.indexedDB.hide_in_pbmode.enabled", false]] + } ); AntiTracking.runTestInNormalAndPrivateMode( @@ -98,7 +97,7 @@ AntiTracking.runTestInNormalAndPrivateMode( ); }); }, - [["dom.indexedDB.hide_in_pbmode.enabled", false]], + null, false, false ); diff --git a/toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers.js b/toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers.js index 97deb6adf889..c9ae0d165417 100644 --- a/toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers.js +++ b/toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers.js @@ -70,6 +70,5 @@ AntiTracking.runTestInNormalAndPrivateMode( resolve() ); }); - }, - [["dom.indexedDB.hide_in_pbmode.enabled", false]] + } ); diff --git a/toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers2.js b/toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers2.js index 4d23cec7191d..fb7f3d2c67ab 100644 --- a/toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers2.js +++ b/toolkit/components/antitracking/test/browser/browser_blockingIndexedDbInWorkers2.js @@ -148,7 +148,7 @@ AntiTracking.runTestInNormalAndPrivateMode( ); }); }, - [["dom.indexedDB.hide_in_pbmode.enabled", false]], + null, false, false );