Bug 618141 - 'IndexedDB: createObjectStore and createIndex should accept an optional object argument'. r=sicking, a=blocking.

This commit is contained in:
Ben Turner 2010-12-21 11:02:01 -05:00
Родитель e6f0c4526c
Коммит 60f0977f47
45 изменённых файлов: 304 добавлений и 153 удалений

Просмотреть файл

@ -1636,6 +1636,9 @@ jsid nsDOMClassInfo::sOnbeforescriptexecute_id = JSID_VOID;
jsid nsDOMClassInfo::sOnafterscriptexecute_id = JSID_VOID; jsid nsDOMClassInfo::sOnafterscriptexecute_id = JSID_VOID;
jsid nsDOMClassInfo::sWrappedJSObject_id = JSID_VOID; jsid nsDOMClassInfo::sWrappedJSObject_id = JSID_VOID;
jsid nsDOMClassInfo::sURL_id = JSID_VOID; jsid nsDOMClassInfo::sURL_id = JSID_VOID;
jsid nsDOMClassInfo::sKeyPath_id = JSID_VOID;
jsid nsDOMClassInfo::sAutoIncrement_id = JSID_VOID;
jsid nsDOMClassInfo::sUnique_id = JSID_VOID;
static const JSClass *sObjectClass = nsnull; static const JSClass *sObjectClass = nsnull;
@ -1866,6 +1869,9 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
#endif // MOZ_MEDIA #endif // MOZ_MEDIA
SET_JSID_TO_STRING(sWrappedJSObject_id, cx, "wrappedJSObject"); SET_JSID_TO_STRING(sWrappedJSObject_id, cx, "wrappedJSObject");
SET_JSID_TO_STRING(sURL_id, cx, "URL"); SET_JSID_TO_STRING(sURL_id, cx, "URL");
SET_JSID_TO_STRING(sKeyPath_id, cx, "keyPath");
SET_JSID_TO_STRING(sAutoIncrement_id, cx, "autoIncrement");
SET_JSID_TO_STRING(sUnique_id, cx, "unique");
return NS_OK; return NS_OK;
} }
@ -4927,6 +4933,9 @@ nsDOMClassInfo::ShutDown()
sOnbeforescriptexecute_id = JSID_VOID; sOnbeforescriptexecute_id = JSID_VOID;
sOnafterscriptexecute_id = JSID_VOID; sOnafterscriptexecute_id = JSID_VOID;
sWrappedJSObject_id = JSID_VOID; sWrappedJSObject_id = JSID_VOID;
sKeyPath_id = JSID_VOID;
sAutoIncrement_id = JSID_VOID;
sUnique_id = JSID_VOID;
NS_IF_RELEASE(sXPConnect); NS_IF_RELEASE(sXPConnect);
NS_IF_RELEASE(sSecMan); NS_IF_RELEASE(sSecMan);

Просмотреть файл

@ -282,6 +282,7 @@ protected:
static PRBool sDisableDocumentAllSupport; static PRBool sDisableDocumentAllSupport;
static PRBool sDisableGlobalScopePollutionSupport; static PRBool sDisableGlobalScopePollutionSupport;
public:
static jsid sTop_id; static jsid sTop_id;
static jsid sParent_id; static jsid sParent_id;
static jsid sScrollbars_id; static jsid sScrollbars_id;
@ -391,7 +392,11 @@ protected:
static jsid sOnafterscriptexecute_id; static jsid sOnafterscriptexecute_id;
static jsid sWrappedJSObject_id; static jsid sWrappedJSObject_id;
static jsid sURL_id; static jsid sURL_id;
static jsid sKeyPath_id;
static jsid sAutoIncrement_id;
static jsid sUnique_id;
protected:
static JSPropertyOp sXPCNativeWrapperGetPropertyOp; static JSPropertyOp sXPCNativeWrapperGetPropertyOp;
static JSPropertyOp sXrayWrapperPropertyHolderGetPropertyOp; static JSPropertyOp sXrayWrapperPropertyHolderGetPropertyOp;
}; };

Просмотреть файл

@ -39,10 +39,12 @@
#include "IDBDatabase.h" #include "IDBDatabase.h"
#include "jscntxt.h"
#include "mozilla/Mutex.h" #include "mozilla/Mutex.h"
#include "mozilla/storage.h" #include "mozilla/storage.h"
#include "nsDOMClassInfo.h" #include "nsDOMClassInfo.h"
#include "nsEventDispatcher.h" #include "nsEventDispatcher.h"
#include "nsJSUtils.h"
#include "nsProxyRelease.h" #include "nsProxyRelease.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
@ -523,8 +525,8 @@ IDBDatabase::GetObjectStoreNames(nsIDOMDOMStringList** aObjectStores)
NS_IMETHODIMP NS_IMETHODIMP
IDBDatabase::CreateObjectStore(const nsAString& aName, IDBDatabase::CreateObjectStore(const nsAString& aName,
const nsAString& aKeyPath, const jsval& aOptions,
PRBool aAutoIncrement, JSContext* aCx,
nsIIDBObjectStore** _retval) nsIIDBObjectStore** _retval)
{ {
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!"); NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
@ -534,12 +536,6 @@ IDBDatabase::CreateObjectStore(const nsAString& aName,
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR; return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
} }
// XPConnect makes "null" into a void string, we need an empty string.
nsString keyPath(aKeyPath);
if (keyPath.IsVoid()) {
keyPath.Truncate();
}
IDBTransaction* transaction = AsyncConnectionHelper::GetCurrentTransaction(); IDBTransaction* transaction = AsyncConnectionHelper::GetCurrentTransaction();
if (!transaction || if (!transaction ||
@ -556,12 +552,66 @@ IDBDatabase::CreateObjectStore(const nsAString& aName,
return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR; return NS_ERROR_DOM_INDEXEDDB_CONSTRAINT_ERR;
} }
nsString keyPath;
bool autoIncrement = false;
if (!JSVAL_IS_VOID(aOptions) && !JSVAL_IS_NULL(aOptions)) {
if (JSVAL_IS_PRIMITIVE(aOptions)) {
// XXX Update spec for a real code here
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
}
NS_ASSERTION(JSVAL_IS_OBJECT(aOptions), "Huh?!");
JSObject* options = JSVAL_TO_OBJECT(aOptions);
js::AutoIdArray ids(aCx, JS_Enumerate(aCx, options));
if (!ids) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
for (size_t index = 0; index < ids.length(); index++) {
jsid id = ids[index];
if (id != nsDOMClassInfo::sKeyPath_id &&
id != nsDOMClassInfo::sAutoIncrement_id) {
// XXX Update spec for a real code here
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
}
jsval val;
if (!JS_GetPropertyById(aCx, options, id, &val)) {
NS_WARNING("JS_GetPropertyById failed!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (id == nsDOMClassInfo::sKeyPath_id) {
JSString* str = JS_ValueToString(aCx, val);
if (!str) {
NS_WARNING("JS_ValueToString failed!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
keyPath = nsDependentJSString(str);
}
else if (id == nsDOMClassInfo::sAutoIncrement_id) {
JSBool boolVal;
if (!JS_ValueToBoolean(aCx, val, &boolVal)) {
NS_WARNING("JS_ValueToBoolean failed!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
autoIncrement = !!boolVal;
}
else {
NS_NOTREACHED("Shouldn't be able to get here!");
}
}
}
nsAutoPtr<ObjectStoreInfo> newInfo(new ObjectStoreInfo()); nsAutoPtr<ObjectStoreInfo> newInfo(new ObjectStoreInfo());
newInfo->name = aName; newInfo->name = aName;
newInfo->id = databaseInfo->nextObjectStoreId++; newInfo->id = databaseInfo->nextObjectStoreId++;
newInfo->keyPath = keyPath; newInfo->keyPath = keyPath;
newInfo->autoIncrement = aAutoIncrement; newInfo->autoIncrement = autoIncrement;
newInfo->databaseId = mDatabaseId; newInfo->databaseId = mDatabaseId;
if (!ObjectStoreInfo::Put(newInfo)) { if (!ObjectStoreInfo::Put(newInfo)) {

Просмотреть файл

@ -1192,7 +1192,8 @@ IDBObjectStore::OpenCursor(nsIIDBKeyRange* aKeyRange,
NS_IMETHODIMP NS_IMETHODIMP
IDBObjectStore::CreateIndex(const nsAString& aName, IDBObjectStore::CreateIndex(const nsAString& aName,
const nsAString& aKeyPath, const nsAString& aKeyPath,
PRBool aUnique, const jsval& aOptions,
JSContext* aCx,
nsIIDBIndex** _retval) nsIIDBIndex** _retval)
{ {
NS_PRECONDITION(NS_IsMainThread(), "Wrong thread!"); NS_PRECONDITION(NS_IsMainThread(), "Wrong thread!");
@ -1229,6 +1230,51 @@ IDBObjectStore::CreateIndex(const nsAString& aName,
NS_ASSERTION(mTransaction->IsOpen(), "Impossible!"); NS_ASSERTION(mTransaction->IsOpen(), "Impossible!");
bool unique = false;
// Get optional arguments.
if (!JSVAL_IS_VOID(aOptions) && !JSVAL_IS_NULL(aOptions)) {
if (JSVAL_IS_PRIMITIVE(aOptions)) {
// XXX Update spec for a real code here
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
}
NS_ASSERTION(JSVAL_IS_OBJECT(aOptions), "Huh?!");
JSObject* options = JSVAL_TO_OBJECT(aOptions);
js::AutoIdArray ids(aCx, JS_Enumerate(aCx, options));
if (!ids) {
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
for (size_t index = 0; index < ids.length(); index++) {
jsid id = ids[index];
if (id != nsDOMClassInfo::sUnique_id) {
// XXX Update spec for a real code here
return NS_ERROR_DOM_INDEXEDDB_NON_TRANSIENT_ERR;
}
jsval val;
if (!JS_GetPropertyById(aCx, options, id, &val)) {
NS_WARNING("JS_GetPropertyById failed!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
if (id == nsDOMClassInfo::sUnique_id) {
JSBool boolVal;
if (!JS_ValueToBoolean(aCx, val, &boolVal)) {
NS_WARNING("JS_ValueToBoolean failed!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
unique = !!boolVal;
}
else {
NS_NOTREACHED("Shouldn't be able to get here!");
}
}
}
DatabaseInfo* databaseInfo; DatabaseInfo* databaseInfo;
if (!DatabaseInfo::Get(mTransaction->Database()->Id(), &databaseInfo)) { if (!DatabaseInfo::Get(mTransaction->Database()->Id(), &databaseInfo)) {
NS_ERROR("This should never fail!"); NS_ERROR("This should never fail!");
@ -1243,7 +1289,7 @@ IDBObjectStore::CreateIndex(const nsAString& aName,
indexInfo->id = databaseInfo->nextIndexId++; indexInfo->id = databaseInfo->nextIndexId++;
indexInfo->name = aName; indexInfo->name = aName;
indexInfo->keyPath = aKeyPath; indexInfo->keyPath = aKeyPath;
indexInfo->unique = aUnique; indexInfo->unique = unique;
indexInfo->autoIncrement = mAutoIncrement; indexInfo->autoIncrement = mAutoIncrement;
// Don't leave this in the list if we fail below! // Don't leave this in the list if we fail below!

Просмотреть файл

@ -55,7 +55,7 @@ interface nsIDOMEventListener;
* 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, uuid(6563ebdc-4509-4aeb-ac14-7e78ad74e2d3)] [scriptable, uuid(42b38d02-1a29-45f0-99ef-04fd5b441270)]
interface nsIIDBDatabase : nsISupports interface nsIIDBDatabase : nsISupports
{ {
readonly attribute DOMString name; readonly attribute DOMString name;
@ -64,10 +64,18 @@ interface nsIIDBDatabase : nsISupports
readonly attribute nsIDOMDOMStringList objectStoreNames; readonly attribute nsIDOMDOMStringList objectStoreNames;
/**
* Optional arguments:
* - keyPath (string):
* Specifies key path on objects in the objectStore. Defaults to no key
* path.
* - autoIncrement (boolean):
* Specifies if the objectStore has a key generator. Defaults to false.
*/
[implicit_jscontext]
nsIIDBObjectStore nsIIDBObjectStore
createObjectStore(in AString name, createObjectStore(in AString name,
[optional /* none */] in AString keyPath, [optional /* none */] in jsval options);
[optional /* false */] in boolean autoIncrement);
void void
deleteObjectStore(in AString name); deleteObjectStore(in AString name);

Просмотреть файл

@ -55,7 +55,7 @@ interface nsIDOMDOMStringList;
* 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, uuid(64f34805-d3e3-4305-91f8-b2cafac3d33c)] [scriptable, uuid(6a65dc92-66e3-407a-a370-590a6c54664a)]
interface nsIIDBObjectStore : nsISupports interface nsIIDBObjectStore : nsISupports
{ {
readonly attribute DOMString name; readonly attribute DOMString name;
@ -104,11 +104,17 @@ interface nsIIDBObjectStore : nsISupports
openCursor([optional /* null */] in nsIIDBKeyRange range, openCursor([optional /* null */] in nsIIDBKeyRange range,
[optional /* NEXT */] in unsigned short direction); [optional /* NEXT */] in unsigned short direction);
// Returns object immediately /**
* Optional arguments:
* - unique (boolean):
* Specifies whether values in the index must be unique. Defaults to
* false.
*/
[implicit_jscontext]
nsIIDBIndex nsIIDBIndex
createIndex(in AString name, createIndex(in AString name,
in AString keyPath, in AString keyPath,
[optional /* false */] in boolean unique); [optional /* none */] in jsval options);
// Returns object immediately // Returns object immediately
nsIIDBIndex nsIIDBIndex

Просмотреть файл

@ -13,7 +13,7 @@ moz_indexedDB.open(parent.location).onsuccess = function(e) {
if (db.objectStoreNames.contains("mystore")) { if (db.objectStoreNames.contains("mystore")) {
db.deleteObjectStore("mystore"); db.deleteObjectStore("mystore");
} }
var store = db.createObjectStore("mystore", ""); var store = db.createObjectStore("mystore");
store.add({ hello: "world" }, 42); store.add({ hello: "world" }, 42);
trans.oncomplete = function() { trans.oncomplete = function() {
parent.postMessage("go", "http://mochi.test:8888"); parent.postMessage("go", "http://mochi.test:8888");

Просмотреть файл

@ -67,7 +67,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
db.createObjectStore("foo", "", true); db.createObjectStore("foo", { autoIncrement: true });
setTimeout(testFinishedCallback, 0, "ready"); setTimeout(testFinishedCallback, 0, "ready");
yield; yield;

Просмотреть файл

@ -77,7 +77,7 @@
is(db.version, "1", "Correct version"); is(db.version, "1", "Correct version");
is(db.objectStoreNames.length, 0, "Correct objectStoreNames length"); is(db.objectStoreNames.length, 0, "Correct objectStoreNames length");
let objectStore = db.createObjectStore("foo", ""); let objectStore = db.createObjectStore("foo");
is(db.objectStoreNames.length, 1, "Correct objectStoreNames length"); is(db.objectStoreNames.length, 1, "Correct objectStoreNames length");
ok(db.objectStoreNames.contains("foo"), "Has correct objectStore"); ok(db.objectStoreNames.contains("foo"), "Has correct objectStore");
@ -110,7 +110,7 @@
is(db.version, "1", "Correct version"); is(db.version, "1", "Correct version");
is(db.objectStoreNames.length, 0, "Correct objectStoreNames length"); is(db.objectStoreNames.length, 0, "Correct objectStoreNames length");
let objectStore = db.createObjectStore("foo", ""); let objectStore = db.createObjectStore("foo");
is(db.objectStoreNames.length, 1, "Correct objectStoreNames length"); is(db.objectStoreNames.length, 1, "Correct objectStoreNames length");
ok(db.objectStoreNames.contains("foo"), "Has correct objectStore"); ok(db.objectStoreNames.contains("foo"), "Has correct objectStore");

Просмотреть файл

@ -111,7 +111,7 @@
event.transaction.oncomplete = grabEventAndContinueHandler; event.transaction.oncomplete = grabEventAndContinueHandler;
db.createObjectStore("foo", "", true); db.createObjectStore("foo", { autoIncrement: true });
yield; yield;
let transaction = db.transaction("foo", IDBTransaction.READ_WRITE); let transaction = db.transaction("foo", IDBTransaction.READ_WRITE);

Просмотреть файл

@ -82,7 +82,7 @@
is(db.version, "1", "Correct version"); is(db.version, "1", "Correct version");
is(db.objectStoreNames.length, 0, "Correct objectStoreNames length"); is(db.objectStoreNames.length, 0, "Correct objectStoreNames length");
let objectStore = db.createObjectStore("foo", ""); let objectStore = db.createObjectStore("foo");
is(db.objectStoreNames.length, 1, "Correct objectStoreNames length"); is(db.objectStoreNames.length, 1, "Correct objectStoreNames length");
ok(db.objectStoreNames.contains("foo"), "Has correct objectStore"); ok(db.objectStoreNames.contains("foo"), "Has correct objectStore");

Просмотреть файл

@ -28,7 +28,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
let event = yield; let event = yield;
let objectStore = db.createObjectStore("foo", ""); let objectStore = db.createObjectStore("foo", { keyPath: "" });
let key = 10; let key = 10;
request = objectStore.add({}, key); request = objectStore.add({}, key);

Просмотреть файл

@ -28,7 +28,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore("foo", "keyPath"); let objectStore = db.createObjectStore("foo", { keyPath: "keyPath" });
request = objectStore.add({keyPath:"foo"}); request = objectStore.add({keyPath:"foo"});
request.onerror = errorHandler; request.onerror = errorHandler;

Просмотреть файл

@ -33,7 +33,7 @@
event.transaction.oncomplete = continueToNextStep; event.transaction.oncomplete = continueToNextStep;
let objectStore = db.createObjectStore("foo", "", true); let objectStore = db.createObjectStore("foo", { autoIncrement: true });
let firstKey; let firstKey;
for (let i = 0; i < entryCount; i++) { for (let i = 0; i < entryCount; i++) {

Просмотреть файл

@ -19,13 +19,13 @@
const name = window.location.pathname; const name = window.location.pathname;
const description = "My Test Database"; const description = "My Test Database";
const objectStoreInfo = [ const objectStoreInfo = [
{ name: "a", keyPath: "id", autoIncrement: true }, { name: "a", options: { keyPath: "id", autoIncrement: true } },
{ name: "b", keyPath: "id", autoIncrement: false }, { name: "b", options: { keyPath: "id", autoIncrement: false } },
]; ];
const indexInfo = [ const indexInfo = [
{ name: "1", keyPath: "unique_value", unique: true }, { name: "1", keyPath: "unique_value", options: { unique: true } },
{ name: "2", keyPath: "value", unique: false }, { name: "2", keyPath: "value", options: { unique: false } },
{ name: "3", keyPath: "value" }, { name: "3", keyPath: "value", options: { unique: false } },
]; ];
let request = moz_indexedDB.open(name, description); let request = moz_indexedDB.open(name, description);
@ -41,10 +41,9 @@
for (let i = 0; i < objectStoreInfo.length; i++) { for (let i = 0; i < objectStoreInfo.length; i++) {
let info = objectStoreInfo[i]; let info = objectStoreInfo[i];
let objectStore = info.hasOwnProperty("autoIncrement") ? let objectStore = info.hasOwnProperty("options") ?
db.createObjectStore(info.name, info.keyPath, db.createObjectStore(info.name, info.options) :
info.autoIncrement) : db.createObjectStore(info.name);
db.createObjectStore(info.name, info.keyPath);
// Test basic failure conditions. // Test basic failure conditions.
try { try {
@ -71,19 +70,35 @@
ok(true, "createIndex with no keyPath should throw"); ok(true, "createIndex with no keyPath should throw");
} }
try {
request = objectStore.createIndex("foo", "bar", 10);
ok(false, "createIndex with bad options should throw");
}
catch(e) {
ok(true, "createIndex with bad options threw");
}
try {
request = objectStore.createIndex("foo", "bar", { foo: "" });
ok(false, "createIndex with bad options should throw");
}
catch(e) {
ok(true, "createIndex with bad options threw");
}
// Test index creation, and that it ends up in indexNames. // Test index creation, and that it ends up in indexNames.
let objectStoreName = info.name; let objectStoreName = info.name;
for (let j = 0; j < indexInfo.length; j++) { for (let j = 0; j < indexInfo.length; j++) {
let info = indexInfo[j]; let info = indexInfo[j];
let count = objectStore.indexNames.length; let count = objectStore.indexNames.length;
let index = info.hasOwnProperty("unique") ? let index = info.hasOwnProperty("options") ?
objectStore.createIndex(info.name, info.keyPath, objectStore.createIndex(info.name, info.keyPath,
info.unique) : info.options) :
objectStore.createIndex(info.name, info.keyPath); objectStore.createIndex(info.name, info.keyPath);
is(index.name, info.name, "correct name"); is(index.name, info.name, "correct name");
is(index.keyPath, info.keyPath, "correct keyPath"); is(index.keyPath, info.keyPath, "correct keyPath");
is(index.unique, !!info.unique, "correct uniqueness"); is(index.unique, info.options.unique, "correct uniqueness");
is(objectStore.indexNames.length, count + 1, is(objectStore.indexNames.length, count + 1,
"indexNames grew in size"); "indexNames grew in size");

Просмотреть файл

@ -19,15 +19,17 @@
const name = window.location.pathname; const name = window.location.pathname;
const description = "My Test Database"; const description = "My Test Database";
const objectStoreInfo = [ const objectStoreInfo = [
{ name: "1", keyPath: "" }, { name: "1", options: { keyPath: "" } },
{ name: "2", keyPath: "", autoIncrement: true }, { name: "2", options: { keyPath: "", autoIncrement: true } },
{ name: "3", keyPath: "", autoIncrement: false }, { name: "3", options: { keyPath: "", autoIncrement: false } },
{ name: "4", keyPath: "" }, { name: "4", options: { keyPath: "" } },
{ name: "5", keyPath: null }, { name: "5", options: { keyPath: "foo" } },
{ name: "6", keyPath: "foo" }, { name: "6" },
{ name: "7" }, { name: "7", options: null },
{ name: "8", autoIncrement: true }, { name: "8", options: { autoIncrement: true } },
{ name: "9", autoIncrement: false } { name: "9", options: { autoIncrement: false } },
{ name: "10", options: { keyPath: "foo", autoIncrement: false } },
{ name: "11", options: { keyPath: "foo", autoIncrement: true } }
]; ];
let request = moz_indexedDB.open(name, description); let request = moz_indexedDB.open(name, description);
@ -64,29 +66,29 @@
ok(true, "createObjectStore with empty name should throw"); ok(true, "createObjectStore with empty name should throw");
} }
try {
db.createObjectStore("foo", "bar");
ok(false, "createObjectStore with bad options should throw");
}
catch(e) {
ok(true, "createObjectStore with bad options");
}
try {
db.createObjectStore("foo", { foo: "" });
ok(false, "createObjectStore with bad options should throw");
}
catch(e) {
ok(true, "createObjectStore with bad options");
}
for (let index in objectStoreInfo) { for (let index in objectStoreInfo) {
index = parseInt(index); index = parseInt(index);
const info = objectStoreInfo[index]; const info = objectStoreInfo[index];
let objectStore; let objectStore = info.hasOwnProperty("options") ?
if (info.hasOwnProperty("keyPath")) { db.createObjectStore(info.name, info.options) :
if (info.hasOwnProperty("autoIncrement")) { db.createObjectStore(info.name);
objectStore = db.createObjectStore(info.name, info.keyPath,
info.autoIncrement);
}
else {
objectStore = db.createObjectStore(info.name, info.keyPath);
}
}
else {
if (info.hasOwnProperty("autoIncrement")) {
objectStore = db.createObjectStore(info.name, null,
info.autoIncrement);
}
else {
objectStore = db.createObjectStore(info.name);
}
}
is(db.objectStoreNames.length, index + 1, is(db.objectStoreNames.length, index + 1,
"updated objectStoreNames list"); "updated objectStoreNames list");
@ -101,7 +103,8 @@
is(found, true, "objectStoreNames contains name"); is(found, true, "objectStoreNames contains name");
is(objectStore.name, info.name, "Bad name"); is(objectStore.name, info.name, "Bad name");
is(objectStore.keyPath, info.keyPath ? info.keyPath : "", is(objectStore.keyPath, info.options && info.options.keyPath ?
info.options.keyPath : "",
"Bad keyPath"); "Bad keyPath");
if(objectStore.indexNames.length, 0, "Bad indexNames"); if(objectStore.indexNames.length, 0, "Bad indexNames");

Просмотреть файл

@ -42,8 +42,8 @@
event.transaction.oncomplete = continueToNextStep; event.transaction.oncomplete = continueToNextStep;
let objectStore = db.createObjectStore("foo", "ss"); let objectStore = db.createObjectStore("foo", { keyPath: "ss" });
objectStore.createIndex("name", "name", true); objectStore.createIndex("name", "name", { unique: true });
for (let i = 0; i < objectStoreData.length - 1; i++) { for (let i = 0; i < objectStoreData.length - 1; i++) {
objectStore.add(objectStoreData[i]); objectStore.add(objectStoreData[i]);

Просмотреть файл

@ -21,13 +21,13 @@
const START_DATA = "hi"; const START_DATA = "hi";
const END_DATA = "bye"; const END_DATA = "bye";
const objectStoreInfo = [ const objectStoreInfo = [
{ name: "1", keyPath: "", key: 1, { name: "1", options: { keyPath: "" }, key: 1,
entry: { data: START_DATA } }, entry: { data: START_DATA } },
{ name: "2", keyPath: "foo", { name: "2", options: { keyPath: "foo" },
entry: { foo: 1, data: START_DATA } }, entry: { foo: 1, data: START_DATA } },
{ name: "3", keyPath: "", autoIncrement: true, { name: "3", options: { keyPath: "", autoIncrement: true },
entry: { data: START_DATA } }, entry: { data: START_DATA } },
{ name: "4", keyPath: "foo", autoIncrement: true, { name: "4", options: { keyPath: "foo", autoIncrement: true },
entry: { data: START_DATA } }, entry: { data: START_DATA } },
]; ];
@ -49,14 +49,15 @@
event = yield; event = yield;
ok(true, "2"); ok(true, "2");
let objectStore = info.hasOwnProperty("autoIncrement") ? let objectStore = info.hasOwnProperty("options") ?
db.createObjectStore(info.name, info.keyPath, db.createObjectStore(info.name, info.options) :
info.autoIncrement) : db.createObjectStore(info.name);
db.createObjectStore(info.name, info.keyPath);
// Create the indexes on 'data' on the object store. // Create the indexes on 'data' on the object store.
let index = objectStore.createIndex("data_index", "data", false); let index = objectStore.createIndex("data_index", "data",
let uniqueIndex = objectStore.createIndex("unique_data_index", "data", true); { unique: false });
let uniqueIndex = objectStore.createIndex("unique_data_index", "data",
{ unique: true });
// Populate the object store with one entry of data. // Populate the object store with one entry of data.
request = info.hasOwnProperty("key") ? request = info.hasOwnProperty("key") ?

Просмотреть файл

@ -32,7 +32,8 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
let event = yield; let event = yield;
let objectStore = db.createObjectStore("autoIncrement", "", true); let objectStore = db.createObjectStore("autoIncrement",
{ autoIncrement: true });
request = objectStore.openCursor(); request = objectStore.openCursor();
request.onerror = errorHandler; request.onerror = errorHandler;
@ -42,7 +43,9 @@
} }
yield; yield;
objectStore = db.createObjectStore("autoIncrementKeyPath", "foo", true); objectStore = db.createObjectStore("autoIncrementKeyPath",
{ keyPath: "foo",
autoIncrement: true });
request = objectStore.openCursor(); request = objectStore.openCursor();
request.onerror = errorHandler; request.onerror = errorHandler;
@ -52,7 +55,7 @@
} }
yield; yield;
objectStore = db.createObjectStore("keyPath", "foo"); objectStore = db.createObjectStore("keyPath", { keyPath: "foo" });
request = objectStore.openCursor(); request = objectStore.openCursor();
request.onerror = errorHandler; request.onerror = errorHandler;
@ -62,7 +65,7 @@
} }
yield; yield;
objectStore = db.createObjectStore("foo", ""); objectStore = db.createObjectStore("foo");
request = objectStore.openCursor(); request = objectStore.openCursor();
request.onerror = errorHandler; request.onerror = errorHandler;

Просмотреть файл

@ -33,7 +33,8 @@
ok(event.source === db, "correct event.source"); ok(event.source === db, "correct event.source");
var objectStore = db.createObjectStore(objectStoreName, null, true); var objectStore = db.createObjectStore(objectStoreName,
{ autoIncrement: true });
request = objectStore.add({}); request = objectStore.add({});
request.onerror = errorHandler; request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;

Просмотреть файл

@ -30,7 +30,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore("foo", "", true); let objectStore = db.createObjectStore("foo", { autoIncrement: true });
request = objectStore.getAll(); request = objectStore.getAll();
request.onerror = errorHandler; request.onerror = errorHandler;

Просмотреть файл

@ -15,7 +15,8 @@
{ {
const name = window.location.pathname; const name = window.location.pathname;
const description = "My Test Database"; const description = "My Test Database";
const objectStore = { name: "Objects", keyPath: "id", autoIncr: true }; const objectStore = { name: "Objects",
options: { keyPath: "id", autoIncrement: true } };
let request = moz_indexedDB.open(name, description); let request = moz_indexedDB.open(name, description);
request.onerror = errorHandler; request.onerror = errorHandler;
@ -31,8 +32,7 @@
is(db1.objectStoreNames.length, 0, "No objectStores in db1"); is(db1.objectStoreNames.length, 0, "No objectStores in db1");
db1.createObjectStore(objectStore.name, objectStore.keyPath, db1.createObjectStore(objectStore.name, objectStore.options);
objectStore.autoIncr);
continueToNextStep(); continueToNextStep();
yield; yield;
@ -55,9 +55,7 @@
let objectStore1 = db1.transaction(objectStore.name) let objectStore1 = db1.transaction(objectStore.name)
.objectStore(objectStore.name); .objectStore(objectStore.name);
is(objectStore1.name, objectStore.name, "Same name"); is(objectStore1.name, objectStore.name, "Same name");
is(objectStore1.keyPath, objectStore.keyPath, "Same keyPath"); is(objectStore1.keyPath, objectStore.options.keyPath, "Same keyPath");
is(objectStore1.autoIncrement, objectStore.autoIncrement,
"Same value for autoIncrement");
let objectStore2 = db2.transaction(objectStore.name) let objectStore2 = db2.transaction(objectStore.name)
.objectStore(objectStore.name); .objectStore(objectStore.name);
@ -65,8 +63,6 @@
ok(objectStore1 !== objectStore2, "Different objectStores"); ok(objectStore1 !== objectStore2, "Different objectStores");
is(objectStore1.name, objectStore2.name, "Same name"); is(objectStore1.name, objectStore2.name, "Same name");
is(objectStore1.keyPath, objectStore2.keyPath, "Same keyPath"); is(objectStore1.keyPath, objectStore2.keyPath, "Same keyPath");
is(objectStore1.autoIncrement, objectStore2.autoIncrement,
"Same value for autoIncrement");
finishTest(); finishTest();
yield; yield;

Просмотреть файл

@ -27,9 +27,9 @@
]; ];
const indexData = [ const indexData = [
{ name: "name", keyPath: "name", unique: true }, { name: "name", keyPath: "name", options: { unique: true } },
{ name: "height", keyPath: "height", unique: false }, { name: "height", keyPath: "height", options: { unique: false } },
{ name: "weight", keyPath: "weight", unique: false } { name: "weight", keyPath: "weight", options: { unique: false } }
]; ];
const objectStoreDataNameSort = [ const objectStoreDataNameSort = [
@ -70,7 +70,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore(objectStoreName, ""); let objectStore = db.createObjectStore(objectStoreName);
// First, add all our data to the object store. // First, add all our data to the object store.
let addedData = 0; let addedData = 0;
@ -90,7 +90,7 @@
// Now create the indexes. // Now create the indexes.
for (let i in indexData) { for (let i in indexData) {
objectStore.createIndex(indexData[i].name, indexData[i].keyPath, objectStore.createIndex(indexData[i].name, indexData[i].keyPath,
indexData[i].unique); indexData[i].options);
} }
is(objectStore.indexNames.length, indexData.length, "Good index count"); is(objectStore.indexNames.length, indexData.length, "Good index count");

Просмотреть файл

@ -27,9 +27,9 @@
]; ];
const indexData = [ const indexData = [
{ name: "name", keyPath: "name", unique: true }, { name: "name", keyPath: "name", options: { unique: true } },
{ name: "height", keyPath: "height", unique: false }, { name: "height", keyPath: "height", options: { unique: false } },
{ name: "weight", keyPath: "weight", unique: false } { name: "weight", keyPath: "weight", options: { unique: false } }
]; ];
const objectStoreDataNameSort = [ const objectStoreDataNameSort = [
@ -70,7 +70,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore(objectStoreName, ""); let objectStore = db.createObjectStore(objectStoreName, {});
// First, add all our data to the object store. // First, add all our data to the object store.
let addedData = 0; let addedData = 0;
@ -89,7 +89,7 @@
// Now create the indexes. // Now create the indexes.
for (let i in indexData) { for (let i in indexData) {
objectStore.createIndex(indexData[i].name, indexData[i].keyPath, objectStore.createIndex(indexData[i].name, indexData[i].keyPath,
indexData[i].unique); indexData[i].options);
} }
is(objectStore.indexNames.length, indexData.length, "Good index count"); is(objectStore.indexNames.length, indexData.length, "Good index count");

Просмотреть файл

@ -14,15 +14,15 @@
function testSteps() function testSteps()
{ {
const objectStoreData = [ const objectStoreData = [
{ name: "3", keyPath: "id", autoIncrement: true }, { name: "3", options: { keyPath: "id", autoIncrement: true } },
{ name: "1", keyPath: "ss", autoIncrement: false }, { name: "1", options: { keyPath: "ss" } },
{ name: "2", keyPath: "", autoIncrement: false }, { name: "2", options: { } },
{ name: "4", keyPath: "", autoIncrement: true }, { name: "4", options: { autoIncrement: true } },
]; ];
const indexData = [ const indexData = [
{ name: "name", keyPath: "name", unique: true }, { name: "name", keyPath: "name", options: { unique: true } },
{ name: "height", keyPath: "height", unique: false } { name: "height", keyPath: "height", options: { } }
]; ];
const data = [ const data = [
@ -46,13 +46,12 @@
for (let objectStoreIndex in objectStoreData) { for (let objectStoreIndex in objectStoreData) {
const objectStoreInfo = objectStoreData[objectStoreIndex]; const objectStoreInfo = objectStoreData[objectStoreIndex];
let objectStore = db.createObjectStore(objectStoreInfo.name, let objectStore = db.createObjectStore(objectStoreInfo.name,
objectStoreInfo.keyPath, objectStoreInfo.options);
objectStoreInfo.autoIncrement);
for (let indexIndex in indexData) { for (let indexIndex in indexData) {
const indexInfo = indexData[indexIndex]; const indexInfo = indexData[indexIndex];
let index = objectStore.createIndex(indexInfo.name, let index = objectStore.createIndex(indexInfo.name,
indexInfo.keyPath, indexInfo.keyPath,
indexInfo.unique); indexInfo.options);
} }
} }
yield; yield;
@ -74,7 +73,7 @@
for (let dataIndex in data) { for (let dataIndex in data) {
const obj = data[dataIndex]; const obj = data[dataIndex];
let key; let key;
if (!info.keyPath && !info.autoIncrement) { if (!info.options.keyPath && !info.options.autoIncrement) {
key = obj.ss; key = obj.ss;
} }
objectStore.add(obj, key); objectStore.add(obj, key);

Просмотреть файл

@ -38,9 +38,9 @@
]; ];
const indexData = [ const indexData = [
{ name: "name", keyPath: "name", unique: true }, { name: "name", keyPath: "name", options: { unique: true } },
{ name: "height", keyPath: "height", unique: false }, { name: "height", keyPath: "height", options: { } },
{ name: "weight", keyPath: "weight", unique: false } { name: "weight", keyPath: "weight", options: { unique: false } }
]; ];
const objectStoreDataNameSort = [ const objectStoreDataNameSort = [
@ -81,7 +81,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore(objectStoreName, ""); let objectStore = db.createObjectStore(objectStoreName, { keyPath: "" });
// First, add all our data to the object store. // First, add all our data to the object store.
let addedData = 0; let addedData = 0;
@ -100,7 +100,7 @@
// Now create the indexes. // Now create the indexes.
for (let i in indexData) { for (let i in indexData) {
objectStore.createIndex(indexData[i].name, indexData[i].keyPath, objectStore.createIndex(indexData[i].name, indexData[i].keyPath,
indexData[i].unique); indexData[i].options);
} }
is(objectStore.indexNames.length, indexData.length, "Good index count"); is(objectStore.indexNames.length, indexData.length, "Good index count");
continueToNextStep(); continueToNextStep();
@ -124,7 +124,8 @@
is(index.name, indexData[i].name, "Correct name"); is(index.name, indexData[i].name, "Correct name");
is(index.storeName, objectStore.name, "Correct store name"); is(index.storeName, objectStore.name, "Correct store name");
is(index.keyPath, indexData[i].keyPath, "Correct keyPath"); is(index.keyPath, indexData[i].keyPath, "Correct keyPath");
is(index.unique, indexData[i].unique, "Correct keyPath"); is(index.unique, indexData[i].options.unique ? true : false,
"Correct unique value");
} }
request = objectStore.index("name").getKey("Bob"); request = objectStore.index("name").getKey("Bob");

Просмотреть файл

@ -38,7 +38,7 @@
]; ];
const indexData = [ const indexData = [
{ name: "weight", keyPath: "weight", unique: false } { name: "weight", keyPath: "weight", options: { unique: false } }
]; ];
const objectStoreDataWeightSort = [ const objectStoreDataWeightSort = [
@ -61,7 +61,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore(objectStoreName, ""); let objectStore = db.createObjectStore(objectStoreName, { } );
let addedData = 0; let addedData = 0;
for (let i in objectStoreData) { for (let i in objectStoreData) {
@ -78,7 +78,7 @@
for (let i in indexData) { for (let i in indexData) {
objectStore.createIndex(indexData[i].name, indexData[i].keyPath, objectStore.createIndex(indexData[i].name, indexData[i].keyPath,
indexData[i].unique); indexData[i].options);
} }
addedData = 0; addedData = 0;

Просмотреть файл

@ -31,7 +31,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
let event = yield; let event = yield;
let objectStore = db.createObjectStore("foo", "", true); let objectStore = db.createObjectStore("foo", { autoIncrement: true });
request = objectStore.add({}); request = objectStore.add({});
request.onerror = errorHandler; request.onerror = errorHandler;
@ -89,7 +89,7 @@
ok(true, "remove with no key threw"); ok(true, "remove with no key threw");
} }
objectStore = db.createObjectStore("bar", "", false); objectStore = db.createObjectStore("bar");
try { try {
objectStore.add({}); objectStore.add({});
@ -123,7 +123,7 @@
ok(true, "remove with no key threw"); ok(true, "remove with no key threw");
} }
objectStore = db.createObjectStore("baz", "id", false); objectStore = db.createObjectStore("baz", { keyPath: "id" });
try { try {
objectStore.add({}); objectStore.add({});
@ -225,7 +225,8 @@
ok(true, "remove with null key threw"); ok(true, "remove with null key threw");
} }
objectStore = db.createObjectStore("bazing", "id", true); objectStore = db.createObjectStore("bazing", { keyPath: "id",
autoIncrement: true });
request = objectStore.add({}); request = objectStore.add({});
request.onerror = errorHandler; request.onerror = errorHandler;

Просмотреть файл

@ -22,8 +22,8 @@
]; ];
const indexes = [ const indexes = [
{ name: "a", unique: false }, { name: "a", options: { } },
{ name: "b", unique: true } { name: "b", options: { unique: true } }
]; ];
let request = moz_indexedDB.open(name, description); let request = moz_indexedDB.open(name, description);
@ -40,11 +40,12 @@
let event = yield; let event = yield;
let objectStore = let objectStore =
db.createObjectStore(objectStores[i].name, "id", db.createObjectStore(objectStores[i].name,
objectStores[i].autoIncrement); { keyPath: "id",
autoIncrement: objectStores[i].autoIncrement });
for (let j in indexes) { for (let j in indexes) {
objectStore.createIndex(indexes[j].name, "name", indexes[j].unique); objectStore.createIndex(indexes[j].name, "name", indexes[j].options);
} }
let data = { name: "Ben" }; let data = { name: "Ben" };

Просмотреть файл

@ -38,8 +38,9 @@ function testSteps()
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore(test.name, test.keyName, let objectStore = db.createObjectStore(test.name,
test.autoIncrement); { keyPath: test.keyName,
autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject); request = objectStore.add(test.storedObject);
request.onerror = errorHandler; request.onerror = errorHandler;

Просмотреть файл

@ -42,13 +42,13 @@ function testSteps()
{ name: "out of line key; key generator", { name: "out of line key; key generator",
autoIncrement: true, autoIncrement: true,
storedObject: {name: "Lincoln"}, storedObject: {name: "Lincoln"},
keyName: null, keyName: undefined,
keyValue: undefined, keyValue: undefined,
}, },
{ name: "out of line key; no key generator", { name: "out of line key; no key generator",
autoIncrement: false, autoIncrement: false,
storedObject: {name: "Lincoln"}, storedObject: {name: "Lincoln"},
keyName: null, keyName: "",
keyValue: 1, keyValue: 1,
} }
]; ];
@ -62,8 +62,9 @@ function testSteps()
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore(test.name, test.keyName, let objectStore = db.createObjectStore(test.name,
test.autoIncrement); { keyPath: test.keyName,
autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject, test.keyValue); request = objectStore.add(test.storedObject, test.keyValue);
request.onerror = errorHandler; request.onerror = errorHandler;

Просмотреть файл

@ -27,7 +27,7 @@
let transaction = event.transaction; let transaction = event.transaction;
let objectStore1 = db.createObjectStore("foo", ""); let objectStore1 = db.createObjectStore("foo");
let objectStore2 = transaction.objectStore("foo"); let objectStore2 = transaction.objectStore("foo");
ok(objectStore1 === objectStore2, "Got same objectStores"); ok(objectStore1 === objectStore2, "Got same objectStores");

Просмотреть файл

@ -33,7 +33,8 @@
is(db.objectStoreNames.length, 0, "Bad objectStores list"); is(db.objectStoreNames.length, 0, "Bad objectStores list");
let objectStore = db.createObjectStore(objectStoreName, "foo"); let objectStore = db.createObjectStore(objectStoreName,
{ keyPath: "foo" });
is(db.objectStoreNames.length, 1, "Bad objectStores list"); is(db.objectStoreNames.length, 1, "Bad objectStores list");
is(db.objectStoreNames.item(0), objectStoreName, "Bad name"); is(db.objectStoreNames.item(0), objectStoreName, "Bad name");

Просмотреть файл

@ -32,7 +32,7 @@
request.onsuccess = function(event) { request.onsuccess = function(event) {
event.transaction.oncomplete = grabEventAndContinueHandler; event.transaction.oncomplete = grabEventAndContinueHandler;
for (let i in objectStores) { for (let i in objectStores) {
db.createObjectStore(objectStores[i], "", true); db.createObjectStore(objectStores[i], { autoIncrement: true });
} }
}; };
yield; yield;

Просмотреть файл

@ -32,7 +32,8 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore(objectStoreName, "", false); let objectStore = db.createObjectStore(objectStoreName,
{ autoIncrement: 0 });
request = objectStore.add(testString.value, testString.key); request = objectStore.add(testString.value, testString.key);
request.onerror = errorHandler; request.onerror = errorHandler;

Просмотреть файл

@ -32,7 +32,8 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore(objectStoreName, "", true); let objectStore = db.createObjectStore(objectStoreName,
{ autoIncrement: 1 });
request = objectStore.add(testString.value); request = objectStore.add(testString.value);
request.onerror = errorHandler; request.onerror = errorHandler;

Просмотреть файл

@ -33,7 +33,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
db.createObjectStore(osName, "", true); db.createObjectStore(osName, { autoIncrement: "true" });
let key1, key2; let key1, key2;

Просмотреть файл

@ -32,7 +32,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore("test store", "foo"); let objectStore = db.createObjectStore("test store", { keyPath: "foo" });
is(db.objectStoreNames.length, 1, "Correct objectStoreNames list"); is(db.objectStoreNames.length, 1, "Correct objectStoreNames list");
is(db.objectStoreNames.item(0), objectStore.name, "Correct name"); is(db.objectStoreNames.item(0), objectStore.name, "Correct name");

Просмотреть файл

@ -34,7 +34,8 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore(objectStoreName, "foo"); let objectStore = db.createObjectStore(objectStoreName,
{ keyPath: "foo" });
let addedCount = 0; let addedCount = 0;
@ -60,7 +61,7 @@
db.deleteObjectStore(objectStore.name); db.deleteObjectStore(objectStore.name);
is(db.objectStoreNames.length, 0, "Correct objectStores list"); is(db.objectStoreNames.length, 0, "Correct objectStores list");
objectStore = db.createObjectStore(objectStoreName, "foo"); objectStore = db.createObjectStore(objectStoreName, { keyPath: "foo" });
is(db.objectStoreNames.length, 1, "Correct objectStoreNames list"); is(db.objectStoreNames.length, 1, "Correct objectStoreNames list");
is(db.objectStoreNames.item(0), objectStoreName, "Correct name"); is(db.objectStoreNames.item(0), objectStoreName, "Correct name");
@ -83,7 +84,7 @@
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
objectStore = db.createObjectStore(objectStoreName, "foo"); objectStore = db.createObjectStore(objectStoreName, { keyPath: "foo" });
request = objectStore.add({foo:"bar"}); request = objectStore.add({foo:"bar"});
request.onerror = errorHandler; request.onerror = errorHandler;

Просмотреть файл

@ -39,7 +39,7 @@
is(request.readyState, DONE, "Correct readyState"); is(request.readyState, DONE, "Correct readyState");
let objectStore = db.createObjectStore("foo", ""); let objectStore = db.createObjectStore("foo");
let key = 10; let key = 10;
request = objectStore.add({}, key); request = objectStore.add({}, key);

Просмотреть файл

@ -32,7 +32,7 @@ function testSteps()
request.onsuccess = grabEventAndContinueHandler; request.onsuccess = grabEventAndContinueHandler;
event = yield; event = yield;
let objectStore = db.createObjectStore("foo", ""); let objectStore = db.createObjectStore("foo");
let index = objectStore.createIndex("bar", "baz"); let index = objectStore.createIndex("bar", "baz");
is(db.version, "1", "Correct version"); is(db.version, "1", "Correct version");

Просмотреть файл

@ -41,7 +41,7 @@
event = yield; event = yield;
transaction = event.transaction; transaction = event.transaction;
objectStore = db.createObjectStore("foo", "", true); objectStore = db.createObjectStore("foo", { autoIncrement: true });
is(transaction.db, db, "Correct database"); is(transaction.db, db, "Correct database");
is(transaction.readyState, LOADING, "Correct readyState"); is(transaction.readyState, LOADING, "Correct readyState");

Просмотреть файл

@ -26,7 +26,7 @@
event.transaction.oncomplete = continueToNextStep; event.transaction.oncomplete = continueToNextStep;
db.createObjectStore("foo", "", true); db.createObjectStore("foo", { autoIncrement: true });
yield; yield;
let transaction = db.transaction("foo"); let transaction = db.transaction("foo");

Просмотреть файл

@ -25,7 +25,7 @@
event = yield; event = yield;
event.transaction.oncomplete = continueToNextStep; event.transaction.oncomplete = continueToNextStep;
db.createObjectStore("foo", ""); db.createObjectStore("foo");
yield; yield;
let transaction1 = db.transaction("foo"); let transaction1 = db.transaction("foo");

Просмотреть файл

@ -35,7 +35,7 @@
is(event.transaction.mode, VERSION_CHANGE, "Correct mode"); is(event.transaction.mode, VERSION_CHANGE, "Correct mode");
let objectStore = db.createObjectStore("foo", "", true); let objectStore = db.createObjectStore("foo", { autoIncrement: true });
request = objectStore.add({}); request = objectStore.add({});
request.onerror = errorHandler; request.onerror = errorHandler;