зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1784590 - Part 1: Remove hide_in_pbmode prefs r=asuth
It turns out that websites break with different reasons when hiding things. At this point we want to stop revising the hack further and instead gather the data about how many websites are currently affected. Differential Revision: https://phabricator.services.mozilla.com/D154578
This commit is contained in:
Родитель
7debf672ba
Коммит
32a02a7021
|
@ -3290,14 +3290,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<nsIGlobalObject> 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();
|
||||
|
@ -5099,12 +5091,6 @@ Storage* nsGlobalWindowInner::GetLocalStorage(ErrorResult& aError) {
|
|||
|
||||
IDBFactory* nsGlobalWindowInner::GetIndexedDB(JSContext* aCx,
|
||||
ErrorResult& aError) {
|
||||
if (!IDBFactory::IsEnabled(aCx, AsGlobal()->GetGlobalJSObject())) {
|
||||
// Let window.indexedDB be an attribute with a null value, to prevent
|
||||
// undefined identifier error
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!mIndexedDB) {
|
||||
// This may keep mIndexedDB null without setting an error.
|
||||
auto res = IDBFactory::CreateForWindow(this);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,112 +0,0 @@
|
|||
/* global importScripts */
|
||||
|
||||
const isWorker = typeof DedicatedWorkerGlobalScope === "function";
|
||||
|
||||
function checkAll(content, inPrivateBrowsing) {
|
||||
function check(
|
||||
item,
|
||||
{ valueExpected, enumerationExpected, parent = "globalThis" }
|
||||
) {
|
||||
const exposed = valueExpected ? "is exposed" : "is not exposed";
|
||||
const pbmode = inPrivateBrowsing ? "with pbmode" : "without pbmode";
|
||||
const enumerated = enumerationExpected
|
||||
? "is enumerated"
|
||||
: "is not enumerated";
|
||||
const worker = isWorker ? "in worker" : "in window";
|
||||
is(
|
||||
content.eval(`!!${parent}.${item}`),
|
||||
valueExpected,
|
||||
`${parent}.${item} ${exposed} ${pbmode} ${worker}`
|
||||
);
|
||||
is(
|
||||
content.eval(`"${item}" in ${parent}`),
|
||||
enumerationExpected,
|
||||
`${parent}.${item} ${enumerated} ${pbmode} ${worker}`
|
||||
);
|
||||
}
|
||||
|
||||
function checkNotExposedInPBM(item, parent) {
|
||||
check(item, {
|
||||
valueExpected: !inPrivateBrowsing,
|
||||
enumerationExpected: !inPrivateBrowsing,
|
||||
parent,
|
||||
});
|
||||
}
|
||||
|
||||
function checkCaches() {
|
||||
checkNotExposedInPBM("caches");
|
||||
checkNotExposedInPBM("Cache");
|
||||
checkNotExposedInPBM("CacheStorage");
|
||||
}
|
||||
|
||||
function checkIDB() {
|
||||
checkNotExposedInPBM("IDBFactory");
|
||||
checkNotExposedInPBM("IDBKeyRange");
|
||||
checkNotExposedInPBM("IDBOpenDBRequest");
|
||||
checkNotExposedInPBM("IDBRequest");
|
||||
checkNotExposedInPBM("IDBVersionChangeEvent");
|
||||
|
||||
// These are always accessed by jakearchibald/idb@v3 without existence checks.
|
||||
// https://github.com/jakearchibald/idb/blob/e1c7c44dbba38415745afc782b8e247da8c833f2/lib/idb.mjs#L152
|
||||
check("IDBCursor", {
|
||||
valueExpected: true,
|
||||
enumerationExpected: true,
|
||||
});
|
||||
check("IDBDatabase", {
|
||||
valueExpected: true,
|
||||
enumerationExpected: true,
|
||||
});
|
||||
check("IDBIndex", {
|
||||
valueExpected: true,
|
||||
enumerationExpected: true,
|
||||
});
|
||||
check("IDBObjectStore", {
|
||||
valueExpected: true,
|
||||
enumerationExpected: true,
|
||||
});
|
||||
check("IDBTransaction", {
|
||||
valueExpected: true,
|
||||
enumerationExpected: true,
|
||||
});
|
||||
|
||||
// https://www.msn.com/feed accesses indexedDB as a global variable without existence check
|
||||
// We need to always expose the attribute itself
|
||||
check("indexedDB", {
|
||||
valueExpected: !inPrivateBrowsing,
|
||||
enumerationExpected: true,
|
||||
});
|
||||
}
|
||||
|
||||
function checkSW() {
|
||||
if (isWorker) {
|
||||
// Currently not supported. Bug 1131324
|
||||
return;
|
||||
}
|
||||
checkNotExposedInPBM("serviceWorker", "navigator");
|
||||
checkNotExposedInPBM("ServiceWorker");
|
||||
checkNotExposedInPBM("ServiceWorkerContainer");
|
||||
checkNotExposedInPBM("ServiceWorkerRegistration");
|
||||
checkNotExposedInPBM("NavigationPreloadManager");
|
||||
checkNotExposedInPBM("PushManager");
|
||||
checkNotExposedInPBM("PushSubscription");
|
||||
checkNotExposedInPBM("PushSubscriptionOptions");
|
||||
}
|
||||
|
||||
checkCaches();
|
||||
checkIDB();
|
||||
checkSW();
|
||||
}
|
||||
|
||||
if (isWorker) {
|
||||
importScripts("/tests/SimpleTest/WorkerSimpleTest.js");
|
||||
|
||||
globalThis.onmessage = ev => {
|
||||
const { inPrivateBrowsing } = ev.data;
|
||||
checkAll(globalThis, inPrivateBrowsing);
|
||||
postMessage({
|
||||
kind: "info",
|
||||
next: true,
|
||||
description: "Worker test finished",
|
||||
});
|
||||
};
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<title>Test for hiding features in Private Browsing</title>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="chrome://mochikit/content/tests/SimpleTest/WorkerHandler.js"></script>
|
||||
<script src="file_hide_in_pbmode.js"></script>
|
||||
<link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css">
|
||||
<script>
|
||||
const { BrowserTestUtils } = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm");
|
||||
|
||||
const contentPage = "https://example.org/chrome/dom/workers/test/empty.html";
|
||||
|
||||
function openBrowserWindow(url, { private }) {
|
||||
return new Promise(resolve => {
|
||||
const win = window.browsingContext.topChromeWindow.OpenBrowserWindow({ private });
|
||||
win.addEventListener("load", () => {
|
||||
const listener = () => {
|
||||
if (win.content.location.href != contentPage) {
|
||||
BrowserTestUtils.loadURI(win.gBrowser, contentPage);
|
||||
return;
|
||||
}
|
||||
|
||||
win.removeEventListener("DOMContentLoaded", listener);
|
||||
resolve(win);
|
||||
}
|
||||
win.addEventListener("DOMContentLoaded", listener);
|
||||
}, { once: true });
|
||||
});
|
||||
}
|
||||
|
||||
function runWorkerTest(content, inPrivateBrowsing) {
|
||||
return new Promise((resolve, reject) => {
|
||||
/** @type {Worker} */
|
||||
const worker = content.eval("new Worker('/chrome/dom/base/test/chrome/file_hide_in_pbmode.js')");
|
||||
worker.postMessage({ inPrivateBrowsing });
|
||||
worker.onerror = reject;
|
||||
listenForTests(worker);
|
||||
worker.addEventListener("message", ev => {
|
||||
if (ev.data.next) {
|
||||
worker.terminate();
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function runTest() {
|
||||
// sanity check
|
||||
let win = await openBrowserWindow(contentPage, { private: false });
|
||||
checkAll(win.content, false);
|
||||
await runWorkerTest(win.content, false);
|
||||
win.close();
|
||||
|
||||
win = await openBrowserWindow(contentPage, { private: true });
|
||||
checkAll(win.content, true);
|
||||
await runWorkerTest(win.content, true);
|
||||
win.close();
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({
|
||||
set: [
|
||||
["dom.caches.hide_in_pbmode.enabled", true],
|
||||
["dom.indexedDB.hide_in_pbmode.enabled", true],
|
||||
["dom.serviceWorkers.hide_in_pbmode.enabled", true],
|
||||
]
|
||||
}, runTest);
|
||||
|
||||
</script>
|
|
@ -1,5 +1 @@
|
|||
[DEFAULT]
|
||||
prefs =
|
||||
dom.caches.hide_in_pbmode.enabled=false
|
||||
|
||||
[browser_cache_pb_window.js]
|
||||
|
|
|
@ -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<nsIGlobalObject> 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) <
|
||||
|
|
|
@ -95,8 +95,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 {
|
||||
|
|
|
@ -1,6 +1,4 @@
|
|||
[DEFAULT]
|
||||
prefs =
|
||||
dom.indexedDB.hide_in_pbmode.enabled=false
|
||||
skip-if = (buildapp != "browser")
|
||||
support-files =
|
||||
head.js
|
||||
|
|
|
@ -53,12 +53,9 @@ bool ServiceWorkersEnabled(JSContext* aCx, JSObject* aGlobal) {
|
|||
// xpc::CurrentNativeGlobal below requires rooting
|
||||
JS::Rooted<JSObject*> global(aCx, aGlobal);
|
||||
|
||||
if (StaticPrefs::dom_serviceWorkers_hide_in_pbmode_enabled()) {
|
||||
if (const nsCOMPtr<nsIGlobalObject> global =
|
||||
xpc::CurrentNativeGlobal(aCx)) {
|
||||
if (global->GetStorageAccess() == StorageAccess::ePrivateBrowsing) {
|
||||
return false;
|
||||
}
|
||||
if (const nsCOMPtr<nsIGlobalObject> global = xpc::CurrentNativeGlobal(aCx)) {
|
||||
if (global->GetStorageAccess() == StorageAccess::ePrivateBrowsing) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -86,8 +83,6 @@ bool ServiceWorkerVisible(JSContext* aCx, JSObject* aGlobal) {
|
|||
// 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ interface IDBCursor {
|
|||
[NewObject, Throws] IDBRequest delete();
|
||||
};
|
||||
|
||||
[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"]
|
||||
[Exposed=(Window,Worker)]
|
||||
interface IDBCursorWithValue : IDBCursor {
|
||||
[Pure, Throws] readonly attribute any value;
|
||||
};
|
||||
|
|
|
@ -22,7 +22,7 @@ dictionary IDBOpenDBOptions
|
|||
* https://w3c.github.io/IndexedDB/#idbfactory
|
||||
* for more information.
|
||||
*/
|
||||
[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"]
|
||||
[Exposed=(Window,Worker)]
|
||||
interface IDBFactory {
|
||||
[NewObject, Throws, NeedsCallerType]
|
||||
IDBOpenDBRequest
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* https://w3c.github.io/IndexedDB/#idbopendbrequest
|
||||
*/
|
||||
|
||||
[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"]
|
||||
[Exposed=(Window,Worker)]
|
||||
interface IDBOpenDBRequest : IDBRequest {
|
||||
attribute EventHandler onblocked;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ enum IDBRequestReadyState {
|
|||
"done"
|
||||
};
|
||||
|
||||
[Exposed=(Window,Worker), Func="IDBFactory::IsEnabled"]
|
||||
[Exposed=(Window,Worker)]
|
||||
interface IDBRequest : EventTarget {
|
||||
[Throws]
|
||||
readonly attribute any result;
|
||||
|
|
|
@ -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 = {});
|
||||
|
|
|
@ -679,12 +679,6 @@ already_AddRefed<IDBFactory> WorkerGlobalScope::GetIndexedDB(
|
|||
JSContext* aCx, ErrorResult& aErrorResult) {
|
||||
AssertIsOnWorkerThread();
|
||||
|
||||
if (!IDBFactory::IsEnabled(aCx, GetGlobalJSObject())) {
|
||||
// Let window.indexedDB be an attribute with a null value, to prevent
|
||||
// undefined identifier error
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RefPtr<IDBFactory> indexedDB = mIndexedDB;
|
||||
|
||||
if (!indexedDB) {
|
||||
|
|
|
@ -2163,12 +2163,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
|
||||
|
@ -2628,12 +2622,6 @@
|
|||
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
|
||||
|
||||
# Whether or not indexedDB test mode is enabled.
|
||||
- name: dom.indexedDB.testing
|
||||
type: RelaxedAtomicBool
|
||||
|
@ -3735,12 +3723,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
|
||||
|
|
Загрузка…
Ссылка в новой задаче