summaryrefslogtreecommitdiffstats
path: root/chrome/test/data
diff options
context:
space:
mode:
authorhans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-28 09:09:25 +0000
committerhans@chromium.org <hans@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-28 09:09:25 +0000
commit0d4f264b1545c54bc0e70a4bea6377caf7ad27d3 (patch)
tree9302e10d093d5cfa7705b1907e483355eb75dc31 /chrome/test/data
parent75f6b73b0cb8087d58110a9c1960dd01908edba0 (diff)
downloadchromium_src-0d4f264b1545c54bc0e70a4bea6377caf7ad27d3.zip
chromium_src-0d4f264b1545c54bc0e70a4bea6377caf7ad27d3.tar.gz
chromium_src-0d4f264b1545c54bc0e70a4bea6377caf7ad27d3.tar.bz2
IndexedDB: Expand browser test to cover the object store.
BUG=60581 TEST=browser_tests --gtest_filter="IndexedDBBrowserTest.*" Review URL: http://codereview.chromium.org/4147005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@64216 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/data')
-rw-r--r--chrome/test/data/indexeddb/cursor_test.js11
-rw-r--r--chrome/test/data/indexeddb/object_store_test.html10
-rw-r--r--chrome/test/data/indexeddb/object_store_test.js82
3 files changed, 101 insertions, 2 deletions
diff --git a/chrome/test/data/indexeddb/cursor_test.js b/chrome/test/data/indexeddb/cursor_test.js
index 21aa4e8..a00da15 100644
--- a/chrome/test/data/indexeddb/cursor_test.js
+++ b/chrome/test/data/indexeddb/cursor_test.js
@@ -1,7 +1,6 @@
function emptyCursorSuccess()
{
debug('Empty cursor opened successfully.')
- // TODO(bulach): check that we can iterate the cursor.
done();
}
@@ -16,11 +15,19 @@ function openEmptyCursor()
function cursorSuccess()
{
+ var cursor = event.result;
+ if (cursor === null) {
+ debug('Cursor reached end of range.');
+ openEmptyCursor();
+ return;
+ }
+
debug('Cursor opened successfully.');
shouldBe("event.result.direction", "0");
shouldBe("event.result.key", "'myKey'");
shouldBe("event.result.value", "'myValue'");
- openEmptyCursor();
+
+ cursor.continue();
}
function openCursor(objectStore)
diff --git a/chrome/test/data/indexeddb/object_store_test.html b/chrome/test/data/indexeddb/object_store_test.html
new file mode 100644
index 0000000..0c7618c
--- /dev/null
+++ b/chrome/test/data/indexeddb/object_store_test.html
@@ -0,0 +1,10 @@
+<html>
+ <head>
+ <title>IndexedDB object store test</title>
+ <script type="text/javascript" src="common.js"></script>
+ <script type="text/javascript" src="object_store_test.js"></script>
+ </head>
+ <body onLoad="test()">
+ <div id="status">Starting...</div>
+ </body>
+</html>
diff --git a/chrome/test/data/indexeddb/object_store_test.js b/chrome/test/data/indexeddb/object_store_test.js
new file mode 100644
index 0000000..064f8bd
--- /dev/null
+++ b/chrome/test/data/indexeddb/object_store_test.js
@@ -0,0 +1,82 @@
+function recordNotFound()
+{
+ debug('Removed data can no longer be found');
+
+ debug('Retrieving an index');
+ shouldBe("objectStore.index('fname_index').name", "'fname_index'");
+
+ debug('Removing an index');
+ try {
+ objectStore.removeIndex('fname_index');
+ } catch(e) {
+ fail(e);
+ }
+ done();
+}
+
+function removeSuccess()
+{
+ debug('Data removed');
+
+ var result = objectStore.get(1);
+ result.onsuccess = unexpectedSuccessCallback;
+ result.onerror = recordNotFound;
+}
+
+function getSuccess()
+{
+ debug('Data retrieved');
+
+ shouldBe("event.result.fname", "'John'");
+ shouldBe("event.result.lname", "'Doe'");
+ shouldBe("event.result.id", "1");
+
+ var result = objectStore.remove(1);
+ result.onsuccess = removeSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function dataAddedSuccess()
+{
+ debug('Data added');
+
+ var result = objectStore.get(1);
+ result.onsuccess = getSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function populateObjectStore()
+{
+ debug('Populating object store');
+ deleteAllObjectStores(db);
+ window.objectStore = db.createObjectStore('employees', 'id');
+ shouldBe("objectStore.name", "'employees'");
+ shouldBe("objectStore.keyPath", "'id'");
+
+ objectStore.createIndex('fname_index', 'fname');
+ objectStore.createIndex('lname_index', 'fname');
+ debug('Created indexes');
+ shouldBe("objectStore.indexNames[0]", "'fname_index'");
+ shouldBe("objectStore.indexNames[1]", "'lname_index'");
+
+ var result = objectStore.add({fname: "John", lname: "Doe", id: 1});
+ result.onsuccess = dataAddedSuccess;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function setVersion()
+{
+ debug('setVersion');
+ window.db = event.result;
+ var result = db.setVersion('1.0');
+ result.onsuccess = populateObjectStore;
+ result.onerror = unexpectedErrorCallback;
+}
+
+function test()
+{
+ debug('Connecting to indexedDB');
+ var result = webkitIndexedDB.open('name', 'description');
+ result.onsuccess = setVersion;
+ result.onerror = unexpectedErrorCallback;
+}