Bug 1304966 - Enable Storage API only for nightly bulid, r=baku

This commit is contained in:
Shawn Huang 2016-10-26 21:38:08 +08:00
parent d4c390f1b6
commit d93d31503b
9 changed files with 39 additions and 3 deletions

View File

@ -88,7 +88,8 @@ SimpleTest.waitForExplicitFinish();
SpecialPowers.pushPrefEnv({
"set": [["dom.caches.enabled", true],
["dom.caches.testing.enabled", true],
["dom.quotaManager.testing", true]],
["dom.quotaManager.testing", true],
["dom.storageManager.enabled", true]],
}, function() {
var name = 'orphanedBodyOwner';
var cache = null;

View File

@ -14,6 +14,6 @@
</head>
<body onload="runTest();"></body>
<body onload="setup();"></body>
</html>

View File

@ -54,3 +54,10 @@ function testSteps()
finishTest();
yield undefined;
}
function setup()
{
SpecialPowers.pushPrefEnv({
"set": [["dom.storageManager.enabled", true]]
}, runTest);
}

View File

@ -332,6 +332,20 @@ StorageManager::Estimate(ErrorResult& aRv)
return promise.forget();
}
// 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_COLLECTING_ADDREF(StorageManager)

View File

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

View File

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

View File

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

View File

@ -34,6 +34,7 @@ WORKER_SIMPLE_PREF("dom.webnotifications.requireinteraction.enabled", DOMWorkerN
WORKER_SIMPLE_PREF("dom.serviceWorkers.enabled", ServiceWorkersEnabled, SERVICEWORKERS_ENABLED)
WORKER_SIMPLE_PREF("dom.serviceWorkers.testing.enabled", ServiceWorkersTestingEnabled, SERVICEWORKERS_TESTING_ENABLED)
WORKER_SIMPLE_PREF("dom.serviceWorkers.openWindow.enabled", OpenWindowEnabled, OPEN_WINDOW_ENABLED)
WORKER_SIMPLE_PREF("dom.storageManager.enabled", StorageManagerEnabled, STORAGEMANAGER_ENABLED)
WORKER_SIMPLE_PREF("dom.push.enabled", PushEnabled, PUSH_ENABLED)
WORKER_SIMPLE_PREF("dom.requestcontext.enabled", RequestContextEnabled, REQUESTCONTEXT_ENABLED)
WORKER_SIMPLE_PREF("gfx.offscreencanvas.enabled", OffscreenCanvasEnabled, OFFSCREENCANVAS_ENABLED)

View File

@ -5513,3 +5513,10 @@ pref("security.mixed_content.use_hsts", false);
// mixed-content blocking
pref("security.mixed_content.use_hsts", true);
#endif
// Disable Storage api in release builds.
#ifdef NIGHTLY_BUILD
pref("dom.storageManager.enabled", true);
#else
pref("dom.storageManager.enabled", false);
#endif