зеркало из https://github.com/mozilla/gecko-dev.git
Bug 735094: Implement new string values (rather than numeric constants) for IndexedDB. r=bent
This commit is contained in:
Родитель
29991e9161
Коммит
a2be3ad884
|
@ -5692,6 +5692,138 @@ DefineInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// This code is temporary until we remove support for the constants defined
|
||||
// on IDBCursor/IDBRequest/IDBTransaction
|
||||
|
||||
struct IDBConstant
|
||||
{
|
||||
const char* interface;
|
||||
const char* name;
|
||||
const char* value;
|
||||
|
||||
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" },
|
||||
};
|
||||
|
||||
static JSBool
|
||||
IDBConstantGetter(JSContext *cx, JSObject *obj, jsid id, jsval* vp)
|
||||
{
|
||||
MOZ_ASSERT(JSID_IS_INT(id));
|
||||
|
||||
int8_t index = JSID_TO_INT(id);
|
||||
|
||||
MOZ_ASSERT((uint8_t)index < mozilla::ArrayLength(sIDBConstants));
|
||||
|
||||
const IDBConstant& c = sIDBConstants[index];
|
||||
|
||||
// Put a warning on the console
|
||||
nsString warnText =
|
||||
NS_LITERAL_STRING("The constant ") +
|
||||
NS_ConvertASCIItoUTF16(c.interface) +
|
||||
NS_LITERAL_STRING(".") +
|
||||
NS_ConvertASCIItoUTF16(c.name) +
|
||||
NS_LITERAL_STRING(" has been deprecated. Use the string value \"") +
|
||||
NS_ConvertASCIItoUTF16(c.value) +
|
||||
NS_LITERAL_STRING("\" instead.");
|
||||
|
||||
PRUint64 windowID = 0;
|
||||
nsIScriptContext* context = GetScriptContextFromJSContext(cx);
|
||||
if (context) {
|
||||
nsCOMPtr<nsPIDOMWindow> window =
|
||||
do_QueryInterface(context->GetGlobalObject());
|
||||
if (window) {
|
||||
window = window->GetCurrentInnerWindow();
|
||||
}
|
||||
NS_WARN_IF_FALSE(window, "Missing a window, got a door?");
|
||||
if (window) {
|
||||
windowID = window->WindowID();
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIScriptError> errorObject =
|
||||
do_CreateInstance(NS_SCRIPTERROR_CONTRACTID);
|
||||
NS_WARN_IF_FALSE(errorObject, "Failed to create error object");
|
||||
if (errorObject) {
|
||||
nsresult rv = errorObject->InitWithWindowID(warnText.get(),
|
||||
nsnull, // file name
|
||||
nsnull, // source line
|
||||
0, 0, // Line/col number
|
||||
nsIScriptError::warningFlag,
|
||||
"DOM Core", windowID);
|
||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv), "Failed to init error object");
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
nsCOMPtr<nsIConsoleService> consoleServ =
|
||||
do_GetService(NS_CONSOLESERVICE_CONTRACTID);
|
||||
if (consoleServ) {
|
||||
consoleServ->LogMessage(errorObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Redefine property to remove getter
|
||||
NS_ConvertASCIItoUTF16 valStr(c.value);
|
||||
jsval value;
|
||||
if (!xpc::StringToJsval(cx, valStr, &value)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!::JS_DefineProperty(cx, obj, c.name, value, nsnull, nsnull,
|
||||
JSPROP_ENUMERATE)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
// Return value
|
||||
*vp = value;
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
static nsresult
|
||||
DefineIDBInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID)
|
||||
{
|
||||
const char* interface;
|
||||
if (aIID->Equals(NS_GET_IID(nsIIDBCursor))) {
|
||||
interface = IDBConstant::IDBCursor;
|
||||
}
|
||||
else if (aIID->Equals(NS_GET_IID(nsIIDBRequest))) {
|
||||
interface = IDBConstant::IDBRequest;
|
||||
}
|
||||
else if (aIID->Equals(NS_GET_IID(nsIIDBTransaction))) {
|
||||
interface = IDBConstant::IDBTransaction;
|
||||
}
|
||||
|
||||
for (int8_t i = 0; i < (int8_t)mozilla::ArrayLength(sIDBConstants); ++i) {
|
||||
const IDBConstant& c = sIDBConstants[i];
|
||||
if (c.interface != interface) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!::JS_DefinePropertyWithTinyId(cx, obj, c.name, i, JSVAL_VOID,
|
||||
IDBConstantGetter, nsnull,
|
||||
JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
class nsDOMConstructor : public nsIDOMDOMConstructor
|
||||
{
|
||||
protected:
|
||||
|
@ -6098,6 +6230,15 @@ nsDOMConstructor::ResolveInterfaceConstants(JSContext *cx, JSObject *obj)
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// 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))) {
|
||||
rv = DefineIDBInterfaceConstants(cx, obj, class_iid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -6241,6 +6382,15 @@ ResolvePrototype(nsIXPConnect *aXPConnect, nsGlobalWindow *aWin, JSContext *cx,
|
|||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
// 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))) {
|
||||
rv = DefineIDBInterfaceConstants(cx, class_obj, primary_iid);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoManager>
|
||||
iim(do_GetService(NS_INTERFACEINFOMANAGER_SERVICE_CONTRACTID));
|
||||
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
|
||||
|
|
|
@ -157,7 +157,7 @@ already_AddRefed<IDBCursor>
|
|||
IDBCursor::Create(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBObjectStore* aObjectStore,
|
||||
PRUint16 aDirection,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery,
|
||||
|
@ -185,7 +185,7 @@ already_AddRefed<IDBCursor>
|
|||
IDBCursor::Create(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBIndex* aIndex,
|
||||
PRUint16 aDirection,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery,
|
||||
|
@ -215,7 +215,7 @@ already_AddRefed<IDBCursor>
|
|||
IDBCursor::Create(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBIndex* aIndex,
|
||||
PRUint16 aDirection,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery,
|
||||
|
@ -242,12 +242,35 @@ IDBCursor::Create(IDBRequest* aRequest,
|
|||
return cursor.forget();
|
||||
}
|
||||
|
||||
// static
|
||||
nsresult
|
||||
IDBCursor::ParseDirection(const nsAString& aDirection, Direction* aResult)
|
||||
{
|
||||
if (aDirection.EqualsLiteral("next")) {
|
||||
*aResult = NEXT;
|
||||
}
|
||||
else if (aDirection.EqualsLiteral("nextunique")) {
|
||||
*aResult = NEXT_UNIQUE;
|
||||
}
|
||||
else if (aDirection.EqualsLiteral("prev")) {
|
||||
*aResult = PREV;
|
||||
}
|
||||
else if (aDirection.EqualsLiteral("prevunique")) {
|
||||
*aResult = PREV_UNIQUE;
|
||||
}
|
||||
else {
|
||||
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBCursor>
|
||||
IDBCursor::CreateCommon(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBObjectStore* aObjectStore,
|
||||
PRUint16 aDirection,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery)
|
||||
|
@ -286,7 +309,7 @@ IDBCursor::CreateCommon(IDBRequest* aRequest,
|
|||
IDBCursor::IDBCursor()
|
||||
: mScriptOwner(nsnull),
|
||||
mType(OBJECTSTORE),
|
||||
mDirection(nsIIDBCursor::NEXT),
|
||||
mDirection(IDBCursor::NEXT),
|
||||
mCachedKey(JSVAL_VOID),
|
||||
mCachedPrimaryKey(JSVAL_VOID),
|
||||
mCachedValue(JSVAL_VOID),
|
||||
|
@ -329,11 +352,11 @@ IDBCursor::ContinueInternal(const Key& aKey,
|
|||
|
||||
#ifdef DEBUG
|
||||
{
|
||||
PRUint16 readyState;
|
||||
if (NS_FAILED(mRequest->GetReadyState(&readyState))) {
|
||||
nsAutoString readyState;
|
||||
if (NS_FAILED(mRequest->GetReadyState(readyState))) {
|
||||
NS_ERROR("This should never fail!");
|
||||
}
|
||||
NS_ASSERTION(readyState == nsIIDBRequest::DONE, "Should be DONE!");
|
||||
NS_ASSERTION(readyState.EqualsLiteral("done"), "Should be DONE!");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -436,11 +459,24 @@ DOMCI_DATA(IDBCursor, IDBCursor)
|
|||
DOMCI_DATA(IDBCursorWithValue, IDBCursor)
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBCursor::GetDirection(PRUint16* aDirection)
|
||||
IDBCursor::GetDirection(nsAString& aDirection)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
*aDirection = mDirection;
|
||||
switch(mDirection) {
|
||||
case NEXT:
|
||||
aDirection.AssignLiteral("next");
|
||||
break;
|
||||
case NEXT_UNIQUE:
|
||||
aDirection.AssignLiteral("nextunique");
|
||||
break;
|
||||
case PREV:
|
||||
aDirection.AssignLiteral("prev");
|
||||
break;
|
||||
case PREV_UNIQUE:
|
||||
aDirection.AssignLiteral("prevunique");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -562,15 +598,15 @@ IDBCursor::Continue(const jsval &aKey,
|
|||
|
||||
if (!key.IsUnset()) {
|
||||
switch (mDirection) {
|
||||
case nsIIDBCursor::NEXT:
|
||||
case nsIIDBCursor::NEXT_NO_DUPLICATE:
|
||||
case IDBCursor::NEXT:
|
||||
case IDBCursor::NEXT_UNIQUE:
|
||||
if (key <= mKey) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
||||
}
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV:
|
||||
case nsIIDBCursor::PREV_NO_DUPLICATE:
|
||||
case IDBCursor::PREV:
|
||||
case IDBCursor::PREV_UNIQUE:
|
||||
if (key >= mKey) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_DATA_ERR;
|
||||
}
|
||||
|
@ -853,8 +889,8 @@ ContinueIndexHelper::BindArgumentsToStatement(mozIStorageStatement* aStatement)
|
|||
|
||||
// Bind object key if duplicates are allowed and we're not continuing to a
|
||||
// specific key.
|
||||
if ((mCursor->mDirection == nsIIDBCursor::NEXT ||
|
||||
mCursor->mDirection == nsIIDBCursor::PREV) &&
|
||||
if ((mCursor->mDirection == IDBCursor::NEXT ||
|
||||
mCursor->mDirection == IDBCursor::PREV) &&
|
||||
mCursor->mContinueToKey.IsUnset()) {
|
||||
NS_ASSERTION(!mCursor->mObjectKey.IsUnset(), "Bad key!");
|
||||
|
||||
|
|
|
@ -77,13 +77,28 @@ public:
|
|||
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBCursor)
|
||||
|
||||
enum Type
|
||||
{
|
||||
OBJECTSTORE = 0,
|
||||
INDEXKEY,
|
||||
INDEXOBJECT
|
||||
};
|
||||
|
||||
enum Direction
|
||||
{
|
||||
NEXT = 0,
|
||||
NEXT_UNIQUE,
|
||||
PREV,
|
||||
PREV_UNIQUE
|
||||
};
|
||||
|
||||
// For OBJECTSTORE cursors.
|
||||
static
|
||||
already_AddRefed<IDBCursor>
|
||||
Create(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBObjectStore* aObjectStore,
|
||||
PRUint16 aDirection,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery,
|
||||
|
@ -96,7 +111,7 @@ public:
|
|||
Create(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBIndex* aIndex,
|
||||
PRUint16 aDirection,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery,
|
||||
|
@ -109,7 +124,7 @@ public:
|
|||
Create(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBIndex* aIndex,
|
||||
PRUint16 aDirection,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery,
|
||||
|
@ -117,18 +132,14 @@ public:
|
|||
const Key& aObjectKey,
|
||||
StructuredCloneReadInfo& aCloneReadInfo);
|
||||
|
||||
enum Type
|
||||
{
|
||||
OBJECTSTORE = 0,
|
||||
INDEXKEY,
|
||||
INDEXOBJECT
|
||||
};
|
||||
|
||||
IDBTransaction* Transaction()
|
||||
{
|
||||
return mTransaction;
|
||||
}
|
||||
|
||||
static nsresult ParseDirection(const nsAString& aDirection,
|
||||
Direction* aResult);
|
||||
|
||||
protected:
|
||||
IDBCursor();
|
||||
~IDBCursor();
|
||||
|
@ -138,7 +149,7 @@ protected:
|
|||
CreateCommon(IDBRequest* aRequest,
|
||||
IDBTransaction* aTransaction,
|
||||
IDBObjectStore* aObjectStore,
|
||||
PRUint16 aDirection,
|
||||
Direction aDirection,
|
||||
const Key& aRangeKey,
|
||||
const nsACString& aContinueQuery,
|
||||
const nsACString& aContinueToQuery);
|
||||
|
@ -155,7 +166,7 @@ protected:
|
|||
JSObject* mScriptOwner;
|
||||
|
||||
Type mType;
|
||||
PRUint16 mDirection;
|
||||
Direction mDirection;
|
||||
nsCString mContinueQuery;
|
||||
nsCString mContinueToQuery;
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ IDBDatabase::CreateObjectStore(const nsAString& aName,
|
|||
IDBTransaction* transaction = AsyncConnectionHelper::GetCurrentTransaction();
|
||||
|
||||
if (!transaction ||
|
||||
transaction->Mode() != nsIIDBTransaction::VERSION_CHANGE) {
|
||||
transaction->GetMode() != IDBTransaction::VERSION_CHANGE) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
|
@ -506,7 +506,7 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName)
|
|||
IDBTransaction* transaction = AsyncConnectionHelper::GetCurrentTransaction();
|
||||
|
||||
if (!transaction ||
|
||||
transaction->Mode() != nsIIDBTransaction::VERSION_CHANGE) {
|
||||
transaction->GetMode() != IDBTransaction::VERSION_CHANGE) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
|
@ -528,7 +528,7 @@ IDBDatabase::DeleteObjectStore(const nsAString& aName)
|
|||
|
||||
NS_IMETHODIMP
|
||||
IDBDatabase::Transaction(const jsval& aStoreNames,
|
||||
PRUint16 aMode,
|
||||
const nsAString& aMode,
|
||||
JSContext* aCx,
|
||||
PRUint8 aOptionalArgCount,
|
||||
nsIIDBTransaction** _retval)
|
||||
|
@ -547,15 +547,15 @@ IDBDatabase::Transaction(const jsval& aStoreNames,
|
|||
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
IDBTransaction::Mode transactionMode = IDBTransaction::READ_ONLY;
|
||||
if (aOptionalArgCount) {
|
||||
if (aMode != nsIIDBTransaction::READ_WRITE &&
|
||||
aMode != nsIIDBTransaction::READ_ONLY) {
|
||||
if (aMode.EqualsLiteral("readwrite")) {
|
||||
transactionMode = IDBTransaction::READ_WRITE;
|
||||
}
|
||||
else if (!aMode.EqualsLiteral("readonly")) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aMode = nsIIDBTransaction::READ_ONLY;
|
||||
}
|
||||
|
||||
nsresult rv;
|
||||
nsTArray<nsString> storesToOpen;
|
||||
|
@ -657,7 +657,7 @@ IDBDatabase::Transaction(const jsval& aStoreNames,
|
|||
}
|
||||
|
||||
nsRefPtr<IDBTransaction> transaction =
|
||||
IDBTransaction::Create(this, storesToOpen, aMode, false);
|
||||
IDBTransaction::Create(this, storesToOpen, transactionMode, false);
|
||||
NS_ENSURE_TRUE(transaction, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
transaction.forget(_retval);
|
||||
|
|
|
@ -186,7 +186,7 @@ public:
|
|||
IDBRequest* aRequest,
|
||||
IDBIndex* aIndex,
|
||||
IDBKeyRange* aKeyRange,
|
||||
PRUint16 aDirection)
|
||||
IDBCursor::Direction aDirection)
|
||||
: AsyncConnectionHelper(aTransaction, aRequest), mIndex(aIndex),
|
||||
mKeyRange(aKeyRange), mDirection(aDirection)
|
||||
{ }
|
||||
|
@ -206,7 +206,7 @@ private:
|
|||
// In-params.
|
||||
nsRefPtr<IDBIndex> mIndex;
|
||||
nsRefPtr<IDBKeyRange> mKeyRange;
|
||||
const PRUint16 mDirection;
|
||||
const IDBCursor::Direction mDirection;
|
||||
|
||||
// Out-params.
|
||||
Key mKey;
|
||||
|
@ -223,7 +223,7 @@ public:
|
|||
IDBRequest* aRequest,
|
||||
IDBIndex* aIndex,
|
||||
IDBKeyRange* aKeyRange,
|
||||
PRUint16 aDirection)
|
||||
IDBCursor::Direction aDirection)
|
||||
: AsyncConnectionHelper(aTransaction, aRequest), mIndex(aIndex),
|
||||
mKeyRange(aKeyRange), mDirection(aDirection)
|
||||
{ }
|
||||
|
@ -248,7 +248,7 @@ private:
|
|||
// In-params.
|
||||
nsRefPtr<IDBIndex> mIndex;
|
||||
nsRefPtr<IDBKeyRange> mKeyRange;
|
||||
const PRUint16 mDirection;
|
||||
const IDBCursor::Direction mDirection;
|
||||
|
||||
// Out-params.
|
||||
Key mKey;
|
||||
|
@ -582,7 +582,7 @@ IDBIndex::GetAllKeys(const jsval& aKey,
|
|||
|
||||
NS_IMETHODIMP
|
||||
IDBIndex::OpenCursor(const jsval& aKey,
|
||||
PRUint16 aDirection,
|
||||
const nsAString& aDirection,
|
||||
JSContext* aCx,
|
||||
PRUint8 aOptionalArgCount,
|
||||
nsIIDBRequest** _retval)
|
||||
|
@ -596,21 +596,16 @@ IDBIndex::OpenCursor(const jsval& aKey,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
IDBCursor::Direction direction = IDBCursor::NEXT;
|
||||
|
||||
nsRefPtr<IDBKeyRange> keyRange;
|
||||
if (aOptionalArgCount) {
|
||||
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aOptionalArgCount >= 2) {
|
||||
if (aDirection != nsIIDBCursor::NEXT &&
|
||||
aDirection != nsIIDBCursor::NEXT_NO_DUPLICATE &&
|
||||
aDirection != nsIIDBCursor::PREV &&
|
||||
aDirection != nsIIDBCursor::PREV_NO_DUPLICATE) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aDirection = nsIIDBCursor::NEXT;
|
||||
rv = IDBCursor::ParseDirection(aDirection, &direction);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,7 +613,7 @@ IDBIndex::OpenCursor(const jsval& aKey,
|
|||
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
nsRefPtr<OpenCursorHelper> helper =
|
||||
new OpenCursorHelper(transaction, request, this, keyRange, aDirection);
|
||||
new OpenCursorHelper(transaction, request, this, keyRange, direction);
|
||||
|
||||
rv = helper->DispatchToTransactionPool();
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
@ -629,7 +624,7 @@ IDBIndex::OpenCursor(const jsval& aKey,
|
|||
|
||||
NS_IMETHODIMP
|
||||
IDBIndex::OpenKeyCursor(const jsval& aKey,
|
||||
PRUint16 aDirection,
|
||||
const nsAString& aDirection,
|
||||
JSContext* aCx,
|
||||
PRUint8 aOptionalArgCount,
|
||||
nsIIDBRequest** _retval)
|
||||
|
@ -643,21 +638,16 @@ IDBIndex::OpenKeyCursor(const jsval& aKey,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
IDBCursor::Direction direction = IDBCursor::NEXT;
|
||||
|
||||
nsRefPtr<IDBKeyRange> keyRange;
|
||||
if (aOptionalArgCount) {
|
||||
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aOptionalArgCount >= 2) {
|
||||
if (aDirection != nsIIDBCursor::NEXT &&
|
||||
aDirection != nsIIDBCursor::NEXT_NO_DUPLICATE &&
|
||||
aDirection != nsIIDBCursor::PREV &&
|
||||
aDirection != nsIIDBCursor::PREV_NO_DUPLICATE) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aDirection = nsIIDBCursor::NEXT;
|
||||
rv = IDBCursor::ParseDirection(aDirection, &direction);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -665,7 +655,7 @@ IDBIndex::OpenKeyCursor(const jsval& aKey,
|
|||
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
nsRefPtr<OpenKeyCursorHelper> helper =
|
||||
new OpenKeyCursorHelper(transaction, request, this, keyRange, aDirection);
|
||||
new OpenKeyCursorHelper(transaction, request, this, keyRange, direction);
|
||||
|
||||
rv = helper->DispatchToTransactionPool();
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
@ -1032,16 +1022,16 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
|
||||
nsCAutoString directionClause(" ORDER BY value ");
|
||||
switch (mDirection) {
|
||||
case nsIIDBCursor::NEXT:
|
||||
case nsIIDBCursor::NEXT_NO_DUPLICATE:
|
||||
case IDBCursor::NEXT:
|
||||
case IDBCursor::NEXT_UNIQUE:
|
||||
directionClause += NS_LITERAL_CSTRING("ASC, object_data_key ASC");
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV:
|
||||
case IDBCursor::PREV:
|
||||
directionClause += NS_LITERAL_CSTRING("DESC, object_data_key DESC");
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV_NO_DUPLICATE:
|
||||
case IDBCursor::PREV_UNIQUE:
|
||||
directionClause += NS_LITERAL_CSTRING("DESC, object_data_key ASC");
|
||||
break;
|
||||
|
||||
|
@ -1092,7 +1082,7 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
NS_NAMED_LITERAL_CSTRING(rangeKey, "range_key");
|
||||
|
||||
switch (mDirection) {
|
||||
case nsIIDBCursor::NEXT:
|
||||
case IDBCursor::NEXT:
|
||||
if (mKeyRange && !mKeyRange->Upper().IsUnset()) {
|
||||
AppendConditionClause(value, rangeKey, true, !mKeyRange->IsUpperOpen(),
|
||||
queryStart);
|
||||
|
@ -1112,7 +1102,7 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
NS_LITERAL_CSTRING(" LIMIT ");
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::NEXT_NO_DUPLICATE:
|
||||
case IDBCursor::NEXT_UNIQUE:
|
||||
if (mKeyRange && !mKeyRange->Upper().IsUnset()) {
|
||||
AppendConditionClause(value, rangeKey, true, !mKeyRange->IsUpperOpen(),
|
||||
queryStart);
|
||||
|
@ -1128,7 +1118,7 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
NS_LITERAL_CSTRING(" LIMIT ");
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV:
|
||||
case IDBCursor::PREV:
|
||||
if (mKeyRange && !mKeyRange->Lower().IsUnset()) {
|
||||
AppendConditionClause(value, rangeKey, false, !mKeyRange->IsLowerOpen(),
|
||||
queryStart);
|
||||
|
@ -1149,7 +1139,7 @@ OpenKeyCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
NS_LITERAL_CSTRING(" LIMIT ");
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV_NO_DUPLICATE:
|
||||
case IDBCursor::PREV_UNIQUE:
|
||||
if (mKeyRange && !mKeyRange->Lower().IsUnset()) {
|
||||
AppendConditionClause(value, rangeKey, false, !mKeyRange->IsLowerOpen(),
|
||||
queryStart);
|
||||
|
@ -1213,18 +1203,18 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
|
||||
nsCAutoString directionClause(" ORDER BY index_table.value ");
|
||||
switch (mDirection) {
|
||||
case nsIIDBCursor::NEXT:
|
||||
case nsIIDBCursor::NEXT_NO_DUPLICATE:
|
||||
case IDBCursor::NEXT:
|
||||
case IDBCursor::NEXT_UNIQUE:
|
||||
directionClause +=
|
||||
NS_LITERAL_CSTRING("ASC, index_table.object_data_key ASC");
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV:
|
||||
case IDBCursor::PREV:
|
||||
directionClause +=
|
||||
NS_LITERAL_CSTRING("DESC, index_table.object_data_key DESC");
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV_NO_DUPLICATE:
|
||||
case IDBCursor::PREV_UNIQUE:
|
||||
directionClause +=
|
||||
NS_LITERAL_CSTRING("DESC, index_table.object_data_key ASC");
|
||||
break;
|
||||
|
@ -1292,7 +1282,7 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
NS_NAMED_LITERAL_CSTRING(limit, " LIMIT ");
|
||||
|
||||
switch (mDirection) {
|
||||
case nsIIDBCursor::NEXT:
|
||||
case IDBCursor::NEXT:
|
||||
if (mKeyRange && !mKeyRange->Upper().IsUnset()) {
|
||||
AppendConditionClause(value, rangeKey, true, !mKeyRange->IsUpperOpen(),
|
||||
queryStart);
|
||||
|
@ -1310,7 +1300,7 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
directionClause + limit;
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::NEXT_NO_DUPLICATE:
|
||||
case IDBCursor::NEXT_UNIQUE:
|
||||
if (mKeyRange && !mKeyRange->Upper().IsUnset()) {
|
||||
AppendConditionClause(value, rangeKey, true, !mKeyRange->IsUpperOpen(),
|
||||
queryStart);
|
||||
|
@ -1326,7 +1316,7 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
directionClause + limit;
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV:
|
||||
case IDBCursor::PREV:
|
||||
if (mKeyRange && !mKeyRange->Lower().IsUnset()) {
|
||||
AppendConditionClause(value, rangeKey, false, !mKeyRange->IsLowerOpen(),
|
||||
queryStart);
|
||||
|
@ -1344,7 +1334,7 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
directionClause + limit;
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV_NO_DUPLICATE:
|
||||
case IDBCursor::PREV_UNIQUE:
|
||||
if (mKeyRange && !mKeyRange->Lower().IsUnset()) {
|
||||
AppendConditionClause(value, rangeKey, false, !mKeyRange->IsLowerOpen(),
|
||||
queryStart);
|
||||
|
|
|
@ -198,7 +198,7 @@ public:
|
|||
IDBRequest* aRequest,
|
||||
IDBObjectStore* aObjectStore,
|
||||
IDBKeyRange* aKeyRange,
|
||||
PRUint16 aDirection)
|
||||
IDBCursor::Direction aDirection)
|
||||
: AsyncConnectionHelper(aTransaction, aRequest), mObjectStore(aObjectStore),
|
||||
mKeyRange(aKeyRange), mDirection(aDirection)
|
||||
{ }
|
||||
|
@ -224,7 +224,7 @@ private:
|
|||
// In-params.
|
||||
nsRefPtr<IDBObjectStore> mObjectStore;
|
||||
nsRefPtr<IDBKeyRange> mKeyRange;
|
||||
const PRUint16 mDirection;
|
||||
const IDBCursor::Direction mDirection;
|
||||
|
||||
// Out-params.
|
||||
Key mKey;
|
||||
|
@ -1637,7 +1637,7 @@ IDBObjectStore::Clear(nsIIDBRequest** _retval)
|
|||
|
||||
NS_IMETHODIMP
|
||||
IDBObjectStore::OpenCursor(const jsval& aKey,
|
||||
PRUint16 aDirection,
|
||||
const nsAString& aDirection,
|
||||
JSContext* aCx,
|
||||
PRUint8 aOptionalArgCount,
|
||||
nsIIDBRequest** _retval)
|
||||
|
@ -1650,21 +1650,16 @@ IDBObjectStore::OpenCursor(const jsval& aKey,
|
|||
|
||||
nsresult rv;
|
||||
|
||||
IDBCursor::Direction direction = IDBCursor::NEXT;
|
||||
|
||||
nsRefPtr<IDBKeyRange> keyRange;
|
||||
if (aOptionalArgCount) {
|
||||
rv = IDBKeyRange::FromJSVal(aCx, aKey, getter_AddRefs(keyRange));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (aOptionalArgCount >= 2) {
|
||||
if (aDirection != nsIIDBCursor::NEXT &&
|
||||
aDirection != nsIIDBCursor::NEXT_NO_DUPLICATE &&
|
||||
aDirection != nsIIDBCursor::PREV &&
|
||||
aDirection != nsIIDBCursor::PREV_NO_DUPLICATE) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
|
||||
}
|
||||
}
|
||||
else {
|
||||
aDirection = nsIIDBCursor::NEXT;
|
||||
rv = IDBCursor::ParseDirection(aDirection, &direction);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1672,7 +1667,7 @@ IDBObjectStore::OpenCursor(const jsval& aKey,
|
|||
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
nsRefPtr<OpenCursorHelper> helper =
|
||||
new OpenCursorHelper(mTransaction, request, this, keyRange, aDirection);
|
||||
new OpenCursorHelper(mTransaction, request, this, keyRange, direction);
|
||||
|
||||
rv = helper->DispatchToTransactionPool();
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
@ -1750,7 +1745,7 @@ IDBObjectStore::CreateIndex(const nsAString& aName,
|
|||
|
||||
if (!transaction ||
|
||||
transaction != mTransaction ||
|
||||
mTransaction->Mode() != nsIIDBTransaction::VERSION_CHANGE) {
|
||||
mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
|
@ -1876,7 +1871,7 @@ IDBObjectStore::DeleteIndex(const nsAString& aName)
|
|||
|
||||
if (!transaction ||
|
||||
transaction != mTransaction ||
|
||||
mTransaction->Mode() != nsIIDBTransaction::VERSION_CHANGE) {
|
||||
mTransaction->GetMode() != IDBTransaction::VERSION_CHANGE) {
|
||||
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
|
@ -2285,13 +2280,13 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
|
||||
nsCAutoString directionClause;
|
||||
switch (mDirection) {
|
||||
case nsIIDBCursor::NEXT:
|
||||
case nsIIDBCursor::NEXT_NO_DUPLICATE:
|
||||
case IDBCursor::NEXT:
|
||||
case IDBCursor::NEXT_UNIQUE:
|
||||
directionClause.AssignLiteral(" ORDER BY key_value ASC");
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV:
|
||||
case nsIIDBCursor::PREV_NO_DUPLICATE:
|
||||
case IDBCursor::PREV:
|
||||
case IDBCursor::PREV_UNIQUE:
|
||||
directionClause.AssignLiteral(" ORDER BY key_value DESC");
|
||||
break;
|
||||
|
||||
|
@ -2344,8 +2339,8 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
NS_NAMED_LITERAL_CSTRING(rangeKey, "range_key");
|
||||
|
||||
switch (mDirection) {
|
||||
case nsIIDBCursor::NEXT:
|
||||
case nsIIDBCursor::NEXT_NO_DUPLICATE:
|
||||
case IDBCursor::NEXT:
|
||||
case IDBCursor::NEXT_UNIQUE:
|
||||
AppendConditionClause(keyValue, currentKey, false, false,
|
||||
keyRangeClause);
|
||||
AppendConditionClause(keyValue, currentKey, false, true,
|
||||
|
@ -2360,8 +2355,8 @@ OpenCursorHelper::DoDatabaseWork(mozIStorageConnection* aConnection)
|
|||
}
|
||||
break;
|
||||
|
||||
case nsIIDBCursor::PREV:
|
||||
case nsIIDBCursor::PREV_NO_DUPLICATE:
|
||||
case IDBCursor::PREV:
|
||||
case IDBCursor::PREV_UNIQUE:
|
||||
AppendConditionClause(keyValue, currentKey, true, false, keyRangeClause);
|
||||
AppendConditionClause(keyValue, currentKey, true, true,
|
||||
continueToKeyRangeClause);
|
||||
|
|
|
@ -190,13 +190,16 @@ IDBRequest::UnrootResultValInternal()
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::GetReadyState(PRUint16* aReadyState)
|
||||
IDBRequest::GetReadyState(nsAString& aReadyState)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
*aReadyState = mHaveResultOrErrorCode ?
|
||||
nsIIDBRequest::DONE :
|
||||
nsIIDBRequest::LOADING;
|
||||
if (mHaveResultOrErrorCode) {
|
||||
aReadyState.AssignLiteral("done");
|
||||
}
|
||||
else {
|
||||
aReadyState.AssignLiteral("pending");
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -110,7 +110,7 @@ StartTransactionRunnable gStartTransactionRunnable;
|
|||
already_AddRefed<IDBTransaction>
|
||||
IDBTransaction::Create(IDBDatabase* aDatabase,
|
||||
nsTArray<nsString>& aObjectStoreNames,
|
||||
PRUint16 aMode,
|
||||
Mode aMode,
|
||||
bool aDispatchDelayed)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
@ -156,7 +156,7 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
|
|||
transaction->mCreating = true;
|
||||
}
|
||||
|
||||
if (aMode != nsIIDBTransaction::VERSION_CHANGE) {
|
||||
if (aMode != IDBTransaction::VERSION_CHANGE) {
|
||||
TransactionThreadPool* pool = TransactionThreadPool::GetOrCreate();
|
||||
pool->Dispatch(transaction, &gStartTransactionRunnable, false, nsnull);
|
||||
}
|
||||
|
@ -165,8 +165,8 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
|
|||
}
|
||||
|
||||
IDBTransaction::IDBTransaction()
|
||||
: mReadyState(nsIIDBTransaction::INITIAL),
|
||||
mMode(nsIIDBTransaction::READ_ONLY),
|
||||
: mReadyState(IDBTransaction::INITIAL),
|
||||
mMode(IDBTransaction::READ_ONLY),
|
||||
mPendingRequests(0),
|
||||
mCreatedRecursionDepth(0),
|
||||
mSavepointCount(0),
|
||||
|
@ -196,9 +196,9 @@ IDBTransaction::OnNewRequest()
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
if (!mPendingRequests) {
|
||||
NS_ASSERTION(mReadyState == nsIIDBTransaction::INITIAL,
|
||||
NS_ASSERTION(mReadyState == IDBTransaction::INITIAL,
|
||||
"Reusing a transaction!");
|
||||
mReadyState = nsIIDBTransaction::LOADING;
|
||||
mReadyState = IDBTransaction::LOADING;
|
||||
}
|
||||
++mPendingRequests;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ IDBTransaction::OnRequestFinished()
|
|||
NS_ASSERTION(mPendingRequests, "Mismatched calls!");
|
||||
--mPendingRequests;
|
||||
if (!mPendingRequests) {
|
||||
NS_ASSERTION(mAborted || mReadyState == nsIIDBTransaction::LOADING,
|
||||
NS_ASSERTION(mAborted || mReadyState == IDBTransaction::LOADING,
|
||||
"Bad state!");
|
||||
mReadyState = IDBTransaction::COMMITTING;
|
||||
CommitOrRollback();
|
||||
|
@ -220,7 +220,7 @@ IDBTransaction::OnRequestFinished()
|
|||
void
|
||||
IDBTransaction::RemoveObjectStore(const nsAString& aName)
|
||||
{
|
||||
NS_ASSERTION(mMode == nsIIDBTransaction::VERSION_CHANGE,
|
||||
NS_ASSERTION(mMode == IDBTransaction::VERSION_CHANGE,
|
||||
"Only remove object stores on VERSION_CHANGE transactions");
|
||||
|
||||
mDatabaseInfo->RemoveObjectStore(aName);
|
||||
|
@ -343,7 +343,7 @@ IDBTransaction::GetOrCreateConnection(mozIStorageConnection** aResult)
|
|||
|
||||
nsRefPtr<UpdateRefcountFunction> function;
|
||||
nsCString beginTransaction;
|
||||
if (mMode != nsIIDBTransaction::READ_ONLY) {
|
||||
if (mMode != IDBTransaction::READ_ONLY) {
|
||||
function = new UpdateRefcountFunction(Database()->Manager());
|
||||
NS_ENSURE_TRUE(function, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
@ -416,7 +416,7 @@ IDBTransaction::IsOpen() const
|
|||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
// If we haven't started anything then we're open.
|
||||
if (mReadyState == nsIIDBTransaction::INITIAL) {
|
||||
if (mReadyState == IDBTransaction::INITIAL) {
|
||||
NS_ASSERTION(AsyncConnectionHelper::GetCurrentTransaction() != this,
|
||||
"This should be some other transaction (or null)!");
|
||||
return true;
|
||||
|
@ -427,7 +427,7 @@ IDBTransaction::IsOpen() const
|
|||
// from the time we were created) then we are open. Otherwise check the
|
||||
// currently running transaction to see if it's the same. We only allow other
|
||||
// requests to be made if this transaction is currently running.
|
||||
if (mReadyState == nsIIDBTransaction::LOADING) {
|
||||
if (mReadyState == IDBTransaction::LOADING) {
|
||||
if (mCreating) {
|
||||
return true;
|
||||
}
|
||||
|
@ -528,20 +528,21 @@ IDBTransaction::GetDb(nsIIDBDatabase** aDB)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBTransaction::GetReadyState(PRUint16* aReadyState)
|
||||
IDBTransaction::GetMode(nsAString& aMode)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
*aReadyState = mReadyState;
|
||||
return NS_OK;
|
||||
}
|
||||
switch(mMode) {
|
||||
case READ_ONLY:
|
||||
aMode.AssignLiteral("readonly");
|
||||
break;
|
||||
case READ_WRITE:
|
||||
aMode.AssignLiteral("readwrite");
|
||||
break;
|
||||
case VERSION_CHANGE:
|
||||
aMode.AssignLiteral("versionchange");
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBTransaction::GetMode(PRUint16* aMode)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
*aMode = mMode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -586,7 +587,7 @@ IDBTransaction::ObjectStore(const nsAString& aName,
|
|||
|
||||
ObjectStoreInfo* info = nsnull;
|
||||
|
||||
if (mMode == nsIIDBTransaction::VERSION_CHANGE ||
|
||||
if (mMode == IDBTransaction::VERSION_CHANGE ||
|
||||
mObjectStoreNames.Contains(aName)) {
|
||||
info = mDatabaseInfo->GetObjectStore(aName);
|
||||
}
|
||||
|
@ -614,12 +615,12 @@ IDBTransaction::Abort()
|
|||
return NS_ERROR_DOM_INDEXEDDB_NOT_ALLOWED_ERR;
|
||||
}
|
||||
|
||||
bool needToCommitOrRollback = mReadyState == nsIIDBTransaction::INITIAL;
|
||||
bool needToCommitOrRollback = mReadyState == IDBTransaction::INITIAL;
|
||||
|
||||
mAborted = true;
|
||||
mReadyState = nsIIDBTransaction::DONE;
|
||||
mReadyState = IDBTransaction::DONE;
|
||||
|
||||
if (Mode() == nsIIDBTransaction::VERSION_CHANGE) {
|
||||
if (Mode() == IDBTransaction::VERSION_CHANGE) {
|
||||
// If a version change transaction is aborted, the db must be closed
|
||||
mDatabase->Close();
|
||||
}
|
||||
|
@ -676,8 +677,8 @@ IDBTransaction::AfterProcessNextEvent(nsIThreadInternal* aThread,
|
|||
mCreating = false;
|
||||
|
||||
// Maybe set the readyState to DONE if there were no requests generated.
|
||||
if (mReadyState == nsIIDBTransaction::INITIAL) {
|
||||
mReadyState = nsIIDBTransaction::DONE;
|
||||
if (mReadyState == IDBTransaction::INITIAL) {
|
||||
mReadyState = IDBTransaction::DONE;
|
||||
|
||||
if (NS_FAILED(CommitOrRollback())) {
|
||||
NS_WARNING("Failed to commit!");
|
||||
|
@ -724,7 +725,7 @@ CommitHelper::Run()
|
|||
if (NS_IsMainThread()) {
|
||||
NS_ASSERTION(mDoomedObjects.IsEmpty(), "Didn't release doomed objects!");
|
||||
|
||||
mTransaction->mReadyState = nsIIDBTransaction::DONE;
|
||||
mTransaction->mReadyState = IDBTransaction::DONE;
|
||||
|
||||
// Release file infos on the main thread, so they will eventually get
|
||||
// destroyed on correct thread.
|
||||
|
@ -736,7 +737,7 @@ CommitHelper::Run()
|
|||
|
||||
nsCOMPtr<nsIDOMEvent> event;
|
||||
if (mAborted) {
|
||||
if (mTransaction->Mode() == nsIIDBTransaction::VERSION_CHANGE) {
|
||||
if (mTransaction->GetMode() == IDBTransaction::VERSION_CHANGE) {
|
||||
// This will make the database take a snapshot of it's DatabaseInfo
|
||||
mTransaction->Database()->Close();
|
||||
// Then remove the info from the hash as it contains invalid data.
|
||||
|
|
|
@ -93,10 +93,25 @@ public:
|
|||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
|
||||
enum Mode
|
||||
{
|
||||
READ_ONLY = 0,
|
||||
READ_WRITE,
|
||||
VERSION_CHANGE
|
||||
};
|
||||
|
||||
enum ReadyState
|
||||
{
|
||||
INITIAL = 0,
|
||||
LOADING,
|
||||
COMMITTING,
|
||||
DONE
|
||||
};
|
||||
|
||||
static already_AddRefed<IDBTransaction>
|
||||
Create(IDBDatabase* aDatabase,
|
||||
nsTArray<nsString>& aObjectStoreNames,
|
||||
PRUint16 aMode,
|
||||
Mode aMode,
|
||||
bool aDispatchDelayed);
|
||||
|
||||
// nsIDOMEventTarget
|
||||
|
@ -130,8 +145,7 @@ public:
|
|||
|
||||
bool IsWriteAllowed() const
|
||||
{
|
||||
return mMode == nsIIDBTransaction::READ_WRITE ||
|
||||
mMode == nsIIDBTransaction::VERSION_CHANGE;
|
||||
return mMode == READ_WRITE || mMode == VERSION_CHANGE;
|
||||
}
|
||||
|
||||
bool IsAborted() const
|
||||
|
@ -139,7 +153,8 @@ public:
|
|||
return mAborted;
|
||||
}
|
||||
|
||||
PRUint16 Mode()
|
||||
// 'Get' prefix is to avoid name collisions with the enum
|
||||
Mode GetMode()
|
||||
{
|
||||
return mMode;
|
||||
}
|
||||
|
@ -172,8 +187,8 @@ private:
|
|||
nsRefPtr<IDBDatabase> mDatabase;
|
||||
nsRefPtr<DatabaseInfo> mDatabaseInfo;
|
||||
nsTArray<nsString> mObjectStoreNames;
|
||||
PRUint16 mReadyState;
|
||||
PRUint16 mMode;
|
||||
ReadyState mReadyState;
|
||||
Mode mMode;
|
||||
PRUint32 mPendingRequests;
|
||||
PRUint32 mCreatedRecursionDepth;
|
||||
|
||||
|
|
|
@ -275,14 +275,14 @@ TransactionThreadPool::FinishTransaction(IDBTransaction* aTransaction)
|
|||
const nsTArray<nsString>& objectStores = transaction->mObjectStoreNames;
|
||||
|
||||
bool dummy;
|
||||
if (transaction->mMode == nsIIDBTransaction::READ_WRITE) {
|
||||
if (transaction->mMode == IDBTransaction::READ_WRITE) {
|
||||
if (NS_FAILED(CheckOverlapAndMergeObjectStores(storesWriting,
|
||||
objectStores,
|
||||
true, &dummy))) {
|
||||
NS_WARNING("Out of memory!");
|
||||
}
|
||||
}
|
||||
else if (transaction->mMode == nsIIDBTransaction::READ_ONLY) {
|
||||
else if (transaction->mMode == IDBTransaction::READ_ONLY) {
|
||||
if (NS_FAILED(CheckOverlapAndMergeObjectStores(storesReading,
|
||||
objectStores,
|
||||
true, &dummy))) {
|
||||
|
@ -358,19 +358,19 @@ TransactionThreadPool::TransactionCanRun(IDBTransaction* aTransaction,
|
|||
nsresult rv =
|
||||
CheckOverlapAndMergeObjectStores(dbTransactionInfo->storesWriting,
|
||||
objectStoreNames,
|
||||
mode == nsIIDBTransaction::READ_WRITE,
|
||||
mode == IDBTransaction::READ_WRITE,
|
||||
&writeOverlap);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
bool readOverlap;
|
||||
rv = CheckOverlapAndMergeObjectStores(dbTransactionInfo->storesReading,
|
||||
objectStoreNames,
|
||||
mode == nsIIDBTransaction::READ_ONLY,
|
||||
mode == IDBTransaction::READ_ONLY,
|
||||
&readOverlap);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (writeOverlap ||
|
||||
(readOverlap && mode == nsIIDBTransaction::READ_WRITE)) {
|
||||
(readOverlap && mode == IDBTransaction::READ_WRITE)) {
|
||||
*aCanRun = false;
|
||||
*aExistingQueue = nsnull;
|
||||
return NS_OK;
|
||||
|
@ -441,7 +441,7 @@ TransactionThreadPool::Dispatch(IDBTransaction* aTransaction,
|
|||
const nsTArray<nsString>& objectStoreNames = aTransaction->mObjectStoreNames;
|
||||
|
||||
nsTArray<nsString>& storesInUse =
|
||||
aTransaction->mMode == nsIIDBTransaction::READ_WRITE ?
|
||||
aTransaction->mMode == IDBTransaction::READ_WRITE ?
|
||||
dbTransactionInfo->storesWriting :
|
||||
dbTransactionInfo->storesReading;
|
||||
|
||||
|
|
|
@ -46,14 +46,11 @@ interface nsIIDBRequest;
|
|||
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBCursor for more
|
||||
* information.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(9d5ddd43-132d-418e-81e8-17d64a6467a2)]
|
||||
[scriptable, builtinclass, uuid(01136b3a-d84c-487c-b929-f5d012346c44)]
|
||||
interface nsIIDBCursor : nsISupports
|
||||
{
|
||||
const unsigned short NEXT = 0;
|
||||
const unsigned short NEXT_NO_DUPLICATE = 1;
|
||||
const unsigned short PREV = 2;
|
||||
const unsigned short PREV_NO_DUPLICATE = 3;
|
||||
readonly attribute unsigned short direction;
|
||||
// "next", "nextunique", "prev" or "prevunique"
|
||||
readonly attribute DOMString direction;
|
||||
|
||||
readonly attribute nsISupports source;
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ interface nsIIDBObjectStoreParameters : nsISupports
|
|||
* http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBDatabase
|
||||
* for more information.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(bb877dff-ab5b-4ebb-9b3c-a7fa97cd4b51)]
|
||||
[scriptable, builtinclass, uuid(bedee48a-f47f-44f2-ba1e-d8fe595bbfee)]
|
||||
interface nsIIDBDatabase : nsISupports
|
||||
{
|
||||
readonly attribute DOMString name;
|
||||
|
@ -75,10 +75,11 @@ interface nsIIDBDatabase : nsISupports
|
|||
void
|
||||
deleteObjectStore([Null(Stringify)] in DOMString name);
|
||||
|
||||
// mode can be either "readonly" or "readwrite"
|
||||
[optional_argc, implicit_jscontext]
|
||||
nsIIDBTransaction
|
||||
transaction(in jsval storeNames, // js array of strings
|
||||
[optional /* READ_ONLY */] in unsigned short mode);
|
||||
[optional /* "readonly" */] in DOMString mode);
|
||||
|
||||
void
|
||||
close();
|
||||
|
|
|
@ -47,7 +47,7 @@ interface nsIIDBRequest;
|
|||
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBIndex for more
|
||||
* information.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(233ec586-7b34-4263-b27e-a4991b757597)]
|
||||
[scriptable, builtinclass, uuid(a859747a-0f05-4dfb-8f42-05c61415d4e4)]
|
||||
interface nsIIDBIndex : nsISupports
|
||||
{
|
||||
readonly attribute DOMString name;
|
||||
|
@ -81,15 +81,17 @@ interface nsIIDBIndex : nsISupports
|
|||
getAllKeys([optional /* null */] in jsval key,
|
||||
[optional /* unlimited */] in unsigned long limit);
|
||||
|
||||
// direction can be "next", "nextunique", "prev" or "prevunique"
|
||||
[implicit_jscontext, optional_argc]
|
||||
nsIIDBRequest
|
||||
openCursor([optional /* null */] in jsval key,
|
||||
[optional /* nsIIDBCursor::NEXT */] in unsigned short direction);
|
||||
[optional /* "next" */] in DOMString direction);
|
||||
|
||||
// direction can be "next", "nextunique", "prev" or "prevunique"
|
||||
[implicit_jscontext, optional_argc]
|
||||
nsIIDBRequest
|
||||
openKeyCursor([optional /* null */] in jsval key,
|
||||
[optional /* nsIIDBCursor::NEXT */] in unsigned short direction);
|
||||
[optional /* "next" */] in DOMString direction);
|
||||
|
||||
// Accepts null, a key value, or a nsIIDBKeyRange object.
|
||||
[implicit_jscontext, optional_argc]
|
||||
|
|
|
@ -57,7 +57,7 @@ interface nsIIDBIndexParameters : nsISupports
|
|||
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-nsIIDBObjectStore
|
||||
* for more information.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(e0d308ea-b804-4962-918a-28ec0aa4e42b)]
|
||||
[scriptable, builtinclass, uuid(43157a3c-bed1-4ce7-98c0-11365b852560)]
|
||||
interface nsIIDBObjectStore : nsISupports
|
||||
{
|
||||
readonly attribute DOMString name;
|
||||
|
@ -105,10 +105,11 @@ interface nsIIDBObjectStore : nsISupports
|
|||
|
||||
// Success fires IDBTransactionEvent, result == IDBCursor or result == null if
|
||||
// no match.
|
||||
// direction can be "next", "nextunique", "prev" or "prevunique"
|
||||
[implicit_jscontext, optional_argc]
|
||||
nsIIDBRequest
|
||||
openCursor([optional /* null */] in jsval range,
|
||||
[optional /* NEXT */] in unsigned short direction);
|
||||
[optional /* "next" */] in DOMString direction);
|
||||
|
||||
[implicit_jscontext]
|
||||
nsIIDBIndex
|
||||
|
|
|
@ -48,12 +48,11 @@ interface nsIIDBTransaction;
|
|||
* http://dev.w3.org/2006/webapi/WebSimpleDB/#idl-def-IDBRequest for more
|
||||
* information.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(a1e4a0ff-e0b2-431c-89cf-43b078189e27)]
|
||||
[scriptable, builtinclass, uuid(fe30ca60-bb90-4d68-af2f-4735f9228a54)]
|
||||
interface nsIIDBRequest : nsISupports
|
||||
{
|
||||
const unsigned short LOADING = 1;
|
||||
const unsigned short DONE = 2;
|
||||
readonly attribute unsigned short readyState;
|
||||
// "pending" or "done"
|
||||
readonly attribute DOMString readyState;
|
||||
|
||||
readonly attribute nsISupports source;
|
||||
|
||||
|
|
|
@ -50,21 +50,13 @@ interface nsIDOMDOMStringList;
|
|||
* http://dvcs.w3.org/hg/IndexedDB/raw-file/tip/Overview.html#idl-def-IDBTransaction
|
||||
* for more information.
|
||||
*/
|
||||
[scriptable, builtinclass, uuid(4f25832d-de40-4c0b-a176-358d94384b19)]
|
||||
[scriptable, builtinclass, uuid(e4927c76-4f1f-4d7d-80ad-8186e1677da6)]
|
||||
interface nsIIDBTransaction : nsISupports
|
||||
{
|
||||
readonly attribute nsIIDBDatabase db;
|
||||
|
||||
const unsigned short INITIAL = 0;
|
||||
const unsigned short LOADING = 1;
|
||||
const unsigned short COMMITTING = 2;
|
||||
const unsigned short DONE = 3;
|
||||
readonly attribute unsigned short readyState;
|
||||
|
||||
const unsigned short READ_ONLY = 0;
|
||||
const unsigned short READ_WRITE = 1;
|
||||
const unsigned short VERSION_CHANGE = 2;
|
||||
readonly attribute unsigned short mode;
|
||||
// "readonly", "readwrite" or "versionchange"
|
||||
readonly attribute DOMString mode;
|
||||
|
||||
readonly attribute nsIDOMDOMStringList objectStoreNames;
|
||||
|
||||
|
|
|
@ -7,13 +7,11 @@
|
|||
<title>Indexed Database Test</title>
|
||||
|
||||
<script type="text/javascript;version=1.7">
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
|
||||
let db;
|
||||
let version = window.location.href.charAt(window.location.href.length - 1);
|
||||
|
||||
function onAddMore() {
|
||||
let transaction = db.transaction("foo", READ_WRITE);
|
||||
let transaction = db.transaction("foo", "readwrite");
|
||||
|
||||
transaction.oncomplete = function(event) {
|
||||
setTimeout(testFinishedCallback, 0, "complete");
|
||||
|
|
|
@ -7,8 +7,6 @@
|
|||
<title>Indexed Database Test</title>
|
||||
|
||||
<script type="text/javascript;version=1.7">
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
|
||||
let db;
|
||||
let i = 0;
|
||||
|
||||
|
|
|
@ -7,13 +7,11 @@
|
|||
<title>Indexed Database Test</title>
|
||||
|
||||
<script type="text/javascript;version=1.7">
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
|
||||
let db;
|
||||
let name = window.location.pathname;
|
||||
|
||||
function onAddMore() {
|
||||
let transaction = db.transaction("foo", READ_WRITE);
|
||||
let transaction = db.transaction("foo", "readwrite");
|
||||
|
||||
transaction.oncomplete = function(event) {
|
||||
setTimeout(testFinishedCallback, 0, "complete");
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
<script type="text/javascript;version=1.7">
|
||||
function testSteps()
|
||||
{
|
||||
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
|
||||
const nsIIDBTransaction = Components.interfaces.nsIIDBTransaction;
|
||||
|
||||
const name = window.location.pathname;
|
||||
const description = "My Test Database";
|
||||
const objectStoreInfo = [
|
||||
|
@ -100,9 +97,7 @@
|
|||
|
||||
ok(event.target.transaction, "event has a transaction");
|
||||
ok(event.target.transaction.db === db, "transaction has the right db");
|
||||
is(event.target.transaction.readyState, nsIIDBTransaction.LOADING,
|
||||
"transaction has the correct readyState");
|
||||
is(event.target.transaction.mode, nsIIDBTransaction.VERSION_CHANGE,
|
||||
is(event.target.transaction.mode, "versionchange",
|
||||
"transaction has the correct mode");
|
||||
is(event.target.transaction.objectStoreNames.length, index + 1,
|
||||
"transaction has correct objectStoreNames list");
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
const VERSION_CHANGE = Components.interfaces.nsIIDBTransaction.VERSION_CHANGE;
|
||||
|
||||
const name = window.location.pathname;
|
||||
|
||||
ok(mozIndexedDB.deleteDatabase, "deleteDatabase function should exist!");
|
||||
|
|
|
@ -13,9 +13,6 @@
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
const VERSION_CHANGE = Components.interfaces.nsIIDBTransaction.VERSION_CHANGE;
|
||||
|
||||
const name = window.location.pathname;
|
||||
|
||||
let request = mozIndexedDB.open(name, 10);
|
||||
|
|
|
@ -12,9 +12,6 @@
|
|||
<script type="text/javascript;version=1.7">
|
||||
function testSteps()
|
||||
{
|
||||
const READ_ONLY = Components.interfaces.nsIIDBTransaction.READ_ONLY;
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
|
||||
const name = window.location.pathname;
|
||||
const description = "My Test Database";
|
||||
const osName = "foo";
|
||||
|
@ -34,82 +31,82 @@
|
|||
|
||||
let key1, key2;
|
||||
|
||||
request = db.transaction([osName], READ_WRITE)
|
||||
request = db.transaction([osName], "readwrite")
|
||||
.objectStore(osName)
|
||||
.add({});
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
is(event.target.transaction.mode, READ_WRITE, "Correct mode");
|
||||
is(event.target.transaction.mode, "readwrite", "Correct mode");
|
||||
key1 = event.target.result;
|
||||
testGenerator.next();
|
||||
}
|
||||
yield;
|
||||
|
||||
request = db.transaction(osName, READ_WRITE).objectStore(osName).add({});
|
||||
request = db.transaction(osName, "readwrite").objectStore(osName).add({});
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
is(event.target.transaction.mode, READ_WRITE, "Correct mode");
|
||||
is(event.target.transaction.mode, "readwrite", "Correct mode");
|
||||
key2 = event.target.result;
|
||||
testGenerator.next();
|
||||
}
|
||||
yield;
|
||||
|
||||
request = db.transaction([osName], READ_WRITE)
|
||||
request = db.transaction([osName], "readwrite")
|
||||
.objectStore(osName)
|
||||
.put({}, key1);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
is(event.target.transaction.mode, READ_WRITE, "Correct mode");
|
||||
is(event.target.transaction.mode, "readwrite", "Correct mode");
|
||||
testGenerator.next();
|
||||
}
|
||||
yield;
|
||||
|
||||
request = db.transaction(osName, READ_WRITE)
|
||||
request = db.transaction(osName, "readwrite")
|
||||
.objectStore(osName)
|
||||
.put({}, key2);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
is(event.target.transaction.mode, READ_WRITE, "Correct mode");
|
||||
is(event.target.transaction.mode, "readwrite", "Correct mode");
|
||||
testGenerator.next();
|
||||
}
|
||||
yield;
|
||||
|
||||
request = db.transaction([osName], READ_WRITE)
|
||||
request = db.transaction([osName], "readwrite")
|
||||
.objectStore(osName)
|
||||
.put({}, key1);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
is(event.target.transaction.mode, READ_WRITE, "Correct mode");
|
||||
is(event.target.transaction.mode, "readwrite", "Correct mode");
|
||||
testGenerator.next();
|
||||
}
|
||||
yield;
|
||||
|
||||
request = db.transaction(osName, READ_WRITE)
|
||||
request = db.transaction(osName, "readwrite")
|
||||
.objectStore(osName)
|
||||
.put({}, key1);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
is(event.target.transaction.mode, READ_WRITE, "Correct mode");
|
||||
is(event.target.transaction.mode, "readwrite", "Correct mode");
|
||||
testGenerator.next();
|
||||
}
|
||||
yield;
|
||||
|
||||
request = db.transaction([osName], READ_WRITE)
|
||||
request = db.transaction([osName], "readwrite")
|
||||
.objectStore(osName)
|
||||
.delete(key1);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
is(event.target.transaction.mode, READ_WRITE, "Correct mode");
|
||||
is(event.target.transaction.mode, "readwrite", "Correct mode");
|
||||
testGenerator.next();
|
||||
}
|
||||
yield;
|
||||
|
||||
request = db.transaction(osName, READ_WRITE)
|
||||
request = db.transaction(osName, "readwrite")
|
||||
.objectStore(osName)
|
||||
.delete(key2);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
is(event.target.transaction.mode, READ_WRITE, "Correct mode");
|
||||
is(event.target.transaction.mode, "readwrite", "Correct mode");
|
||||
testGenerator.next();
|
||||
}
|
||||
yield;
|
||||
|
|
|
@ -144,7 +144,7 @@ function testSteps()
|
|||
|
||||
count = dataCount - 1;
|
||||
|
||||
getObjectStore().openCursor(null, IDBCursor.PREV).onsuccess = function(event) {
|
||||
getObjectStore().openCursor(null, "prev").onsuccess = function(event) {
|
||||
let cursor = event.target.result;
|
||||
if (cursor) {
|
||||
is(cursor.primaryKey, count, "Got correct object");
|
||||
|
@ -167,7 +167,7 @@ function testSteps()
|
|||
|
||||
count = dataCount - 1;
|
||||
|
||||
getObjectStore().openCursor(null, IDBCursor.PREV).onsuccess = function(event) {
|
||||
getObjectStore().openCursor(null, "prev").onsuccess = function(event) {
|
||||
let cursor = event.target.result;
|
||||
if (cursor) {
|
||||
is(cursor.primaryKey, count, "Got correct object");
|
||||
|
|
|
@ -7,8 +7,6 @@ var testGenerator = testSteps();
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
const entryCount = 1000;
|
||||
|
@ -64,7 +62,7 @@ function testSteps()
|
|||
ok(true, "clear should throw on READ_ONLY transactions");
|
||||
}
|
||||
|
||||
request = db.transaction("foo", READ_WRITE).objectStore("foo").clear();
|
||||
request = db.transaction("foo", "readwrite").objectStore("foo").clear();
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield;
|
||||
|
@ -84,7 +82,7 @@ function testSteps()
|
|||
}
|
||||
yield;
|
||||
|
||||
request = db.transaction("foo", READ_WRITE).objectStore("foo").add({});
|
||||
request = db.transaction("foo", "readwrite").objectStore("foo").add({});
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield;
|
||||
|
|
|
@ -7,9 +7,6 @@ var testGenerator = testSteps();
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
|
||||
const nsIIDBTransaction = Components.interfaces.nsIIDBTransaction;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
const objectStoreInfo = [
|
||||
|
@ -109,9 +106,7 @@ function testSteps()
|
|||
ok(event.target.transaction, "event has a transaction");
|
||||
ok(event.target.transaction.db === db,
|
||||
"transaction has the right db");
|
||||
is(event.target.transaction.readyState, nsIIDBTransaction.LOADING,
|
||||
"transaction has the correct readyState");
|
||||
is(event.target.transaction.mode, nsIIDBTransaction.VERSION_CHANGE,
|
||||
is(event.target.transaction.mode, "versionchange",
|
||||
"transaction has the correct mode");
|
||||
is(event.target.transaction.objectStoreNames.length, i + 1,
|
||||
"transaction only has one object store");
|
||||
|
|
|
@ -7,9 +7,6 @@ var testGenerator = testSteps();
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
|
||||
const nsIIDBTransaction = Components.interfaces.nsIIDBTransaction;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
const objectStoreInfo = [
|
||||
|
@ -87,9 +84,7 @@ function testSteps()
|
|||
|
||||
ok(event.target.transaction, "event has a transaction");
|
||||
ok(event.target.transaction.db === db, "transaction has the right db");
|
||||
is(event.target.transaction.readyState, nsIIDBTransaction.LOADING,
|
||||
"transaction has the correct readyState");
|
||||
is(event.target.transaction.mode, nsIIDBTransaction.VERSION_CHANGE,
|
||||
is(event.target.transaction.mode, "versionchange",
|
||||
"transaction has the correct mode");
|
||||
is(event.target.transaction.objectStoreNames.length, index + 1,
|
||||
"transaction has correct objectStoreNames list");
|
||||
|
|
|
@ -71,7 +71,7 @@ function testSteps()
|
|||
sawAdded = false;
|
||||
sawRemoved = false;
|
||||
|
||||
db.transaction("foo", IDBTransaction.READ_WRITE).objectStore("foo")
|
||||
db.transaction("foo", "readwrite").objectStore("foo")
|
||||
.index("name").openCursor().onsuccess = function(event) {
|
||||
event.target.transaction.oncomplete = continueToNextStep;
|
||||
let cursor = event.target.result;
|
||||
|
|
|
@ -7,9 +7,6 @@ var testGenerator = testSteps();
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const nsIIDBObjectStore = Components.interfaces.nsIIDBObjectStore;
|
||||
const nsIIDBTransaction = Components.interfaces.nsIIDBTransaction;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
const START_DATA = "hi";
|
||||
|
|
|
@ -286,7 +286,7 @@ function testSteps()
|
|||
let gotRemoveEvent = false;
|
||||
let retval = false;
|
||||
|
||||
request = objectStore.openCursor(null, IDBCursor.NEXT);
|
||||
request = objectStore.openCursor(null, "next");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -331,7 +331,7 @@ function testSteps()
|
|||
|
||||
keyIndex = sortedKeys.length - 1;
|
||||
|
||||
request = objectStore.openCursor(null, IDBCursor.PREV);
|
||||
request = objectStore.openCursor(null, "prev");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
|
|
@ -43,7 +43,7 @@ function testSteps()
|
|||
objectStore.createIndex("set", "", { unique: true });
|
||||
yield; // success
|
||||
|
||||
let trans = db.transaction("data", IDBTransaction.READ_WRITE);
|
||||
let trans = db.transaction("data", "readwrite");
|
||||
objectStore = trans.objectStore("data");
|
||||
index = objectStore.index("set");
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ function testSteps()
|
|||
const indexName = indexData[indexIndex].name;
|
||||
|
||||
let objectStore =
|
||||
db.transaction(objectStoreName, IDBTransaction.READ_WRITE)
|
||||
db.transaction(objectStoreName, "readwrite")
|
||||
.objectStore(objectStoreName);
|
||||
ok(true, "Got objectStore " + objectStoreName);
|
||||
|
||||
|
@ -133,7 +133,7 @@ function testSteps()
|
|||
|
||||
is(keyIndex, 1, "Saw all the items");
|
||||
|
||||
db.transaction(objectStoreName, IDBTransaction.READ_WRITE)
|
||||
db.transaction(objectStoreName, "readwrite")
|
||||
.objectStore(objectStoreName).clear()
|
||||
.onsuccess = continueToNextStep;
|
||||
yield;
|
||||
|
|
|
@ -52,7 +52,7 @@ function testSteps()
|
|||
let indexCount = event.target.result;
|
||||
|
||||
for each (let unique in [false, true]) {
|
||||
let index = db.transaction(autoIncrement, IDBTransaction.READ_WRITE)
|
||||
let index = db.transaction(autoIncrement, "readwrite")
|
||||
.objectStore(autoIncrement)
|
||||
.index(unique);
|
||||
|
||||
|
@ -86,7 +86,7 @@ function testSteps()
|
|||
is(sawEntry, true, "Saw entry for key value " + modifiedEntry);
|
||||
|
||||
// Recount index. Shouldn't change.
|
||||
index = db.transaction(autoIncrement, IDBTransaction.READ_WRITE)
|
||||
index = db.transaction(autoIncrement, "readwrite")
|
||||
.objectStore(autoIncrement)
|
||||
.index(unique);
|
||||
|
||||
|
@ -121,7 +121,7 @@ function testSteps()
|
|||
is(sawEntry, true, "Saw entry for key value " + modifiedEntry);
|
||||
|
||||
// Recount objectStore. Should be unchanged.
|
||||
objectStore = db.transaction(autoIncrement, IDBTransaction.READ_WRITE)
|
||||
objectStore = db.transaction(autoIncrement, "readwrite")
|
||||
.objectStore(autoIncrement);
|
||||
|
||||
objectStore.count().onsuccess = grabEventAndContinueHandler;
|
||||
|
|
|
@ -9,13 +9,6 @@ function testSteps()
|
|||
{
|
||||
const CONSTRAINT_ERR =
|
||||
Components.interfaces.nsIIDBDatabaseException.CONSTRAINT_ERR;
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
const NEXT = Components.interfaces.nsIIDBCursor.NEXT;
|
||||
const PREV = Components.interfaces.nsIIDBCursor.PREV;
|
||||
const NEXT_NO_DUPLICATE =
|
||||
Components.interfaces.nsIIDBCursor.NEXT_NO_DUPLICATE;
|
||||
const PREV_NO_DUPLICATE =
|
||||
Components.interfaces.nsIIDBCursor.PREV_NO_DUPLICATE;
|
||||
|
||||
const name = this.window ? this.window ? window.location.pathname : "Splendid Test" : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
|
@ -167,7 +160,7 @@ function testSteps()
|
|||
|
||||
keyIndex = 0;
|
||||
|
||||
request = objectStore.index("weight").openKeyCursor(null, NEXT);
|
||||
request = objectStore.index("weight").openKeyCursor(null, "next");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -195,7 +188,7 @@ function testSteps()
|
|||
is(keyIndex, objectStoreData.length - 1, "Saw all the expected keys");
|
||||
|
||||
// Check that the name index enforces its unique constraint.
|
||||
objectStore = db.transaction(objectStoreName, READ_WRITE)
|
||||
objectStore = db.transaction(objectStoreName, "readwrite")
|
||||
.objectStore(objectStoreName);
|
||||
request = objectStore.add({ name: "Bob", height: 62, weight: 170 },
|
||||
"237-23-7738");
|
||||
|
@ -207,7 +200,7 @@ function testSteps()
|
|||
|
||||
keyIndex = objectStoreDataNameSort.length - 1;
|
||||
|
||||
request = objectStore.index("name").openKeyCursor(null, PREV);
|
||||
request = objectStore.index("name").openKeyCursor(null, "prev");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -523,7 +516,7 @@ function testSteps()
|
|||
|
||||
keyIndex = objectStoreDataNameSort.length - 1;
|
||||
|
||||
request = objectStore.index("name").openCursor(null, PREV);
|
||||
request = objectStore.index("name").openCursor(null, "prev");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -783,7 +776,7 @@ function testSteps()
|
|||
keyIndex = 4;
|
||||
keyRange = IDBKeyRange.bound("Bob", "Ron");
|
||||
|
||||
request = objectStore.index("name").openCursor(keyRange, PREV);
|
||||
request = objectStore.index("name").openCursor(keyRange, "prev");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -832,11 +825,11 @@ function testSteps()
|
|||
|
||||
ok(true, "Test group 20");
|
||||
|
||||
// Test NEXT_NO_DUPLICATE
|
||||
// Test "nextunique"
|
||||
keyIndex = 3;
|
||||
keyRange = IDBKeyRange.only(65);
|
||||
|
||||
request = objectStore.index("height").openKeyCursor(keyRange, NEXT);
|
||||
request = objectStore.index("height").openKeyCursor(keyRange, "next");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -863,7 +856,7 @@ function testSteps()
|
|||
keyRange = IDBKeyRange.only(65);
|
||||
|
||||
request = objectStore.index("height").openKeyCursor(keyRange,
|
||||
NEXT_NO_DUPLICATE);
|
||||
"nextunique");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -888,7 +881,7 @@ function testSteps()
|
|||
|
||||
keyIndex = 5;
|
||||
|
||||
request = objectStore.index("height").openKeyCursor(null, PREV);
|
||||
request = objectStore.index("height").openKeyCursor(null, "prev");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -914,7 +907,7 @@ function testSteps()
|
|||
keyIndex = 5;
|
||||
|
||||
request = objectStore.index("height").openKeyCursor(null,
|
||||
PREV_NO_DUPLICATE);
|
||||
"prevunique");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -943,7 +936,7 @@ function testSteps()
|
|||
keyIndex = 3;
|
||||
keyRange = IDBKeyRange.only(65);
|
||||
|
||||
request = objectStore.index("height").openCursor(keyRange, NEXT);
|
||||
request = objectStore.index("height").openCursor(keyRange, "next");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -980,7 +973,7 @@ function testSteps()
|
|||
keyRange = IDBKeyRange.only(65);
|
||||
|
||||
request = objectStore.index("height").openCursor(keyRange,
|
||||
NEXT_NO_DUPLICATE);
|
||||
"nextunique");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -1015,7 +1008,7 @@ function testSteps()
|
|||
|
||||
keyIndex = 5;
|
||||
|
||||
request = objectStore.index("height").openCursor(null, PREV);
|
||||
request = objectStore.index("height").openCursor(null, "prev");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
@ -1051,7 +1044,7 @@ function testSteps()
|
|||
keyIndex = 5;
|
||||
|
||||
request = objectStore.index("height").openCursor(null,
|
||||
PREV_NO_DUPLICATE);
|
||||
"prevunique");
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function (event) {
|
||||
let cursor = event.target.result;
|
||||
|
|
|
@ -9,7 +9,6 @@ function testSteps()
|
|||
{
|
||||
const CONSTRAINT_ERR =
|
||||
Components.interfaces.nsIIDBDatabaseException.CONSTRAINT_ERR;
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
|
|
|
@ -8,7 +8,7 @@ var testGenerator = testSteps();
|
|||
function testSteps()
|
||||
{
|
||||
const dbname = this.window ? window.location.pathname : "Splendid Test";
|
||||
const RW = IDBTransaction.READ_WRITE
|
||||
const RW = "readwrite"
|
||||
let c1 = 1;
|
||||
let c2 = 1;
|
||||
|
||||
|
|
|
@ -207,7 +207,7 @@ function testSteps()
|
|||
openRequest.onsuccess = grabEventAndContinueHandler;
|
||||
yield;
|
||||
|
||||
let trans = db.transaction(["mystore"], IDBTransaction.READ_WRITE);
|
||||
let trans = db.transaction(["mystore"], "readwrite");
|
||||
store = trans.objectStore("mystore");
|
||||
index = store.index("myindex");
|
||||
is(index.multiEntry, true, "index still is multiEntry");
|
||||
|
|
|
@ -27,7 +27,7 @@ function testSteps()
|
|||
event.target.onsuccess = continueToNextStep;
|
||||
yield;
|
||||
|
||||
objectStore = db.transaction("foo", IDBTransaction.READ_WRITE)
|
||||
objectStore = db.transaction("foo", "readwrite")
|
||||
.objectStore("foo");
|
||||
request = objectStore.add(data);
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
|
@ -56,7 +56,7 @@ function testSteps()
|
|||
is(obj.key, data.key, "Got the right key");
|
||||
is(obj.index, data.index, "Got the right property value");
|
||||
|
||||
objectStore = db.transaction("foo", IDBTransaction.READ_WRITE)
|
||||
objectStore = db.transaction("foo", "readwrite")
|
||||
.objectStore("foo");
|
||||
request = objectStore.delete(data.key);
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
|
|
|
@ -152,7 +152,7 @@ function testSteps()
|
|||
|
||||
is(event.target.result.name, data[3].name, "Correct data");
|
||||
|
||||
objectStore = db.transaction(osName, IDBTransaction.READ_WRITE)
|
||||
objectStore = db.transaction(osName, "readwrite")
|
||||
.objectStore(osName);
|
||||
|
||||
try {
|
||||
|
|
|
@ -7,8 +7,6 @@ var testGenerator = testSteps();
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
const objectStores = [ "foo", "bar" ];
|
||||
|
@ -33,7 +31,7 @@ function testSteps()
|
|||
for (let i = 0; i < 50; i++) {
|
||||
let stepNumber = 0;
|
||||
|
||||
request = db.transaction(["foo"], READ_WRITE)
|
||||
request = db.transaction(["foo"], "readwrite")
|
||||
.objectStore("foo")
|
||||
.add({});
|
||||
request.onerror = errorHandler;
|
||||
|
@ -43,7 +41,7 @@ function testSteps()
|
|||
event.target.transaction.oncomplete = grabEventAndContinueHandler;
|
||||
}
|
||||
|
||||
request = db.transaction(["foo"], READ_WRITE)
|
||||
request = db.transaction(["foo"], "readwrite")
|
||||
.objectStore("foo")
|
||||
.add({});
|
||||
request.onerror = errorHandler;
|
||||
|
@ -53,7 +51,7 @@ function testSteps()
|
|||
event.target.transaction.oncomplete = grabEventAndContinueHandler;
|
||||
}
|
||||
|
||||
request = db.transaction(["foo", "bar"], READ_WRITE)
|
||||
request = db.transaction(["foo", "bar"], "readwrite")
|
||||
.objectStore("bar")
|
||||
.add({});
|
||||
request.onerror = errorHandler;
|
||||
|
@ -63,7 +61,7 @@ function testSteps()
|
|||
event.target.transaction.oncomplete = grabEventAndContinueHandler;
|
||||
}
|
||||
|
||||
request = db.transaction(["foo", "bar"], READ_WRITE)
|
||||
request = db.transaction(["foo", "bar"], "readwrite")
|
||||
.objectStore("bar")
|
||||
.add({});
|
||||
request.onerror = errorHandler;
|
||||
|
@ -73,7 +71,7 @@ function testSteps()
|
|||
event.target.transaction.oncomplete = grabEventAndContinueHandler;
|
||||
}
|
||||
|
||||
request = db.transaction(["bar"], READ_WRITE)
|
||||
request = db.transaction(["bar"], "readwrite")
|
||||
.objectStore("bar")
|
||||
.add({});
|
||||
request.onerror = errorHandler;
|
||||
|
|
|
@ -10,17 +10,14 @@ function testSteps()
|
|||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
|
||||
const LOADING = Components.interfaces.nsIIDBRequest.LOADING;
|
||||
const DONE = Components.interfaces.nsIIDBRequest.DONE;
|
||||
|
||||
let request = mozIndexedDB.open(name, 1, description);
|
||||
is(request.readyState, LOADING, "Correct readyState");
|
||||
is(request.readyState, "pending", "Correct readyState");
|
||||
|
||||
request.onerror = errorHandler;
|
||||
request.onupgradeneeded = grabEventAndContinueHandler;
|
||||
let event = yield;
|
||||
|
||||
is(request.readyState, DONE, "Correct readyState");
|
||||
is(request.readyState, "done", "Correct readyState");
|
||||
|
||||
let db = event.target.result;
|
||||
|
||||
|
@ -28,23 +25,23 @@ function testSteps()
|
|||
let key = 10;
|
||||
|
||||
request = objectStore.add({}, key);
|
||||
is(request.readyState, LOADING, "Correct readyState");
|
||||
is(request.readyState, "pending", "Correct readyState");
|
||||
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield;
|
||||
|
||||
is(request.readyState, DONE, "Correct readyState");
|
||||
is(request.readyState, "done", "Correct readyState");
|
||||
is(event.target.result, key, "Correct key");
|
||||
|
||||
request = objectStore.get(key);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
is(request.readyState, LOADING, "Correct readyState");
|
||||
is(request.readyState, "pending", "Correct readyState");
|
||||
event = yield;
|
||||
|
||||
ok(event.target.result, "Got something");
|
||||
is(request.readyState, DONE, "Correct readyState");
|
||||
is(request.readyState, "done", "Correct readyState");
|
||||
|
||||
finishTest();
|
||||
yield;
|
||||
|
|
|
@ -7,9 +7,6 @@ var testGenerator = testSteps();
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
const VERSION_CHANGE = Components.interfaces.nsIIDBTransaction.VERSION_CHANGE;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
|
||||
|
@ -41,7 +38,7 @@ function testSteps()
|
|||
let db = event.target.result;
|
||||
|
||||
is(db.version, version, "Database version number updated correctly");
|
||||
is(event.target.transaction.mode, VERSION_CHANGE, "Correct mode");
|
||||
is(event.target.transaction.mode, "versionchange", "Correct mode");
|
||||
|
||||
executeSoon(function() { testGenerator.next(); });
|
||||
yield;
|
||||
|
|
|
@ -7,9 +7,6 @@ var testGenerator = testSteps();
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
const VERSION_CHANGE = Components.interfaces.nsIIDBTransaction.VERSION_CHANGE;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ function testSteps()
|
|||
ok(event instanceof IDBVersionChangeEvent, "Event is of the right type");
|
||||
ok(event.target.result instanceof IDBDatabase, "Good result");
|
||||
db2 = event.target.result;
|
||||
is(event.target.transaction.mode, IDBTransaction.VERSION_CHANGE,
|
||||
is(event.target.transaction.mode, "versionchange",
|
||||
"Correct mode");
|
||||
is(db2.version, 2, "Correct db version");
|
||||
is(event.oldVersion, 1, "Correct event oldVersion");
|
||||
|
@ -127,7 +127,7 @@ function testSteps()
|
|||
|
||||
ok(event instanceof IDBVersionChangeEvent, "Event is of the right type");
|
||||
ok(event.target.result instanceof IDBDatabase, "Good result");
|
||||
is(event.target.transaction.mode, IDBTransaction.VERSION_CHANGE,
|
||||
is(event.target.transaction.mode, "versionchange",
|
||||
"Correct mode");
|
||||
is(event.oldVersion, 3, "Correct event oldVersion");
|
||||
is(event.newVersion, 4, "Correct event newVersion");
|
||||
|
|
|
@ -13,14 +13,6 @@ function testSteps()
|
|||
{
|
||||
const Ci = Components.interfaces;
|
||||
|
||||
const INITIAL = Ci.nsIIDBTransaction.INITIAL;
|
||||
const LOADING = Ci.nsIIDBTransaction.LOADING;
|
||||
const COMMITTING = Ci.nsIIDBTransaction.COMMITTING;
|
||||
const DONE = Ci.nsIIDBTransaction.DONE;
|
||||
const READ_ONLY = Ci.nsIIDBTransaction.READ_ONLY;
|
||||
const READ_WRITE = Ci.nsIIDBTransaction.READ_WRITE;
|
||||
const VERSION_CHANGE = Ci.nsIIDBTransaction.VERSION_CHANGE;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
|
||||
|
@ -43,8 +35,7 @@ function testSteps()
|
|||
index = objectStore.createIndex("fooindex", "indexKey", { unique: true });
|
||||
|
||||
is(transaction.db, db, "Correct database");
|
||||
is(transaction.readyState, LOADING, "Correct readyState");
|
||||
is(transaction.mode, VERSION_CHANGE, "Correct mode");
|
||||
is(transaction.mode, "versionchange", "Correct mode");
|
||||
is(transaction.objectStoreNames.length, 1, "Correct names length");
|
||||
is(transaction.objectStoreNames.item(0), "foo", "Correct name");
|
||||
is(transaction.objectStore("foo"), objectStore, "Can get stores");
|
||||
|
@ -63,8 +54,7 @@ function testSteps()
|
|||
event = yield;
|
||||
|
||||
is(transaction.db, db, "Correct database");
|
||||
is(transaction.readyState, DONE, "Correct readyState");
|
||||
is(transaction.mode, VERSION_CHANGE, "Correct mode");
|
||||
is(transaction.mode, "versionchange", "Correct mode");
|
||||
is(transaction.objectStoreNames.length, 1, "Correct names length");
|
||||
is(transaction.objectStoreNames.item(0), "foo", "Correct name");
|
||||
is(transaction.onabort, null, "No abort listener");
|
||||
|
@ -165,7 +155,7 @@ function testSteps()
|
|||
|
||||
yield;
|
||||
|
||||
request = db.transaction("foo", READ_WRITE).objectStore("foo").add({});
|
||||
request = db.transaction("foo", "readwrite").objectStore("foo").add({});
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield;
|
||||
|
@ -180,7 +170,7 @@ function testSteps()
|
|||
|
||||
let key;
|
||||
|
||||
request = db.transaction("foo", READ_WRITE).objectStore("foo").add({});
|
||||
request = db.transaction("foo", "readwrite").objectStore("foo").add({});
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
event = yield;
|
||||
|
@ -192,9 +182,7 @@ function testSteps()
|
|||
ok(false, "Shouldn't see a complete event here!");
|
||||
};
|
||||
|
||||
is(event.target.transaction.readyState, LOADING, "Correct readyState");
|
||||
event.target.transaction.abort();
|
||||
is(event.target.transaction.readyState, DONE, "Correct readyState");
|
||||
|
||||
event = yield;
|
||||
|
||||
|
@ -218,7 +206,7 @@ function testSteps()
|
|||
abortEventCount++;
|
||||
event.preventDefault();
|
||||
};
|
||||
objectStore = db.transaction("foo", READ_WRITE).objectStore("foo");
|
||||
objectStore = db.transaction("foo", "readwrite").objectStore("foo");
|
||||
|
||||
for (let i = 0; i < 10; i++) {
|
||||
request = objectStore.add({});
|
||||
|
@ -247,7 +235,7 @@ function testSteps()
|
|||
}
|
||||
|
||||
// Set up some predictible data
|
||||
transaction = db.transaction("foo", READ_WRITE);
|
||||
transaction = db.transaction("foo", "readwrite");
|
||||
objectStore = transaction.objectStore("foo");
|
||||
objectStore.clear();
|
||||
objectStore.add({}, 1);
|
||||
|
@ -269,9 +257,7 @@ function testSteps()
|
|||
|
||||
// During INITIAL
|
||||
transaction = db.transaction("foo");
|
||||
is(transaction.readyState, INITIAL, "in INITIAL state");
|
||||
transaction.abort();
|
||||
is(transaction.readyState, DONE, "in DONE state after abort()");
|
||||
try {
|
||||
transaction.abort();
|
||||
ok(false, "second abort should throw an error");
|
||||
|
@ -284,9 +270,7 @@ function testSteps()
|
|||
transaction = db.transaction("foo");
|
||||
transaction.objectStore("foo").get(1).onerror = abortErrorHandler;
|
||||
expectedAbortEventCount++;
|
||||
is(transaction.readyState, LOADING, "in LOADING state");
|
||||
transaction.abort();
|
||||
is(transaction.readyState, DONE, "in DONE state after abort()");
|
||||
try {
|
||||
transaction.abort();
|
||||
ok(false, "second abort should throw an error");
|
||||
|
@ -301,9 +285,7 @@ function testSteps()
|
|||
event = yield;
|
||||
transaction.objectStore("foo").get(1).onerror = abortErrorHandler;
|
||||
expectedAbortEventCount++
|
||||
is(transaction.readyState, LOADING, "in LOADING state");
|
||||
transaction.abort();
|
||||
is(transaction.readyState, DONE, "in DONE state after abort()");
|
||||
try {
|
||||
transaction.abort();
|
||||
ok(false, "second abort should throw an error");
|
||||
|
@ -313,16 +295,14 @@ function testSteps()
|
|||
}
|
||||
|
||||
// During LOADING from error callback
|
||||
transaction = db.transaction("foo", READ_WRITE);
|
||||
transaction = db.transaction("foo", "readwrite");
|
||||
transaction.objectStore("foo").add({}, 1).onerror = function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
transaction.objectStore("foo").get(1).onerror = abortErrorHandler;
|
||||
expectedAbortEventCount++
|
||||
|
||||
is(transaction.readyState, LOADING, "in LOADING state");
|
||||
transaction.abort();
|
||||
is(transaction.readyState, DONE, "in DONE state after abort()");
|
||||
continueToNextStep();
|
||||
}
|
||||
yield;
|
||||
|
@ -337,22 +317,19 @@ function testSteps()
|
|||
makeNewRequest();
|
||||
transaction.objectStore("foo").get(1).onsuccess = function(event) {
|
||||
executeSoon(function() {
|
||||
is(transaction.readyState, LOADING, "in LOADING state");
|
||||
transaction.abort();
|
||||
expectedAbortEventCount++;
|
||||
is(transaction.readyState, DONE, "in DONE state after abort()");
|
||||
continueToNextStep();
|
||||
});
|
||||
};
|
||||
yield;
|
||||
|
||||
// During COMMITTING
|
||||
transaction = db.transaction("foo", READ_WRITE);
|
||||
transaction = db.transaction("foo", "readwrite");
|
||||
transaction.objectStore("foo").put({hello: "world"}, 1).onsuccess = function(event) {
|
||||
continueToNextStep();
|
||||
};
|
||||
yield;
|
||||
is(transaction.readyState, COMMITTING, "in COMMITTING state");
|
||||
try {
|
||||
transaction.abort();
|
||||
ok(false, "second abort should throw an error");
|
||||
|
@ -362,7 +339,6 @@ function testSteps()
|
|||
}
|
||||
transaction.oncomplete = grabEventAndContinueHandler;
|
||||
event = yield;
|
||||
is(transaction.readyState, DONE, "in DONE state");
|
||||
|
||||
// Since the previous transaction shouldn't have caused any error events,
|
||||
// we know that all events should have fired by now.
|
||||
|
@ -370,7 +346,7 @@ function testSteps()
|
|||
"All abort errors fired");
|
||||
|
||||
// Abort both failing and succeeding requests
|
||||
transaction = db.transaction("foo", READ_WRITE);
|
||||
transaction = db.transaction("foo", "readwrite");
|
||||
transaction.onabort = transaction.oncomplete = grabEventAndContinueHandler;
|
||||
transaction.objectStore("foo").add({indexKey: "key"}).onsuccess = function(event) {
|
||||
transaction.abort();
|
||||
|
|
|
@ -20,7 +20,6 @@ function testSteps()
|
|||
yield;
|
||||
|
||||
let transaction1 = db.transaction("foo");
|
||||
is(transaction1.readyState, IDBTransaction.INITIAL, "Correct readyState");
|
||||
|
||||
let transaction2;
|
||||
|
||||
|
@ -35,29 +34,18 @@ function testSteps()
|
|||
thread.dispatch(function() {
|
||||
eventHasRun = true;
|
||||
|
||||
is(transaction1.readyState, IDBTransaction.INITIAL,
|
||||
"Correct readyState");
|
||||
|
||||
transaction2 = db.transaction("foo");
|
||||
is(transaction2.readyState, IDBTransaction.INITIAL,
|
||||
"Correct readyState");
|
||||
|
||||
}, Components.interfaces.nsIThread.DISPATCH_NORMAL);
|
||||
|
||||
while (!eventHasRun) {
|
||||
thread.processNextEvent(false);
|
||||
}
|
||||
|
||||
is(transaction1.readyState, IDBTransaction.INITIAL, "Correct readyState");
|
||||
|
||||
ok(transaction2, "Non-null transaction2");
|
||||
is(transaction2.readyState, IDBTransaction.DONE, "Correct readyState");
|
||||
|
||||
continueToNextStep();
|
||||
yield;
|
||||
|
||||
is(transaction1.readyState, IDBTransaction.DONE, "Correct readyState");
|
||||
|
||||
finishTest();
|
||||
yield;
|
||||
}
|
||||
|
|
|
@ -20,8 +20,8 @@ function testSteps()
|
|||
db.createObjectStore("foo");
|
||||
yield;
|
||||
|
||||
let trans1 = db.transaction("foo", IDBTransaction.READ_WRITE);
|
||||
let trans2 = db.transaction("foo", IDBTransaction.READ_WRITE);
|
||||
let trans1 = db.transaction("foo", "readwrite");
|
||||
let trans2 = db.transaction("foo", "readwrite");
|
||||
|
||||
let request1 = trans2.objectStore("foo").put("2", 42);
|
||||
let request2 = trans1.objectStore("foo").put("1", 42);
|
||||
|
@ -35,7 +35,7 @@ function testSteps()
|
|||
yield;
|
||||
yield;
|
||||
|
||||
let trans3 = db.transaction("foo", IDBTransaction.READ);
|
||||
let trans3 = db.transaction("foo", "readonly");
|
||||
let request = trans3.objectStore("foo").get(42);
|
||||
request.onsuccess = grabEventAndContinueHandler;
|
||||
request.onerror = errorHandler;
|
||||
|
|
|
@ -7,11 +7,6 @@ var testGenerator = testSteps();
|
|||
|
||||
function testSteps()
|
||||
{
|
||||
const READ_ONLY = Components.interfaces.nsIIDBTransaction.READ_ONLY;
|
||||
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
|
||||
const VERSION_CHANGE =
|
||||
Components.interfaces.nsIIDBTransaction.VERSION_CHANGE;
|
||||
|
||||
const name = this.window ? window.location.pathname : "Splendid Test";
|
||||
const description = "My Test Database";
|
||||
|
||||
|
@ -23,7 +18,7 @@ function testSteps()
|
|||
|
||||
let db = event.target.result;
|
||||
|
||||
is(event.target.transaction.mode, VERSION_CHANGE, "Correct mode");
|
||||
is(event.target.transaction.mode, "versionchange", "Correct mode");
|
||||
|
||||
let objectStore = db.createObjectStore("foo", { autoIncrement: true });
|
||||
|
||||
|
@ -58,10 +53,10 @@ function testSteps()
|
|||
request = db.transaction("foo").objectStore("foo").get(key);
|
||||
request.onerror = errorHandler;
|
||||
request.onsuccess = function(event) {
|
||||
is(event.target.transaction.mode, READ_ONLY, "Correct mode");
|
||||
is(event.target.transaction.mode, "readonly", "Correct mode");
|
||||
callbackCount++;
|
||||
if (callbackCount == 100) {
|
||||
request = db.transaction("foo", READ_WRITE)
|
||||
request = db.transaction("foo", "readwrite")
|
||||
.objectStore("foo")
|
||||
.add({}, readerCount);
|
||||
request.onerror = errorHandler;
|
||||
|
|
Загрузка…
Ссылка в новой задаче