already_AddRefed<IDBTransaction> IDBDatabase::Transaction(const StringOrStringSequence& aStoreNames, IDBTransactionMode aMode, ErrorResult& aRv) { AssertIsOnOwningThread(); aRv.MightThrowJSException(); if (aMode == IDBTransactionMode::Readwriteflush && !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<JS::Value> exception(cx); MOZ_ALWAYS_TRUE(JS_GetPendingException(cx, &exception)); aRv.ThrowJSException(cx, exception); return nullptr; } RefPtr<IDBTransaction> transaction; aRv = Transaction(aStoreNames, aMode, getter_AddRefs(transaction)); if (NS_WARN_IF(aRv.Failed())) { return nullptr; } return transaction.forget(); }