summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorandreip@chromium.org <andreip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-24 11:23:45 +0000
committerandreip@chromium.org <andreip@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-24 11:23:45 +0000
commitf13db4e57df5848e921a9a06c9484df7e9aed072 (patch)
treeff0c6776f592d3cbb9e3a2b157e11370056992fb /chrome/test
parent81fa4fc0d2cd35b09d3e14b1315488282aacb2c4 (diff)
downloadchromium_src-f13db4e57df5848e921a9a06c9484df7e9aed072.zip
chromium_src-f13db4e57df5848e921a9a06c9484df7e9aed072.tar.gz
chromium_src-f13db4e57df5848e921a9a06c9484df7e9aed072.tar.bz2
Adds IDBFactory::didCompleteEventsForTransaction plumbing
(depends on https://bugs.webkit.org/show_bug.cgi?id=44700) TEST=IndexedDBBrowserTest.TransactionGetTest This takes over http://codereview.chromium.org/3310022/show Review URL: http://codereview.chromium.org/3394007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@60457 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/data/indexeddb/common.js17
-rw-r--r--chrome/test/data/indexeddb/transaction_get_test.html10
-rw-r--r--chrome/test/data/indexeddb/transaction_get_test.js70
3 files changed, 97 insertions, 0 deletions
diff --git a/chrome/test/data/indexeddb/common.js b/chrome/test/data/indexeddb/common.js
index b773fe3..9ebd361 100644
--- a/chrome/test/data/indexeddb/common.js
+++ b/chrome/test/data/indexeddb/common.js
@@ -22,11 +22,23 @@ function getLog()
return "" + document.getElementById('status').innerHTML;
}
+function unexpectedSuccessCallback()
+{
+ fail('unexpectedSuccessCallback');
+}
+
function unexpectedErrorCallback()
{
fail('unexpectedErrorCallback');
}
+function deleteAllObjectStores(db)
+{
+ objectStores = db.objectStores;
+ for (var i = 0; i < objectStores.length; ++i)
+ db.removeObjectStore(objectStores[i]);
+}
+
// The following functions are based on
// WebKit/LayoutTests/fast/js/resources/js-test-pre.js
// so that the tests will look similar to the existing layout tests.
@@ -79,3 +91,8 @@ function shouldBeTrue(_a) { shouldBe(_a, "true"); }
function shouldBeFalse(_a) { shouldBe(_a, "false"); }
function shouldBeNaN(_a) { shouldBe(_a, "NaN"); }
function shouldBeNull(_a) { shouldBe(_a, "null"); }
+function shouldBeEqualToString(a, b)
+{
+ var unevaledString = '"' + b.replace(/\\/g, "\\\\").replace(/"/g, "\"") + '"';
+ shouldBe(a, unevaledString);
+}
diff --git a/chrome/test/data/indexeddb/transaction_get_test.html b/chrome/test/data/indexeddb/transaction_get_test.html
new file mode 100644
index 0000000..edc1e0f
--- /dev/null
+++ b/chrome/test/data/indexeddb/transaction_get_test.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <title>IndexedDB transaction get test</title>
+ <script type="text/javascript" src="common.js"></script>
+ <script type="text/javascript" src="transaction_get_test.js"></script>
+ </head>
+ <body onLoad="test()">
+ <div id="status">Starting...</div>
+ </body>
+</html>
diff --git a/chrome/test/data/indexeddb/transaction_get_test.js b/chrome/test/data/indexeddb/transaction_get_test.js
new file mode 100644
index 0000000..e9c992a
--- /dev/null
+++ b/chrome/test/data/indexeddb/transaction_get_test.js
@@ -0,0 +1,70 @@
+function afterCommit()
+{
+ try {
+ debug("Accessing a committed transaction should throw");
+ var store = transaction.objectStore('storeName');
+ } catch (e) {
+ exc = e;
+ shouldBe('exc.code', '9');
+ }
+ done();
+}
+
+function nonExistingKey()
+{
+ window.setTimeout('afterCommit()', 0);
+}
+
+function gotValue()
+{
+ value = event.result;
+ shouldBeEqualToString('value', 'myValue');
+}
+
+function startTransaction()
+{
+ debug("Using get in a transaction");
+ transaction = db.transaction();
+ //transaction.onabort = unexpectedErrorCallback;
+ store = transaction.objectStore('storeName');
+ shouldBeEqualToString("store.name", "storeName");
+ result = store.get('myKey');
+ result.onsuccess = gotValue;
+ result.onerror = unexpectedErrorCallback;
+
+ var emptyResult = store.get('nonExistingKey');
+ emptyResult.onsuccess = unexpectedSuccessCallback;
+ emptyResult.onerror = nonExistingKey;
+}
+
+function populateObjectStore(objectStore)
+{
+ result = objectStore.add('myValue', 'myKey');
+ result.onsuccess = startTransaction;
+}
+
+function createObjectStoreSuccess()
+{
+ var objectStore = event.result;
+ populateObjectStore(objectStore);
+}
+
+function openSuccess()
+{
+ db = event.result;
+
+ deleteAllObjectStores(db);
+
+ result = db.createObjectStore('storeName');
+ result.onsuccess = createObjectStoreSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function test()
+{
+ result = indexedDB.open('name', 'description');
+ result.onsuccess = openSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+test();