From 5ebb7a4795ee59b70266ec9a1373ef144be49e76 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 23 Mar 2016 11:02:57 -0400 Subject: [PATCH] Bug 1257725 part 4. Get rid of ThreadsafeAutoJSContext usage in IndexedDB code, except for IDBRequest::CaptureCaller. r=khuey --- dom/indexedDB/IDBDatabase.cpp | 24 ++++-------------------- dom/indexedDB/IndexedDatabaseManager.cpp | 3 +-- 2 files changed, 5 insertions(+), 22 deletions(-) diff --git a/dom/indexedDB/IDBDatabase.cpp b/dom/indexedDB/IDBDatabase.cpp index c72a4921517b..08351d77ad0f 100644 --- a/dom/indexedDB/IDBDatabase.cpp +++ b/dom/indexedDB/IDBDatabase.cpp @@ -607,32 +607,16 @@ IDBDatabase::Transaction(const StringOrStringSequence& aStoreNames, { AssertIsOnOwningThread(); - aRv.MightThrowJSException(); - if ((aMode == IDBTransactionMode::Readwriteflush || aMode == IDBTransactionMode::Cleanup) && !IndexedDatabaseManager::ExperimentalFeaturesEnabled()) { // Pretend that this mode doesn't exist. We don't have a way to annotate // certain enum values as depending on preferences so we just duplicate the // normal exception generation here. - ThreadsafeAutoJSContext cx; - - // Disable any automatic error reporting that might be set up so that we - // can grab the exception object. - AutoForceSetExceptionOnContext forceExn(cx); - - MOZ_ALWAYS_FALSE( - ThrowErrorMessage(cx, - MSG_INVALID_ENUM_VALUE, - "Argument 2 of IDBDatabase.transaction", - "readwriteflush", - "IDBTransactionMode")); - MOZ_ASSERT(JS_IsExceptionPending(cx)); - - JS::Rooted exception(cx); - MOZ_ALWAYS_TRUE(JS_GetPendingException(cx, &exception)); - - aRv.ThrowJSException(cx, exception); + aRv.ThrowTypeError( + NS_LITERAL_STRING("Argument 2 of IDBDatabase.transaction"), + NS_LITERAL_STRING("readwriteflush"), + NS_LITERAL_STRING("IDBTransactionMode")); return nullptr; } diff --git a/dom/indexedDB/IndexedDatabaseManager.cpp b/dom/indexedDB/IndexedDatabaseManager.cpp index eaa38e16ec80..b6061bc549e0 100644 --- a/dom/indexedDB/IndexedDatabaseManager.cpp +++ b/dom/indexedDB/IndexedDatabaseManager.cpp @@ -484,8 +484,7 @@ IndexedDatabaseManager::CommonPostHandleEvent(EventChainPostVisitor& aVisitor, error->GetName(errorName); } - ThreadsafeAutoJSContext cx; - RootedDictionary init(cx); + RootedDictionary init(nsContentUtils::RootingCxForThread()); request->GetCallerLocation(init.mFilename, &init.mLineno, &init.mColno); init.mMessage = errorName;