mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1184607 P7.6 Expose CacheStorage .caches property on xpcshell global. r=smaug
* * * 7.6 interdiff
This commit is contained in:
parent
40781e8295
commit
2ffa8b7ffc
35
dom/cache/CacheStorage.cpp
vendored
35
dom/cache/CacheStorage.cpp
vendored
@ -239,6 +239,41 @@ CacheStorage::CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
|
||||
return ref.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
bool
|
||||
CacheStorage::DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal)
|
||||
{
|
||||
MOZ_ASSERT(NS_IsMainThread());
|
||||
MOZ_ASSERT(js::GetObjectClass(aGlobal)->flags & JSCLASS_DOM_GLOBAL,
|
||||
"Passed object is not a global object!");
|
||||
|
||||
if (NS_WARN_IF(!CacheStorageBinding::GetConstructorObject(aCx, aGlobal) ||
|
||||
!CacheBinding::GetConstructorObject(aCx, aGlobal))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
nsIPrincipal* principal = nsContentUtils::ObjectPrincipal(aGlobal);
|
||||
MOZ_ASSERT(principal);
|
||||
|
||||
ErrorResult rv;
|
||||
nsRefPtr<CacheStorage> storage =
|
||||
CreateOnMainThread(DEFAULT_NAMESPACE, xpc::NativeGlobal(aGlobal), principal,
|
||||
false, /* private browsing */
|
||||
true, /* force trusted */
|
||||
rv);
|
||||
if (NS_WARN_IF(rv.Failed())) {
|
||||
return ThrowMethodFailed(aCx, rv);
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> caches(aCx);
|
||||
js::AssertSameCompartment(aCx, aGlobal);
|
||||
if (NS_WARN_IF(!ToJSValue(aCx, storage, &caches))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return JS_DefineProperty(aCx, aGlobal, "caches", caches, JSPROP_ENUMERATE);
|
||||
}
|
||||
|
||||
CacheStorage::CacheStorage(Namespace aNamespace, nsIGlobalObject* aGlobal,
|
||||
const PrincipalInfo& aPrincipalInfo, Feature* aFeature)
|
||||
: mNamespace(aNamespace)
|
||||
|
3
dom/cache/CacheStorage.h
vendored
3
dom/cache/CacheStorage.h
vendored
@ -56,6 +56,9 @@ public:
|
||||
CreateOnWorker(Namespace aNamespace, nsIGlobalObject* aGlobal,
|
||||
workers::WorkerPrivate* aWorkerPrivate, ErrorResult& aRv);
|
||||
|
||||
static bool
|
||||
DefineCaches(JSContext* aCx, JS::Handle<JSObject*> aGlobal);
|
||||
|
||||
// webidl interface methods
|
||||
already_AddRefed<Promise> Match(const RequestOrUSVString& aRequest,
|
||||
const CacheQueryOptions& aOptions,
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include "Crypto.h"
|
||||
#include "mozilla/dom/BindingUtils.h"
|
||||
#include "mozilla/dom/BlobBinding.h"
|
||||
#include "mozilla/dom/cache/CacheStorage.h"
|
||||
#include "mozilla/dom/CSSBinding.h"
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
|
||||
#include "mozilla/dom/Fetch.h"
|
||||
@ -907,6 +908,8 @@ xpc::GlobalProperties::Parse(JSContext* cx, JS::HandleObject obj)
|
||||
#endif
|
||||
} else if (!strcmp(name.ptr(), "fetch")) {
|
||||
fetch = true;
|
||||
} else if (!strcmp(name.ptr(), "caches")) {
|
||||
caches = true;
|
||||
} else {
|
||||
JS_ReportError(cx, "Unknown property name: %s", name.ptr());
|
||||
return false;
|
||||
@ -972,6 +975,9 @@ xpc::GlobalProperties::Define(JSContext* cx, JS::HandleObject obj)
|
||||
if (fetch && !SandboxCreateFetch(cx, obj))
|
||||
return false;
|
||||
|
||||
if (caches && !dom::cache::CacheStorage::DefineCaches(cx, obj))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -3418,6 +3418,7 @@ struct GlobalProperties {
|
||||
bool crypto : 1;
|
||||
bool rtcIdentityProvider : 1;
|
||||
bool fetch : 1;
|
||||
bool caches : 1;
|
||||
};
|
||||
|
||||
// Infallible.
|
||||
|
Loading…
Reference in New Issue
Block a user