blob: bbe5e86770911f5d6a993147ddee2e238a862ebd [file] [log] [blame]
Test IndexedDB: request result persists in setTimeout callback
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
objectStore = db.createObjectStore('foo', { keyPath: 'key', autoIncrement: true });
index = objectStore.createIndex('foo', 'index');
openSuccess():
db = null;
db = request.result;
checkDatabaseType():
PASS db instanceof IDBDatabase is true
addRecord():
objectStore = db.transaction('foo', 'readwrite').objectStore('foo');
data = { key: 5, index: 10 };
request = objectStore.add(data);
addSuccess():
key = null;
key = request.result;
checkAddedKey():
PASS key is data.key
objectStore = db.transaction('foo').objectStore('foo');
request = objectStore.get(data.key);
getSuccess():
record = null;
record = request.result;
checkRetrievedKey():
PASS record.key is data.key
PASS record.index is data.index
deleteRecord():
objectStore = db.transaction('foo', 'readwrite').objectStore('foo');
request = objectStore.delete(data.key);
deleteSuccess():
PASS successfullyParsed is true
TEST COMPLETE