Bug 1216697 - Unship Request.cache until the implementation is finished; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2015-10-23 10:25:03 -04:00
parent 5c06455625
commit 383397be38
11 changed files with 67 additions and 2 deletions

View File

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

View File

@ -36,6 +36,8 @@ public:
static bool
RequestContextEnabled(JSContext* aCx, JSObject* aObj);
static bool
RequestCacheEnabled(JSContext* aCx, JSObject* aObj);
JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override

View File

@ -7,7 +7,8 @@ function testScript(script) {
function setupPrefs() {
return new Promise(function(resolve, reject) {
SpecialPowers.pushPrefEnv({
"set": [["dom.requestcontext.enabled", true],
"set": [["dom.requestcache.enabled", true],
["dom.requestcontext.enabled", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true]]

View File

@ -36,6 +36,7 @@ skip-if = buildapp == 'b2g' || (toolkit == 'android' && debug) # Bug 1137683 &&
[test_formdataparsing_sw_reroute.html]
skip-if = buildapp == 'b2g' # Bug 1137683
[test_request.html]
[test_request_cache.html]
[test_request_context.html]
[test_request_sw_reroute.html]
skip-if = buildapp == 'b2g' # Bug 1137683

View File

@ -10,7 +10,8 @@ function testScript(script) {
}
SpecialPowers.pushPrefEnv({
"set": [["dom.serviceWorkers.enabled", true],
"set": [["dom.requestcache.enabled", true],
["dom.serviceWorkers.enabled", true],
["dom.serviceWorkers.interception.opaque.enabled", true],
["dom.serviceWorkers.testing.enabled", true],
["dom.serviceWorkers.exemptFromPerDomainMax", true]]

View File

@ -0,0 +1,19 @@
<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<!DOCTYPE HTML>
<html>
<head>
<title>Make sure that Request.cache is not exposed by default</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<script>
var req = new Request("");
ok(!("cache" in req), "Request.cache should not be exposed by default");
</script>
</body>
</html>

View File

@ -22,6 +22,7 @@ interface Request {
readonly attribute DOMString referrer;
readonly attribute RequestMode mode;
readonly attribute RequestCredentials credentials;
[Func="mozilla::dom::Request::RequestCacheEnabled"]
readonly attribute RequestCache cache;
readonly attribute RequestRedirect redirect;

View File

@ -169,6 +169,7 @@ static_assert(MAX_WORKERS_PER_DOMAIN >= 1,
#define PREF_INTERCEPTION_ENABLED "dom.serviceWorkers.interception.enabled"
#define PREF_INTERCEPTION_OPAQUE_ENABLED "dom.serviceWorkers.interception.opaque.enabled"
#define PREF_PUSH_ENABLED "dom.push.enabled"
#define PREF_REQUESTCACHE_ENABLED "dom.requestcache.enabled"
#define PREF_REQUESTCONTEXT_ENABLED "dom.requestcontext.enabled"
#define PREF_OFFSCREENCANVAS_ENABLED "gfx.offscreencanvas.enabled"
@ -1960,6 +1961,10 @@ RuntimeService::Init()
WorkerPrefChanged,
PREF_PUSH_ENABLED,
reinterpret_cast<void *>(WORKERPREF_PUSH))) ||
NS_FAILED(Preferences::RegisterCallbackAndCall(
WorkerPrefChanged,
PREF_REQUESTCACHE_ENABLED,
reinterpret_cast<void *>(WORKERPREF_REQUESTCACHE))) ||
NS_FAILED(Preferences::RegisterCallbackAndCall(
WorkerPrefChanged,
PREF_REQUESTCONTEXT_ENABLED,
@ -2203,6 +2208,10 @@ RuntimeService::Cleanup()
WorkerPrefChanged,
PREF_PUSH_ENABLED,
reinterpret_cast<void *>(WORKERPREF_PUSH))) ||
NS_FAILED(Preferences::UnregisterCallback(
WorkerPrefChanged,
PREF_REQUESTCACHE_ENABLED,
reinterpret_cast<void *>(WORKERPREF_REQUESTCACHE))) ||
NS_FAILED(Preferences::UnregisterCallback(
WorkerPrefChanged,
PREF_REQUESTCONTEXT_ENABLED,
@ -2788,6 +2797,7 @@ RuntimeService::WorkerPrefChanged(const char* aPrefName, void* aClosure)
case WORKERPREF_SERVICEWORKERS:
case WORKERPREF_SERVICEWORKERS_TESTING:
case WORKERPREF_PUSH:
case WORKERPREF_REQUESTCACHE:
case WORKERPREF_REQUESTCONTEXT:
case WORKERPREF_OFFSCREENCANVAS:
sDefaultPreferences[key] = Preferences::GetBool(aPrefName, false);

View File

@ -1307,6 +1307,13 @@ public:
return mPreferences[WORKERPREF_PUSH];
}
bool
RequestCacheEnabled() const
{
AssertIsOnWorkerThread();
return mPreferences[WORKERPREF_REQUESTCACHE];
}
bool
RequestContextEnabled() const
{

View File

@ -208,6 +208,7 @@ enum WorkerPreference
WORKERPREF_INTERCEPTION_OPAQUE_ENABLED, // dom.serviceWorkers.interception.opaque.enabled
WORKERPREF_PERFORMANCE_LOGGING_ENABLED, // dom.performance.enable_user_timing_logging
WORKERPREF_PUSH, // dom.push.enabled
WORKERPREF_REQUESTCACHE, // dom.requestcache.enabled
WORKERPREF_REQUESTCONTEXT, // dom.requestcontext.enabled
WORKERPREF_OFFSCREENCANVAS, // gfx.offscreencanvas.enabled
WORKERPREF_COUNT

View File

@ -5098,6 +5098,9 @@ pref("memory.report_concurrency", 10);
// Add Mozilla AudioChannel APIs.
pref("media.useAudioChannelAPI", false);
// Expose Request.cache. Currently disabled since the implementation is incomplete.
pref("dom.requestcache.enabled", false);
// Expose Request.context. Currently disabled since the spec is in flux.
pref("dom.requestcontext.enabled", false);