blob: 627beb33dd2fe1aeb12727bf0239e57ce2dda998 [file] [log] [blame]
Test IndexedDB: adds, gets, deletes, and re-gets a record in a variety of different object store configurations
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
data = [
{ name: 'inline key; key generator',
autoIncrement: true,
storedObject: {name: 'Lincoln'},
keyName: 'id',
keyValue: undefined,
},
{ name: 'inline key; no key generator',
autoIncrement: false,
storedObject: {id: 1, name: 'Lincoln'},
keyName: 'id',
keyValue: undefined,
},
{ name: 'out of line key; key generator',
autoIncrement: true,
storedObject: {name: 'Lincoln'},
keyName: undefined,
keyValue: undefined,
},
{ name: 'out of line key; no key generator',
autoIncrement: false,
storedObject: {name: 'Lincoln'},
keyName: undefined,
keyValue: 1,
}
];
i = 0;
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
objectStore = db.createObjectStore(test.name, { keyPath: test.keyName, autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject);
id = event.target.result;
request = objectStore.get(id);
PASS test.storedObject.name is event.target.result.name
request = objectStore.delete(id);
request = objectStore.get(id);
PASS event.target.result === undefined is true
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
objectStore = db.createObjectStore(test.name, { keyPath: test.keyName, autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject);
id = event.target.result;
request = objectStore.get(id);
PASS test.storedObject.name is event.target.result.name
request = objectStore.delete(id);
request = objectStore.get(id);
PASS event.target.result === undefined is true
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
objectStore = db.createObjectStore(test.name, { autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject);
id = event.target.result;
request = objectStore.get(id);
PASS test.storedObject.name is event.target.result.name
request = objectStore.delete(id);
request = objectStore.get(id);
PASS event.target.result === undefined is true
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
objectStore = db.createObjectStore(test.name, { autoIncrement: test.autoIncrement });
request = objectStore.add(test.storedObject, test.keyValue);
id = event.target.result;
request = objectStore.get(id);
PASS test.storedObject.name is event.target.result.name
request = objectStore.delete(id);
request = objectStore.get(id);
PASS event.target.result === undefined is true
PASS successfullyParsed is true
TEST COMPLETE