Backed out changeset 74293125739a (bug 1176341)

This commit is contained in:
Wes Kocher
2015-07-10 12:48:20 -07:00
parent ef09d26bc0
commit 421260e747
8 changed files with 55 additions and 35 deletions

View File

@@ -34,7 +34,7 @@ namespace {
already_AddRefed<CacheStorage>
CreateCacheStorage(nsIPrincipal* aPrincipal, ErrorResult& aRv,
JS::MutableHandle<JSObject*>* aSandbox = nullptr)
nsIXPConnectJSObjectHolder** aHolder = nullptr)
{
AssertIsOnMainThread();
MOZ_ASSERT(aPrincipal);
@@ -44,20 +44,21 @@ CreateCacheStorage(nsIPrincipal* aPrincipal, ErrorResult& aRv,
AutoJSAPI jsapi;
jsapi.Init();
JS::Rooted<JSObject*> sandbox(jsapi.cx());
aRv = xpc->CreateSandbox(jsapi.cx(), aPrincipal, sandbox.address());
nsCOMPtr<nsIXPConnectJSObjectHolder> sandbox;
aRv = xpc->CreateSandbox(jsapi.cx(), aPrincipal, getter_AddRefs(sandbox));
if (NS_WARN_IF(aRv.Failed())) {
return nullptr;
}
nsCOMPtr<nsIGlobalObject> sandboxGlobalObject = xpc::NativeGlobal(sandbox);
nsCOMPtr<nsIGlobalObject> sandboxGlobalObject =
xpc::NativeGlobal(sandbox->GetJSObject());
if (!sandboxGlobalObject) {
aRv.Throw(NS_ERROR_FAILURE);
return nullptr;
}
if (aSandbox) {
aSandbox->set(sandbox);
if (aHolder) {
sandbox.forget(aHolder);
}
// We assume private browsing is not enabled here. The ScriptLoader
@@ -319,8 +320,7 @@ public:
// Always create a CacheStorage since we want to write the network entry to
// the cache even if there isn't an existing one.
ErrorResult result;
JS::MutableHandle<JSObject*> sandboxHandle(&mSandbox);
mCacheStorage = CreateCacheStorage(aPrincipal, result, &sandboxHandle);
mCacheStorage = CreateCacheStorage(aPrincipal, result, getter_AddRefs(mSandbox));
if (NS_WARN_IF(result.Failed())) {
MOZ_ASSERT(!result.IsErrorWithMessage());
return result.StealNSResult();
@@ -621,7 +621,7 @@ private:
}
nsRefPtr<CompareCallback> mCallback;
JS::PersistentRooted<JSObject*> mSandbox;
nsCOMPtr<nsIXPConnectJSObjectHolder> mSandbox;
nsRefPtr<CacheStorage> mCacheStorage;
nsRefPtr<CompareNetwork> mCN;