blob: f79ac849405b837361fb0da3069db5e54bcf40c0 [file] [log] [blame]
Test IndexedDB's cursor mutation during object store cursor iteration
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: 'ss' });
objectStoreData = [
{ ss: '237-23-7732', name: 'Bob' },
{ ss: '237-23-7733', name: 'Ann' },
{ ss: '237-23-7734', name: 'Ron' },
{ ss: '237-23-7735', name: 'Sue' },
{ ss: '237-23-7736', name: 'Joe' },
{ ss: '237-23-7737', name: 'Pat' }
];
objectStore.add(objectStoreData[i]);
objectStore.add(objectStoreData[i]);
objectStore.add(objectStoreData[i]);
objectStore.add(objectStoreData[i]);
objectStore.add(objectStoreData[i]);
count = 0;
sawAdded = false;
sawRemoved = false;
request = objectStore.openCursor();
iterateCursor():
event.target.transaction.oncomplete = checkCursorResultsAndSetupMutatingCursor;
cursor = event.target.result;
sawRemoved = true;
count++;
cursor.continue();
iterateCursor():
event.target.transaction.oncomplete = checkCursorResultsAndSetupMutatingCursor;
cursor = event.target.result;
count++;
cursor.continue();
iterateCursor():
event.target.transaction.oncomplete = checkCursorResultsAndSetupMutatingCursor;
cursor = event.target.result;
count++;
cursor.continue();
iterateCursor():
event.target.transaction.oncomplete = checkCursorResultsAndSetupMutatingCursor;
cursor = event.target.result;
count++;
cursor.continue();
iterateCursor():
event.target.transaction.oncomplete = checkCursorResultsAndSetupMutatingCursor;
cursor = event.target.result;
count++;
cursor.continue();
iterateCursor():
event.target.transaction.oncomplete = checkCursorResultsAndSetupMutatingCursor;
cursor = event.target.result;
checkCursorResultsAndSetupMutatingCursor():
PASS count is objectStoreData.length - 1
PASS sawAdded is false
PASS sawRemoved is true
count = 0;
sawAdded = false;
sawRemoved = false;
request = db.transaction('foo', 'readwrite').objectStore('foo').openCursor();
iterateMutatingCursor():
event.target.transaction.oncomplete = checkMutatingCursorResults;
cursor = event.target.result;
sawRemoved = true;
PASS cursor.value.name is 'Bob'
count++
objectStore = event.target.transaction.objectStore('foo');
request = objectStore.delete(objectStoreData[0].ss);
addFinalData():
request = objectStore.add(objectStoreData[objectStoreData.length - 1]);
iterateMutatingCursor():
event.target.transaction.oncomplete = checkMutatingCursorResults;
cursor = event.target.result;
PASS cursor.value.name is 'Ann'
count++
iterateMutatingCursor():
event.target.transaction.oncomplete = checkMutatingCursorResults;
cursor = event.target.result;
PASS cursor.value.name is 'Ron'
count++
iterateMutatingCursor():
event.target.transaction.oncomplete = checkMutatingCursorResults;
cursor = event.target.result;
PASS cursor.value.name is 'Sue'
count++
iterateMutatingCursor():
event.target.transaction.oncomplete = checkMutatingCursorResults;
cursor = event.target.result;
PASS cursor.value.name is 'Joe'
count++
iterateMutatingCursor():
event.target.transaction.oncomplete = checkMutatingCursorResults;
cursor = event.target.result;
sawAdded = true;
PASS cursor.value.name is 'Pat'
count++
iterateMutatingCursor():
event.target.transaction.oncomplete = checkMutatingCursorResults;
cursor = event.target.result;
checkMutatingCursorResults():
PASS count is objectStoreData.length
PASS sawAdded is true
PASS sawRemoved is true
PASS successfullyParsed is true
TEST COMPLETE