summaryrefslogtreecommitdiffstats
path: root/LayoutTests/storage/indexeddb/queued-commands.html
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/storage/indexeddb/queued-commands.html')
-rw-r--r--LayoutTests/storage/indexeddb/queued-commands.html87
1 files changed, 87 insertions, 0 deletions
diff --git a/LayoutTests/storage/indexeddb/queued-commands.html b/LayoutTests/storage/indexeddb/queued-commands.html
new file mode 100644
index 0000000..7dc94c3
--- /dev/null
+++ b/LayoutTests/storage/indexeddb/queued-commands.html
@@ -0,0 +1,87 @@
+<html>
+<head>
+<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
+<script src="../../fast/js/resources/js-test-pre.js"></script>
+<script src="../../fast/js/resources/js-test-post-function.js"></script>
+<script src="resources/shared.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script>
+
+description("Verify that queuing up several commands works (and they all fire).");
+if (window.layoutTestController)
+ layoutTestController.waitUntilDone();
+
+function test()
+{
+ result = evalAndLog("webkitIndexedDB.open('name', 'description')");
+ verifyResult(result);
+ result.onsuccess = setVersion;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function setVersion()
+{
+ verifySuccessEvent(event);
+ db = evalAndLog("db = event.result");
+
+ result = evalAndLog("db.setVersion('new version')");
+ verifyResult(result);
+ result.onsuccess = deleteExisting;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function deleteExisting()
+{
+ debug("setVersionSuccess():");
+ verifySuccessEvent(event);
+ window.trans = evalAndLog("trans = event.result");
+ shouldBeTrue("trans !== null");
+ trans.onabort = unexpectedAbortCallback;
+
+ deleteAllObjectStores(db, createIndex);
+}
+
+function createIndex()
+{
+ window.store = evalAndLog("db.createObjectStore('storeName', null)");
+ window.indexObject = evalAndLog("store.createIndex('indexName', 'x')");
+
+ result = evalAndLog("store.add({x: 'value', y: 'zzz'}, 'key')");
+ verifyResult(result);
+ result.onsuccess = function() { verifyAdd(0); };
+ result.onerror = unexpectedErrorCallback;
+
+ result = evalAndLog("store.add({x: 'value2', y: 'zzz2'}, 'key2')");
+ verifyResult(result);
+ result.onsuccess = function() { verifyAdd(1); };
+ result.onerror = unexpectedErrorCallback;
+
+ result = evalAndLog("store.put({x: 'valu2', y: 'zz2'}, 'ky2')");
+ verifyResult(result);
+ result.onsuccess = function() { verifyAdd(2); };
+ result.onerror = unexpectedErrorCallback;
+
+ window.addCount = 0;
+}
+
+function verifyAdd(expected)
+{
+ verifySuccessEvent(event);
+ shouldBe("" + addCount++, "" + expected);
+
+ if (addCount == 3)
+ done();
+ if (addCount > 3)
+ testFailed("Unexpected call to verifyAdd!");
+}
+
+test();
+
+var successfullyParsed = true;
+
+</script>
+</body>
+</html>