diff options
Diffstat (limited to 'LayoutTests/storage/indexeddb/open-cursor.html')
-rw-r--r-- | LayoutTests/storage/indexeddb/open-cursor.html | 88 |
1 files changed, 87 insertions, 1 deletions
diff --git a/LayoutTests/storage/indexeddb/open-cursor.html b/LayoutTests/storage/indexeddb/open-cursor.html index f60365d..03d1da0 100644 --- a/LayoutTests/storage/indexeddb/open-cursor.html +++ b/LayoutTests/storage/indexeddb/open-cursor.html @@ -8,6 +8,92 @@ <body> <p id="description"></p> <div id="console"></div> -<script src="script-tests/open-cursor.js"></script> +<script> + +description("Test IndexedDB's openCursor."); +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +function emptyCursorSuccess() +{ + debug("Empty cursor opened successfully.") + verifySuccessEvent(event); + // FIXME: check that we can iterate the cursor. + done(); +} + +function openEmptyCursor() +{ + debug("Opening an empty cursor."); + keyRange = IDBKeyRange.leftBound("InexistentKey"); + result = evalAndLog("objectStore.openCursor(keyRange)"); + verifyResult(result); + result.onsuccess = emptyCursorSuccess; + result.onerror = unexpectedErrorCallback; +} + +function cursorSuccess() +{ + debug("Cursor opened successfully.") + verifySuccessEvent(event); + // FIXME: check that we can iterate the cursor. + shouldBe("event.result.direction", "0"); + shouldBe("event.result.key", "'myKey'"); + shouldBe("event.result.value", "'myValue'"); + debug(""); + openEmptyCursor(); +} + +function openCursor() +{ + debug("Opening cursor"); + keyRange = IDBKeyRange.leftBound("myKey"); + result = evalAndLog("objectStore.openCursor(keyRange)"); + verifyResult(result); + result.onsuccess = cursorSuccess; + result.onerror = unexpectedErrorCallback; +} + +function populateObjectStore(objectStore) +{ + result = evalAndLog("objectStore.add('myValue', 'myKey')"); + verifyResult(result); + result.onsuccess = openCursor; + result.onerror = unexpectedErrorCallback; +} + +function createObjectStoreSuccess() +{ + verifySuccessEvent(event); + var objectStore = evalAndLog("objectStore = event.result"); + populateObjectStore(objectStore); +} + +function openSuccess() +{ + verifySuccessEvent(event); + var db = evalAndLog("db = event.result"); + + deleteAllObjectStores(db); + + result = evalAndLog("db.createObjectStore('test')"); + verifyResult(result); + result.onsuccess = createObjectStoreSuccess; + result.onerror = unexpectedErrorCallback; +} + +function test() +{ + result = evalAndLog("indexedDB.open('name', 'description')"); + verifyResult(result); + result.onsuccess = openSuccess; + result.onerror = unexpectedErrorCallback; +} + +test(); + +var successfullyParsed = true; + +</script> </body> </html> |