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