Bug 1451486 - Part 1 - Ignore the storage attribute on indexedDB.open() by default. r=asuth,baku

MozReview-Commit-ID: 844FRkx3rKZ

--HG--
extra : rebase_source : 962cd1ade83b34561ebd6cd70365b44b85a3aa95
This commit is contained in:
Johann Hofmann 2018-04-10 23:00:30 +02:00
Родитель e2ad665009
Коммит 29d2c4832d
9 изменённых файлов: 43 добавлений и 1 удалений

Просмотреть файл

@ -8,6 +8,10 @@
"use strict"; "use strict";
add_task(async function() { add_task(async function() {
await SpecialPowers.pushPrefEnv({
set: [["dom.indexedDB.storageOption.enabled", true]]
});
const TESTPAGE = MAIN_DOMAIN + "storage-indexeddb-duplicate-names.html"; const TESTPAGE = MAIN_DOMAIN + "storage-indexeddb-duplicate-names.html";
setPermission(TESTPAGE, "indexedDB"); setPermission(TESTPAGE, "indexedDB");

Просмотреть файл

@ -41,6 +41,7 @@ DOM_PREF(ResistFingerprintingEnabled, "privacy.resistFingerprinting")
DOM_PREF(EnableAutoDeclineCanvasPrompts, "privacy.resistFingerprinting.autoDeclineNoUserInputCanvasPrompts") DOM_PREF(EnableAutoDeclineCanvasPrompts, "privacy.resistFingerprinting.autoDeclineNoUserInputCanvasPrompts")
DOM_PREF(DevToolsEnabled, "devtools.enabled") DOM_PREF(DevToolsEnabled, "devtools.enabled")
DOM_PREF(PerformanceObserverEnabled, "dom.enable_performance_observer") DOM_PREF(PerformanceObserverEnabled, "dom.enable_performance_observer")
DOM_PREF(IndexedDBStorageOptionsEnabled, "dom.indexedDB.storageOption.enabled")
DOM_WEBIDL_PREF(ImageBitmapExtensionsEnabled) DOM_WEBIDL_PREF(ImageBitmapExtensionsEnabled)
DOM_WEBIDL_PREF(DOMCachesEnabled) DOM_WEBIDL_PREF(DOMCachesEnabled)

Просмотреть файл

@ -701,11 +701,27 @@ IDBFactory::OpenInternal(JSContext* aCx,
isInternal = QuotaManager::IsOriginInternal(origin); isInternal = QuotaManager::IsOriginInternal(origin);
} }
// Allow storage attributes for add-ons independent of the pref.
// This works in the main thread only, workers don't have the principal.
bool isAddon = false;
if (NS_IsMainThread()) {
// aPrincipal is passed inconsistently, so even when we are already on
// the main thread, we may have been passed a null aPrincipal.
nsCOMPtr<nsIPrincipal> principal = PrincipalInfoToPrincipal(principalInfo);
if (principal) {
nsAutoString addonId;
Unused << NS_WARN_IF(NS_FAILED(principal->GetAddonId(addonId)));
isAddon = !addonId.IsEmpty();
}
}
if (isInternal) { if (isInternal) {
// Chrome privilege and internal origins always get persistent storage. // Chrome privilege and internal origins always get persistent storage.
persistenceType = PERSISTENCE_TYPE_PERSISTENT; persistenceType = PERSISTENCE_TYPE_PERSISTENT;
} else { } else if (isAddon || DOMPrefs::IndexedDBStorageOptionsEnabled()) {
persistenceType = PersistenceTypeFromStorage(aStorageType); persistenceType = PersistenceTypeFromStorage(aStorageType);
} else {
persistenceType = PERSISTENCE_TYPE_DEFAULT;
} }
DatabaseMetadata& metadata = commonParams.metadata(); DatabaseMetadata& metadata = commonParams.metadata();

Просмотреть файл

@ -1,4 +1,6 @@
[DEFAULT] [DEFAULT]
prefs =
dom.indexedDB.storageOption.enabled=true
skip-if = (buildapp != "browser") skip-if = (buildapp != "browser")
support-files = support-files =
head.js head.js

Просмотреть файл

@ -3,6 +3,8 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
[DEFAULT] [DEFAULT]
prefs =
dom.indexedDB.storageOption.enabled=true
support-files = support-files =
bfcache_page1.html bfcache_page1.html
bfcache_page2.html bfcache_page2.html

Просмотреть файл

@ -7,6 +7,11 @@ var testGenerator = testSteps();
function* testSteps() function* testSteps()
{ {
Services.prefs.setBoolPref("dom.indexedDB.storageOption.enabled", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("dom.indexedDB.storageOption.enabled");
});
const openParams = [ const openParams = [
// This one lives in storage/default/http+++localhost // This one lives in storage/default/http+++localhost
{ url: "http://localhost", dbName: "dbA", dbVersion: 1 }, { url: "http://localhost", dbName: "dbA", dbVersion: 1 },

Просмотреть файл

@ -7,6 +7,11 @@ var testGenerator = testSteps();
function* testSteps() function* testSteps()
{ {
Services.prefs.setBoolPref("dom.indexedDB.storageOption.enabled", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("dom.indexedDB.storageOption.enabled");
});
const openParams = [ const openParams = [
// This one lives in storage/permanent/chrome // This one lives in storage/permanent/chrome
// The .metadata-v2 file was intentionally removed for this origin directory // The .metadata-v2 file was intentionally removed for this origin directory

Просмотреть файл

@ -7,6 +7,11 @@ var testGenerator = testSteps();
function* testSteps() function* testSteps()
{ {
Services.prefs.setBoolPref("dom.indexedDB.storageOption.enabled", true);
registerCleanupFunction(() => {
Services.prefs.clearUserPref("dom.indexedDB.storageOption.enabled");
});
const openParams = [ const openParams = [
// This one lives in storage/permanent/chrome // This one lives in storage/permanent/chrome
{ dbName: "dbA", { dbName: "dbA",

Просмотреть файл

@ -138,6 +138,8 @@ pref("dom.indexedDB.logging.enabled", true);
pref("dom.indexedDB.logging.details", true); pref("dom.indexedDB.logging.details", true);
// Enable profiler marks for indexedDB events. // Enable profiler marks for indexedDB events.
pref("dom.indexedDB.logging.profiler-marks", false); pref("dom.indexedDB.logging.profiler-marks", false);
// Enable passing the "storage" option to indexedDB.open.
pref("dom.indexedDB.storageOption.enabled", false);
// Whether or not File Handle is enabled. // Whether or not File Handle is enabled.
pref("dom.fileHandle.enabled", true); pref("dom.fileHandle.enabled", true);