Bug 888598 - Move IDBTransaction to WebIDL, r=janv

This commit is contained in:
Andrea Marchesini 2013-07-29 19:12:21 +02:00
parent 755b40d4bb
commit 59c5192f42
40 changed files with 191 additions and 195 deletions

View File

@ -54,7 +54,6 @@ exports.indexedDB = Object.freeze({
exports.IDBKeyRange = IDBKeyRange;
exports.DOMException = Ci.nsIDOMDOMException;
exports.IDBCursor = Ci.nsIIDBCursor;
exports.IDBTransaction = Ci.nsIIDBTransaction;
exports.IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
exports.IDBDatabase = Ci.nsIIDBDatabase;
exports.IDBIndex = Ci.nsIIDBIndex;

View File

@ -8,7 +8,7 @@ let xulApp = require("sdk/system/xul-app");
if (xulApp.versionInRange(xulApp.platformVersion, "16.0a1", "*")) {
new function tests() {
const { indexedDB, IDBKeyRange, DOMException, IDBCursor, IDBTransaction,
const { indexedDB, IDBKeyRange, DOMException, IDBCursor,
IDBOpenDBRequest, IDBDatabase, IDBIndex, IDBObjectStore, IDBRequest
} = require("sdk/indexed-db");
@ -22,7 +22,7 @@ exports["test indexedDB is frozen"] = function(assert){
};
exports["test db variables"] = function(assert) {
[ indexedDB, IDBKeyRange, DOMException, IDBCursor, IDBTransaction,
[ indexedDB, IDBKeyRange, DOMException, IDBCursor,
IDBOpenDBRequest, IDBOpenDBRequest, IDBDatabase, IDBIndex,
IDBObjectStore, IDBRequest
].forEach(function(value) {

View File

@ -198,7 +198,6 @@
#include "mozilla/dom/indexedDB/IDBRequest.h"
#include "mozilla/dom/indexedDB/IDBDatabase.h"
#include "mozilla/dom/indexedDB/IDBObjectStore.h"
#include "mozilla/dom/indexedDB/IDBTransaction.h"
#include "mozilla/dom/indexedDB/IDBCursor.h"
#include "mozilla/dom/indexedDB/IDBKeyRange.h"
#include "mozilla/dom/indexedDB/IDBIndex.h"
@ -628,8 +627,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBTransaction, IDBEventTargetSH,
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH,
DOM_DEFAULT_SCRIPTABLE_FLAGS)
NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH,
@ -1525,11 +1522,6 @@ nsDOMClassInfo::Init()
DOM_CLASSINFO_MAP_ENTRY(nsIIDBObjectStore)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBTransaction, nsIIDBTransaction)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBTransaction)
DOM_CLASSINFO_MAP_ENTRY(nsIDOMEventTarget)
DOM_CLASSINFO_MAP_END
DOM_CLASSINFO_MAP_BEGIN(IDBCursor, nsIIDBCursor)
DOM_CLASSINFO_MAP_ENTRY(nsIIDBCursor)
DOM_CLASSINFO_MAP_END
@ -2837,7 +2829,7 @@ DefineInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj, const nsIID *
}
// This code is temporary until we remove support for the constants defined
// on IDBCursor/IDBRequest/IDBTransaction
// on IDBCursor/IDBRequest
struct IDBConstant
{
@ -2847,23 +2839,18 @@ struct IDBConstant
static const char* IDBCursor;
static const char* IDBRequest;
static const char* IDBTransaction;
};
const char* IDBConstant::IDBCursor = "IDBCursor";
const char* IDBConstant::IDBRequest = "IDBRequest";
const char* IDBConstant::IDBTransaction = "IDBTransaction";
static const IDBConstant sIDBConstants[] = {
{ IDBConstant::IDBCursor, "NEXT", "next" },
{ IDBConstant::IDBCursor, "NEXT_NO_DUPLICATE", "nextunique" },
{ IDBConstant::IDBCursor, "PREV", "prev" },
{ IDBConstant::IDBCursor, "PREV_NO_DUPLICATE", "prevunique" },
{ IDBConstant::IDBRequest, "LOADING", "pending" },
{ IDBConstant::IDBRequest, "DONE", "done" },
{ IDBConstant::IDBTransaction, "READ_ONLY", "readonly" },
{ IDBConstant::IDBTransaction, "READ_WRITE", "readwrite" },
{ IDBConstant::IDBTransaction, "VERSION_CHANGE", "versionchange" },
{ IDBConstant::IDBCursor, "NEXT", "next" },
{ IDBConstant::IDBCursor, "NEXT_NO_DUPLICATE", "nextunique" },
{ IDBConstant::IDBCursor, "PREV", "prev" },
{ IDBConstant::IDBCursor, "PREV_NO_DUPLICATE", "prevunique" },
{ IDBConstant::IDBRequest, "LOADING", "pending" },
{ IDBConstant::IDBRequest, "DONE", "done" },
};
static JSBool
@ -2957,9 +2944,6 @@ DefineIDBInterfaceConstants(JSContext *cx, JS::Handle<JSObject*> obj, const nsII
else if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
interface = IDBConstant::IDBRequest;
}
else if (aIID->Equals(NS_GET_IID(nsIIDBTransaction))) {
interface = IDBConstant::IDBTransaction;
}
else {
MOZ_CRASH("unexpected IID");
}
@ -3382,8 +3366,7 @@ nsDOMConstructor::ResolveInterfaceConstants(JSContext *cx, JS::Handle<JSObject*>
// Special case a few IDB interfaces which for now are getting transitional
// constants.
if (class_iid->Equals(NS_GET_IID(nsIIDBCursor)) ||
class_iid->Equals(NS_GET_IID(nsIIDBRequest)) ||
class_iid->Equals(NS_GET_IID(nsIIDBTransaction))) {
class_iid->Equals(NS_GET_IID(nsIIDBRequest))) {
rv = DefineIDBInterfaceConstants(cx, obj, class_iid);
NS_ENSURE_SUCCESS(rv, rv);
}
@ -3521,8 +3504,7 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
// Special case a few IDB interfaces which for now are getting transitional
// constants.
if (primary_iid->Equals(NS_GET_IID(nsIIDBCursor)) ||
primary_iid->Equals(NS_GET_IID(nsIIDBRequest)) ||
primary_iid->Equals(NS_GET_IID(nsIIDBTransaction))) {
primary_iid->Equals(NS_GET_IID(nsIIDBRequest))) {
rv = DefineIDBInterfaceConstants(cx, class_obj, primary_iid);
NS_ENSURE_SUCCESS(rv, rv);
}

View File

@ -122,7 +122,6 @@ DOMCI_CLASS(ChromeMessageSender)
DOMCI_CLASS(IDBRequest)
DOMCI_CLASS(IDBDatabase)
DOMCI_CLASS(IDBObjectStore)
DOMCI_CLASS(IDBTransaction)
DOMCI_CLASS(IDBCursor)
DOMCI_CLASS(IDBCursorWithValue)
DOMCI_CLASS(IDBKeyRange)

View File

@ -546,6 +546,10 @@ DOMInterfaces = {
'nativeType': 'mozilla::dom::indexedDB::IDBFileHandle',
},
'IDBTransaction': {
'nativeType': 'mozilla::dom::indexedDB::IDBTransaction',
},
'IDBVersionChangeEvent': {
'nativeType': 'mozilla::dom::indexedDB::IDBVersionChangeEvent',
'headerFile': 'IDBEvents.h',
@ -1656,6 +1660,7 @@ addExternalIface('FileCallback', nativeType='nsIFileCallback',
headerFile='nsIDOMHTMLCanvasElement.h')
addExternalIface('HitRegionOptions', nativeType='nsISupports')
addExternalIface('IDBDatabase', nativeType='nsIIDBDatabase')
addExternalIface('IDBObjectStore', nativeType='nsIIDBObjectStore')
addExternalIface('IDBOpenDBRequest', nativeType='nsIIDBOpenDBRequest')
addExternalIface('imgINotificationObserver', nativeType='imgINotificationObserver')
addExternalIface('imgIRequest', nativeType='imgIRequest', notflattened=True)

View File

@ -176,8 +176,7 @@ AsyncConnectionHelper::~AsyncConnectionHelper()
NS_ProxyRelease(mainThread, static_cast<nsIIDBDatabase*>(database));
}
if (transaction) {
NS_ProxyRelease(mainThread,
static_cast<nsIIDBTransaction*>(transaction));
NS_ProxyRelease(mainThread, static_cast<IDBWrapperCache*>(transaction));
}
}
}

View File

@ -624,7 +624,7 @@ IDBDatabase::Transaction(const jsval& aStoreNames,
const nsAString& aMode,
JSContext* aCx,
uint8_t aOptionalArgCount,
nsIIDBTransaction** _retval)
nsISupports** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -758,7 +758,8 @@ IDBDatabase::Transaction(const jsval& aStoreNames,
transaction->GetSerialNumber(), IDB_PROFILER_STRING(this),
IDB_PROFILER_STRING(transaction));
transaction.forget(_retval);
nsRefPtr<IDBWrapperCache> tmp = transaction.get();
tmp.forget(_retval);
return NS_OK;
}

View File

@ -2405,11 +2405,11 @@ IDBObjectStore::GetKeyPath(JSContext* aCx,
}
NS_IMETHODIMP
IDBObjectStore::GetTransaction(nsIIDBTransaction** aTransaction)
IDBObjectStore::GetTransaction(nsISupports** aTransaction)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsCOMPtr<nsIIDBTransaction> transaction(mTransaction);
nsRefPtr<IDBWrapperCache> transaction(mTransaction);
transaction.forget(aTransaction);
return NS_OK;
}

View File

@ -10,7 +10,6 @@
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
#include "nsIIDBObjectStore.h"
#include "nsIIDBTransaction.h"
#include "nsCycleCollectionParticipant.h"

View File

@ -255,11 +255,11 @@ IDBRequest::GetSource(nsISupports** aSource)
}
NS_IMETHODIMP
IDBRequest::GetTransaction(nsIIDBTransaction** aTransaction)
IDBRequest::GetTransaction(nsISupports** aTransaction)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsCOMPtr<nsIIDBTransaction> transaction(mTransaction);
nsRefPtr<IDBWrapperCache> transaction(mTransaction);
transaction.forget(aTransaction);
return NS_OK;
}

View File

@ -39,6 +39,7 @@
using namespace mozilla::dom;
USING_INDEXEDDB_NAMESPACE
using mozilla::dom::quota::QuotaManager;
using mozilla::ErrorResult;
namespace {
@ -178,6 +179,8 @@ IDBTransaction::IDBTransaction()
#endif
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
SetIsDOMBinding();
}
IDBTransaction::~IDBTransaction()
@ -616,9 +619,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBTransaction, IDBWrapperCache)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBTransaction)
NS_INTERFACE_MAP_ENTRY(nsIIDBTransaction)
NS_INTERFACE_MAP_ENTRY(nsIRunnable)
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBTransaction)
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
NS_IMPL_ADDREF_INHERITED(IDBTransaction, IDBWrapperCache)
@ -626,59 +627,49 @@ NS_IMPL_RELEASE_INHERITED(IDBTransaction, IDBWrapperCache)
DOMCI_DATA(IDBTransaction, IDBTransaction)
NS_IMPL_EVENT_HANDLER(IDBTransaction, error)
NS_IMPL_EVENT_HANDLER(IDBTransaction, complete)
NS_IMPL_EVENT_HANDLER(IDBTransaction, abort)
NS_IMETHODIMP
IDBTransaction::GetDb(nsIIDBDatabase** aDB)
JSObject*
IDBTransaction::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
NS_ADDREF(*aDB = mDatabase);
return NS_OK;
return IDBTransactionBinding::Wrap(aCx, aScope, this);
}
NS_IMETHODIMP
IDBTransaction::GetMode(nsAString& aMode)
mozilla::dom::IDBTransactionMode
IDBTransaction::GetMode(ErrorResult& aRv) const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
switch (mMode) {
case READ_ONLY:
aMode.AssignLiteral("readonly");
break;
return mozilla::dom::IDBTransactionMode::Readonly;
case READ_WRITE:
aMode.AssignLiteral("readwrite");
break;
return mozilla::dom::IDBTransactionMode::Readwrite;
case VERSION_CHANGE:
aMode.AssignLiteral("versionchange");
break;
return mozilla::dom::IDBTransactionMode::Versionchange;
case MODE_INVALID:
default:
NS_NOTREACHED("Bad mode value!");
return NS_ERROR_UNEXPECTED;
aRv.Throw(NS_ERROR_UNEXPECTED);
return mozilla::dom::IDBTransactionMode::Readonly;
}
return NS_OK;
}
NS_IMETHODIMP
IDBTransaction::GetError(nsISupports** aError)
DOMError*
IDBTransaction::GetError(ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (IsOpen()) {
return NS_ERROR_DOM_INVALID_STATE_ERR;
aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
return nullptr;
}
NS_IF_ADDREF(*aError = mError);
return NS_OK;
return mError;
}
NS_IMETHODIMP
IDBTransaction::GetObjectStoreNames(nsIDOMDOMStringList** aObjectStores)
already_AddRefed<nsIDOMDOMStringList>
IDBTransaction::GetObjectStoreNames(ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -698,38 +689,24 @@ IDBTransaction::GetObjectStoreNames(nsIDOMDOMStringList** aObjectStores)
uint32_t count = arrayOfNames->Length();
for (uint32_t index = 0; index < count; index++) {
NS_ENSURE_TRUE(list->Add(arrayOfNames->ElementAt(index)),
NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!list->Add(arrayOfNames->ElementAt(index))) {
NS_WARNING("Failed to add element!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
}
list.forget(aObjectStores);
return NS_OK;
return list.forget();
}
NS_IMETHODIMP
IDBTransaction::ObjectStore(const nsAString& aName,
nsIIDBObjectStore** _retval)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
nsRefPtr<IDBObjectStore> objectStore;
nsresult rv = ObjectStoreInternal(aName, getter_AddRefs(objectStore));
if (NS_FAILED(rv)) {
return rv;
}
objectStore.forget(_retval);
return NS_OK;
}
nsresult
IDBTransaction::ObjectStoreInternal(const nsAString& aName,
IDBObjectStore** _retval)
already_AddRefed<nsIIDBObjectStore>
IDBTransaction::ObjectStore(const nsAString& aName, ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
if (IsFinished()) {
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR);
return nullptr;
}
ObjectStoreInfo* info = nullptr;
@ -740,23 +717,19 @@ IDBTransaction::ObjectStoreInternal(const nsAString& aName,
}
if (!info) {
return NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR;
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_NOT_FOUND_ERR);
return nullptr;
}
nsRefPtr<IDBObjectStore> objectStore =
GetOrCreateObjectStore(aName, info, false);
NS_ENSURE_TRUE(objectStore, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
if (!objectStore) {
NS_WARNING("Failed to get or create object store!");
aRv.Throw(NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
return nullptr;
}
objectStore.forget(_retval);
return NS_OK;
}
NS_IMETHODIMP
IDBTransaction::Abort()
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return AbortInternal(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR, nullptr);
return objectStore.forget();
}
nsresult

View File

@ -13,7 +13,6 @@
#include "mozIStorageConnection.h"
#include "mozIStorageStatement.h"
#include "mozIStorageFunction.h"
#include "nsIIDBTransaction.h"
#include "mozilla/dom/DOMError.h"
#include "nsIRunnable.h"
@ -23,11 +22,13 @@
#include "nsInterfaceHashtable.h"
#include "nsRefPtrHashtable.h"
#include "mozilla/dom/IDBTransactionBinding.h"
#include "mozilla/dom/indexedDB/IDBDatabase.h"
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
#include "mozilla/dom/indexedDB/FileInfo.h"
class nsIThread;
class nsPIDOMWindow;
BEGIN_INDEXEDDB_NAMESPACE
@ -54,7 +55,6 @@ public:
};
class IDBTransaction : public IDBWrapperCache,
public nsIIDBTransaction,
public nsIRunnable
{
friend class AsyncConnectionHelper;
@ -65,7 +65,6 @@ class IDBTransaction : public IDBWrapperCache,
public:
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIIDBTRANSACTION
NS_DECL_NSIRUNNABLE
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction, IDBWrapperCache)
@ -197,10 +196,6 @@ public:
return mActorParent;
}
nsresult
ObjectStoreInternal(const nsAString& aName,
IDBObjectStore** _retval);
nsresult
Abort(IDBRequest* aRequest);
@ -221,6 +216,47 @@ public:
}
#endif
// nsWrapperCache
virtual JSObject*
WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope) MOZ_OVERRIDE;
// WebIDL
nsPIDOMWindow*
GetParentObject() const
{
return GetOwner();
}
IDBTransactionMode
GetMode(ErrorResult& aRv) const;
nsIIDBDatabase*
Db() const
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
return mDatabase;
}
DOMError*
GetError(ErrorResult& aRv);
already_AddRefed<nsIIDBObjectStore>
ObjectStore(const nsAString& aName, ErrorResult& aRv);
void
Abort(ErrorResult& aRv)
{
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
aRv = AbortInternal(NS_ERROR_DOM_INDEXEDDB_ABORT_ERR, nullptr);
}
IMPL_EVENT_HANDLER(abort)
IMPL_EVENT_HANDLER(complete)
IMPL_EVENT_HANDLER(error)
already_AddRefed<nsIDOMDOMStringList>
GetObjectStoreNames(ErrorResult& aRv);
private:
nsresult
AbortInternal(nsresult aAbortCode,

View File

@ -448,7 +448,8 @@ TransactionThreadPool::AbortTransactionsForDatabase(IDBDatabase* aDatabase)
// This can fail, for example if the transaction is in the process of
// being comitted. That is expected and fine, so we ignore any returned
// errors.
transactions[index]->Abort();
ErrorResult rv;
transactions[index]->Abort(rv);
}
}

View File

@ -468,7 +468,9 @@ IndexedDBDatabaseParent::HandleRequestEvent(nsIDOMEvent* aEvent,
// If we get here then the child process is either dead or in the process
// of being killed. Abort the transaction now to prevent any changes to
// the database.
if (NS_FAILED(transaction->Abort())) {
ErrorResult rv;
transaction->Abort(rv);
if (rv.Failed()) {
NS_WARNING("Failed to abort transaction!");
}
return NS_ERROR_FAILURE;
@ -717,7 +719,8 @@ IndexedDBTransactionParent::ActorDestroy(ActorDestroyReason aWhy)
if (mArtificialRequestCount) {
// The transaction never completed and now the child side is dead. Abort
// here to be safe.
mTransaction->Abort();
ErrorResult rv;
mTransaction->Abort(rv);
mTransaction->OnRequestFinished();
#ifdef DEBUG
@ -792,10 +795,14 @@ IndexedDBTransactionParent::RecvPIndexedDBObjectStoreConstructor(
{
AutoSetCurrentTransaction asct(mTransaction);
nsresult rv =
mTransaction->ObjectStoreInternal(name, getter_AddRefs(objectStore));
NS_ENSURE_SUCCESS(rv, false);
ErrorResult rv;
nsCOMPtr<nsIIDBObjectStore> store = mTransaction->ObjectStore(name, rv);
if (rv.Failed()) {
NS_WARNING("Failed to get object store!");
return false;
}
objectStore = static_cast<IDBObjectStore*>(store.get());
actor->SetObjectStore(objectStore);
}

View File

@ -16,7 +16,6 @@ XPIDL_SOURCES += [
'nsIIDBObjectStore.idl',
'nsIIDBOpenDBRequest.idl',
'nsIIDBRequest.idl',
'nsIIDBTransaction.idl',
'nsIIndexedDatabaseManager.idl',
]

View File

@ -8,7 +8,6 @@
interface nsIIDBObjectStore;
interface nsIIDBRequest;
interface nsIIDBTransaction;
interface nsIDOMDOMStringList;
interface nsIDOMEventListener;
@ -37,7 +36,7 @@ interface nsIIDBDatabase : nsISupports
// mode can be either "readonly" or "readwrite"
[optional_argc, implicit_jscontext]
nsIIDBTransaction
nsISupports
transaction(in jsval storeNames, // js array of strings
[optional /* "readonly" */] in DOMString mode);

View File

@ -9,7 +9,6 @@
interface nsIIDBIndex;
interface nsIIDBKeyRange;
interface nsIIDBRequest;
interface nsIIDBTransaction;
interface nsIDOMDOMStringList;
dictionary IDBIndexParameters
@ -33,7 +32,8 @@ interface nsIIDBObjectStore : nsISupports
readonly attribute nsIDOMDOMStringList indexNames;
readonly attribute nsIIDBTransaction transaction;
// IDBTransaction
readonly attribute nsISupports transaction;
readonly attribute boolean autoIncrement;

View File

@ -7,7 +7,6 @@
#include "nsISupports.idl"
interface nsIDOMEventListener;
interface nsIIDBTransaction;
/**
* IDBRequest interface. See
@ -24,7 +23,8 @@ interface nsIIDBRequest : nsISupports
readonly attribute nsISupports source;
readonly attribute nsIIDBTransaction transaction;
// This is a nsIIDBTransaction
readonly attribute nsISupports transaction;
// "pending" or "done"
readonly attribute DOMString readyState;

View File

@ -1,48 +0,0 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsISupports.idl"
interface nsIDOMEventListener;
interface nsIIDBObjectStore;
interface nsIIDBRequest;
interface nsIIDBDatabase;
interface nsIDOMDOMStringList;
/**
* IDBDTransaction interface. See
* http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBTransaction
* for more information.
*/
[scriptable, builtinclass, uuid(e17e36f6-a7d8-40b7-82d4-b54847169834)]
interface nsIIDBTransaction : nsISupports
{
readonly attribute nsIIDBDatabase db;
// "readonly", "readwrite" or "versionchange"
readonly attribute DOMString mode;
// This is a DOMError
readonly attribute nsISupports error;
readonly attribute nsIDOMDOMStringList objectStoreNames;
nsIIDBObjectStore
objectStore([Null(Stringify)] in DOMString name);
// Don't commit the transaction.
void abort();
[implicit_jscontext] attribute jsval onerror;
// Event listener that fires when the transaction is completed
// successfully. Receives an Event.
[implicit_jscontext] attribute jsval oncomplete;
// Event listener that fires when the transaction is aborted.
// Receives an Event.
[implicit_jscontext] attribute jsval onabort;
};

View File

@ -101,7 +101,7 @@
db.createObjectStore("foo", { autoIncrement: true });
yield undefined;
let transaction = db.transaction("foo", IDBTransaction.READ_WRITE);
let transaction = db.transaction("foo", "readwrite");
transaction.addEventListener("error", errorEventCounter, false);
transaction.addEventListener("error", errorEventCounter, true);
@ -119,7 +119,7 @@
request.onerror = errorEventCounter;
yield undefined;
transaction = db.transaction("foo", IDBTransaction.READ_WRITE);
transaction = db.transaction("foo", "readwrite");
transaction.addEventListener("error", errorEventCounter, false);
transaction.addEventListener("error", errorEventCounter, true);

View File

@ -17,7 +17,7 @@ function startDBWork() {
}
function madeMod() {
var trans = db.transaction(["mystore"], IDBTransaction.READ_WRITE);
var trans = db.transaction(["mystore"], "readwrite");
var store = trans.
objectStore("mystore");
trans.oncomplete = function() {

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const databaseInfo = [
{ name: window.location.pathname + "1" },

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const databaseInfo = [
{ name: window.location.pathname + "1" },

View File

@ -12,7 +12,7 @@
<script type="text/javascript;version=1.7">
function testSteps()
{
const READ_WRITE = IDBTransaction.READ_WRITE;
const READ_WRITE = "readwrite";
const name = window.location.pathname;

View File

@ -7,7 +7,6 @@ const { 'classes': Cc, 'interfaces': Ci } = Components;
const DOMException = Ci.nsIDOMDOMException;
const IDBCursor = Ci.nsIIDBCursor;
const IDBTransaction = Ci.nsIIDBTransaction;
const IDBOpenDBRequest = Ci.nsIIDBOpenDBRequest;
const IDBDatabase = Ci.nsIIDBDatabase
const IDBIndex = Ci.nsIIDBIndex

View File

@ -8,7 +8,6 @@ var testGenerator = testSteps();
function testSteps()
{
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
const nsIIDBTransaction = Components.interfaces.nsIIDBTransaction;
// Test object stores

View File

@ -0,0 +1,45 @@
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBTransaction
* https://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBTransactionMode
*/
interface IDBObjectStore;
enum IDBTransactionMode {
"readonly",
"readwrite",
"versionchange"
};
interface IDBTransaction : EventTarget {
[Throws]
readonly attribute IDBTransactionMode mode;
readonly attribute IDBDatabase db;
[Throws]
readonly attribute DOMError? error;
[Throws]
IDBObjectStore objectStore (DOMString name);
[Throws]
void abort();
[SetterThrows]
attribute EventHandler onabort;
[SetterThrows]
attribute EventHandler oncomplete;
[SetterThrows]
attribute EventHandler onerror;
};
// This seems to be custom
partial interface IDBTransaction {
[Throws]
readonly attribute DOMStringList objectStoreNames;
};

View File

@ -167,6 +167,7 @@ webidl_files = \
IDBDatabase.webidl \
IDBFactory.webidl \
IDBFileHandle.webidl \
IDBTransaction.webidl \
IDBVersionChangeEvent.webidl \
ImageData.webidl \
ImageDocument.webidl \

View File

@ -91,7 +91,6 @@ members = [
'nsIIDBKeyRange.*',
'nsIIDBObjectStore.*',
'nsIIDBRequest.*',
'nsIIDBTransaction.*',
'nsIIDBOpenDBRequest.*',
'nsIIndexedDatabaseManager.*',

View File

@ -35,6 +35,7 @@
#include "XPCQuickStubs.h"
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/dom/IDBTransactionBinding.h"
#include "mozilla/dom/IDBVersionChangeEventBinding.h"
#include "mozilla/dom/TextDecoderBinding.h"
#include "mozilla/dom/TextEncoderBinding.h"
@ -543,7 +544,8 @@ nsXPConnect::InitClassesWithNewWrappedGlobal(JSContext * aJSContext,
MOZ_ASSERT(js::GetObjectClass(global)->flags & JSCLASS_DOM_GLOBAL);
// Init WebIDL binding constructors wanted on all XPConnect globals.
if (!IDBVersionChangeEventBinding::GetConstructorObject(aJSContext, global) ||
if (!IDBTransactionBinding::GetConstructorObject(aJSContext, global) ||
!IDBVersionChangeEventBinding::GetConstructorObject(aJSContext, global) ||
!TextDecoderBinding::GetConstructorObject(aJSContext, global) ||
!TextEncoderBinding::GetConstructorObject(aJSContext, global) ||
!DOMErrorBinding::GetConstructorObject(aJSContext, global)) {