IndexedDB test conversions batch 5
authordgrogan@chromium.org <dgrogan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2012 20:54:44 +0000 (20:54 +0000)
committerdgrogan@chromium.org <dgrogan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 15 Nov 2012 20:54:44 +0000 (20:54 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102308

Reviewed by Tony Chang.

* storage/indexeddb/mozilla/cursor-update-updates-indexes-expected.txt:
* storage/indexeddb/mozilla/event-source-expected.txt:
* storage/indexeddb/mozilla/global-data-expected.txt:
* storage/indexeddb/mozilla/key-requirements-put-null-key-expected.txt:
* storage/indexeddb/mozilla/odd-result-order-expected.txt:
* storage/indexeddb/mozilla/remove-objectstore-expected.txt:
* storage/indexeddb/mozilla/resources/cursor-update-updates-indexes.js:
  Calls indexedDBTest a bunch of times, which seems awkward, but is
  really convenient.

* storage/indexeddb/mozilla/resources/event-source.js:
  Now that setVersion is gone, it appears that no request should have
  a database as a source so the dropped test is ok.

* storage/indexeddb/mozilla/resources/global-data.js:
(prepareDatabase):
(open2Success):
* storage/indexeddb/mozilla/resources/key-requirements-put-null-key.js:
(prepareDatabase):
* storage/indexeddb/mozilla/resources/odd-result-order.js:
  The tests had to be run in slightly different order but they are all
  preserved.

(prepareDatabase):
(openSuccess):
(deleteSuccess):
* storage/indexeddb/mozilla/resources/remove-objectstore.js:
(prepareDatabase):
(checkObjectStore):
(inSetVersion2.request.onsuccess):
(inSetVersion2):
(setVersion3):
(inSetVersion3):
(deleteThirdObjectStore):
* storage/indexeddb/objectstore-removeobjectstore-expected.txt:
* storage/indexeddb/resources/objectstore-removeobjectstore.js:
(getValue):
(checkResult):
(addIndex):
(deleteObjectStore):
(createObjectStoreAgain):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@134819 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/mozilla/cursor-update-updates-indexes-expected.txt
LayoutTests/storage/indexeddb/mozilla/event-source-expected.txt
LayoutTests/storage/indexeddb/mozilla/global-data-expected.txt
LayoutTests/storage/indexeddb/mozilla/key-requirements-put-null-key-expected.txt
LayoutTests/storage/indexeddb/mozilla/odd-result-order-expected.txt
LayoutTests/storage/indexeddb/mozilla/remove-objectstore-expected.txt
LayoutTests/storage/indexeddb/mozilla/resources/cursor-update-updates-indexes.js
LayoutTests/storage/indexeddb/mozilla/resources/event-source.js
LayoutTests/storage/indexeddb/mozilla/resources/global-data.js
LayoutTests/storage/indexeddb/mozilla/resources/key-requirements-put-null-key.js
LayoutTests/storage/indexeddb/mozilla/resources/odd-result-order.js
LayoutTests/storage/indexeddb/mozilla/resources/remove-objectstore.js
LayoutTests/storage/indexeddb/objectstore-removeobjectstore-expected.txt
LayoutTests/storage/indexeddb/resources/objectstore-removeobjectstore.js

index e5a76ce..8f7263e 100644 (file)
@@ -1,3 +1,52 @@
+2012-11-15  David Grogan  <dgrogan@chromium.org>
+
+        IndexedDB test conversions batch 5
+        https://bugs.webkit.org/show_bug.cgi?id=102308
+
+        Reviewed by Tony Chang.
+
+        * storage/indexeddb/mozilla/cursor-update-updates-indexes-expected.txt:
+        * storage/indexeddb/mozilla/event-source-expected.txt:
+        * storage/indexeddb/mozilla/global-data-expected.txt:
+        * storage/indexeddb/mozilla/key-requirements-put-null-key-expected.txt:
+        * storage/indexeddb/mozilla/odd-result-order-expected.txt:
+        * storage/indexeddb/mozilla/remove-objectstore-expected.txt:
+        * storage/indexeddb/mozilla/resources/cursor-update-updates-indexes.js:
+          Calls indexedDBTest a bunch of times, which seems awkward, but is
+          really convenient.
+
+        * storage/indexeddb/mozilla/resources/event-source.js:
+          Now that setVersion is gone, it appears that no request should have
+          a database as a source so the dropped test is ok.
+
+        * storage/indexeddb/mozilla/resources/global-data.js:
+        (prepareDatabase):
+        (open2Success):
+        * storage/indexeddb/mozilla/resources/key-requirements-put-null-key.js:
+        (prepareDatabase):
+        * storage/indexeddb/mozilla/resources/odd-result-order.js:
+          The tests had to be run in slightly different order but they are all
+          preserved.
+
+        (prepareDatabase):
+        (openSuccess):
+        (deleteSuccess):
+        * storage/indexeddb/mozilla/resources/remove-objectstore.js:
+        (prepareDatabase):
+        (checkObjectStore):
+        (inSetVersion2.request.onsuccess):
+        (inSetVersion2):
+        (setVersion3):
+        (inSetVersion3):
+        (deleteThirdObjectStore):
+        * storage/indexeddb/objectstore-removeobjectstore-expected.txt:
+        * storage/indexeddb/resources/objectstore-removeobjectstore.js:
+        (getValue):
+        (checkResult):
+        (addIndex):
+        (deleteObjectStore):
+        (createObjectStoreAgain):
+
 2012-11-15  Alpha Lam  <hclam@chromium.org>
 
         [chromium] WebGL texImage2D fails with deferred image decoding
index ab314ce..d1fa4fb 100644 (file)
@@ -1,14 +1,8 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
 Test IndexedDB: mutating records with a r/w cursor updates indexes on those records
 
 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.open(name)
-openSuccess():
-db = event.target.result
 firstValue = 'hi';
 secondValue = 'bye';
 objectStoreInfo = [
@@ -22,15 +16,21 @@ objectStoreInfo = [
           entry: { data: firstValue } },
     ];
 i = 0;
+
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+dbname = "cursor-update-updates-indexes.html"
+indexedDB.deleteDatabase(dbname)
 info = objectStoreInfo[i];
-request = db.setVersion('1')
+indexedDB.open(dbname)
 setupObjectStoreAndCreateIndex():
-Deleted all object stores.
+db = event.target.result
 objectStore = db.createObjectStore(info.name, info.options);
 index = objectStore.createIndex('data_index', 'data', { unique: false });
 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: true });
 request = objectStore.add(info.entry, info.key);
 trans = db.transaction(info.name, 'readwrite')
+trans.oncomplete = test
 objectStore = trans.objectStore(info.name)
 index = objectStore.index('data_index')
 uniqueIndex = objectStore.index('unique_data_index')
@@ -44,15 +44,21 @@ PASS value.data is event.target.result.data
 request = uniqueIndex.get(secondValue);
 PASS value.data is event.target.result.data
 i++;
+db.close()
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+dbname = "cursor-update-updates-indexes.html"
+indexedDB.deleteDatabase(dbname)
 info = objectStoreInfo[i];
-request = db.setVersion('1')
+indexedDB.open(dbname)
 setupObjectStoreAndCreateIndex():
-Deleted all object stores.
+db = event.target.result
 objectStore = db.createObjectStore(info.name, info.options);
 index = objectStore.createIndex('data_index', 'data', { unique: false });
 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: true });
 request = objectStore.add(info.entry);
 trans = db.transaction(info.name, 'readwrite')
+trans.oncomplete = test
 objectStore = trans.objectStore(info.name)
 index = objectStore.index('data_index')
 uniqueIndex = objectStore.index('unique_data_index')
@@ -66,15 +72,21 @@ PASS value.data is event.target.result.data
 request = uniqueIndex.get(secondValue);
 PASS value.data is event.target.result.data
 i++;
+db.close()
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+dbname = "cursor-update-updates-indexes.html"
+indexedDB.deleteDatabase(dbname)
 info = objectStoreInfo[i];
-request = db.setVersion('1')
+indexedDB.open(dbname)
 setupObjectStoreAndCreateIndex():
-Deleted all object stores.
+db = event.target.result
 objectStore = db.createObjectStore(info.name, info.options);
 index = objectStore.createIndex('data_index', 'data', { unique: false });
 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: true });
 request = objectStore.add(info.entry);
 trans = db.transaction(info.name, 'readwrite')
+trans.oncomplete = test
 objectStore = trans.objectStore(info.name)
 index = objectStore.index('data_index')
 uniqueIndex = objectStore.index('unique_data_index')
@@ -88,15 +100,21 @@ PASS value.data is event.target.result.data
 request = uniqueIndex.get(secondValue);
 PASS value.data is event.target.result.data
 i++;
+db.close()
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+dbname = "cursor-update-updates-indexes.html"
+indexedDB.deleteDatabase(dbname)
 info = objectStoreInfo[i];
-request = db.setVersion('1')
+indexedDB.open(dbname)
 setupObjectStoreAndCreateIndex():
-Deleted all object stores.
+db = event.target.result
 objectStore = db.createObjectStore(info.name, info.options);
 index = objectStore.createIndex('data_index', 'data', { unique: false });
 uniqueIndex = objectStore.createIndex('unique_data_index', 'data', { unique: true });
 request = objectStore.add(info.entry);
 trans = db.transaction(info.name, 'readwrite')
+trans.oncomplete = test
 objectStore = trans.objectStore(info.name)
 index = objectStore.index('data_index')
 uniqueIndex = objectStore.index('unique_data_index')
@@ -110,6 +128,7 @@ PASS value.data is event.target.result.data
 request = uniqueIndex.get(secondValue);
 PASS value.data is event.target.result.data
 i++;
+db.close()
 PASS successfullyParsed is true
 
 TEST COMPLETE
index c85f2c0..d870c28 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
 Test IndexedDB's event.target.source in success callbacks
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -6,14 +5,11 @@ 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.open(name)
+dbname = "event-source.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
 source = event.target.source;
 PASS source is null
-db = event.target.result
-request = db.setVersion('1')
-source = event.target.source;
-PASS source is db
-Deleted all object stores.
 objectStore = db.createObjectStore(objectStoreName, { autoIncrement: true });
 request = objectStore.add({});
 source = event.target.source;
index 70ace0e..499fbf7 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
 Test IndexedDB's opening DB more than once
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -6,12 +5,11 @@ 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.open(name)
-db1 = event.target.result
-request = db1.setVersion('1')
-Deleted all object stores.
+dbname = "global-data.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
 db1.createObjectStore(objectStoreName, objectStoreOptions);
-indexedDB.open(name);
+indexedDB.open(dbname);
 db2 = event.target.result
 PASS db1 !== db2 is true
 PASS db1.objectStoreNames.length is 1
index d2e7ce0..2701b0c 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
 Test IndexedDB's behavior put()ing with null key
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -6,10 +5,9 @@ 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.open(name)
-db = event.target.result
-request = db.setVersion('1')
-Deleted all object stores.
+dbname = "key-requirements-put-null-key.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
 objectStore = db.createObjectStore('bar');
 Expecting exception from objectStore.put({}, null);
 PASS Exception was thrown.
index 947aa54..8efc4f7 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
 Test IndexedDB: request result persists in setTimeout callback
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -6,18 +5,16 @@ 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.open(name)
+dbname = "odd-result-order.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
+objectStore = db.createObjectStore('foo', { keyPath: 'key', autoIncrement: true });
+index = objectStore.createIndex('foo', 'index');
 openSuccess():
 db = null;
 db = request.result;
 checkDatabaseType():
 PASS db instanceof IDBDatabase is true
-request = db.setVersion('1')
-setupObjectStore():
-Deleted all object stores.
-objectStore = db.createObjectStore('foo', { keyPath: 'key', autoIncrement: true });
-index = objectStore.createIndex('foo', 'index');
-event.target.transaction.oncomplete = addRecord;
 addRecord():
 objectStore = db.transaction('foo', 'readwrite').objectStore('foo');
 data = { key: 5, index: 10 };
index b248286..4919f0f 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
 Test IndexedDB deleting an object store
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -6,11 +5,10 @@ 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.open(name)
-db = event.target.result
+dbname = "remove-objectstore.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
 PASS db.objectStoreNames.length is 0
-request = db.setVersion('1')
-Deleted all object stores.
 objectStoreName = 'Objects';
 objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });
 request = objectStore.add({foo: i});
@@ -115,6 +113,8 @@ request = objectStore.add({foo: i});
 request = objectStore.add({foo: i});
 PASS db.objectStoreNames.length is 1
 PASS db.objectStoreNames.item(0) is objectStoreName
+db.close()
+request = indexedDB.open(dbname, 2)
 db.deleteObjectStore(objectStore.name);
 PASS db.objectStoreNames.length is 0
 objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });
@@ -124,7 +124,8 @@ request = objectStore.openCursor();
 PASS event.target.result is null
 db.deleteObjectStore(objectStore.name);
 PASS db.objectStoreNames.length is 0
-request = db.setVersion('3');
+db.close()
+request = indexedDB.open(dbname, 3)
 objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });
 request = objectStore.add({foo:'bar'});
 db.deleteObjectStore(objectStoreName);
index c9b9341..408c061 100644 (file)
@@ -11,23 +11,9 @@ if (this.importScripts) {
 
 description("Test IndexedDB: mutating records with a r/w cursor updates indexes on those records");
 
-function test()
-{
-    removeVendorPrefixes();
-
-    name = self.location.pathname;
-    request = evalAndLog("indexedDB.open(name)");
-    request.onsuccess = openSuccess;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function openSuccess()
-{
-    debug("openSuccess():");
-    db = evalAndLog("db = event.target.result");
-    firstValue = evalAndLog("firstValue = 'hi';");
-    secondValue = evalAndLog("secondValue = 'bye';");
-    objectStoreInfo = evalAndLog("objectStoreInfo = [\n" +
+firstValue = evalAndLog("firstValue = 'hi';");
+secondValue = evalAndLog("secondValue = 'bye';");
+objectStoreInfo = evalAndLog("objectStoreInfo = [\n" +
 "        { name: '1', options: {}, key: 1,\n" +
 "          entry: { data: firstValue } },\n" +
 "        { name: '2', options: { keyPath: 'foo' },\n" +
@@ -37,17 +23,16 @@ function openSuccess()
 "        { name: '4', options: { keyPath: 'foo', autoIncrement: true },\n" +
 "          entry: { data: firstValue } },\n" +
 "    ];");
-    i = evalAndLog("i = 0;");
-    setVersion();
-}
+i = evalAndLog("i = 0;");
+debug("");
+
+test();
 
-function setVersion()
+function test()
 {
     if (i < objectStoreInfo.length) {
+        indexedDBTest(setupObjectStoreAndCreateIndexAndAdd, openCursor);
         info = evalAndLog("info = objectStoreInfo[i];");
-        request = evalAndLog("request = db.setVersion('1')");
-        request.onsuccess = setupObjectStoreAndCreateIndexAndAdd;
-        request.onerror = unexpectedErrorCallback;
     } else {
         finishJSTest();
     }
@@ -55,9 +40,8 @@ function setVersion()
 
 function setupObjectStoreAndCreateIndexAndAdd()
 {
-    var transaction = event.target.result;
     debug("setupObjectStoreAndCreateIndex():");
-    deleteAllObjectStores(db);
+    evalAndLog("db = event.target.result");
 
     objectStore = evalAndLog("objectStore = db.createObjectStore(info.name, info.options);");
 
@@ -69,18 +53,16 @@ function setupObjectStoreAndCreateIndexAndAdd()
         request = evalAndLog("request = objectStore.add(info.entry);");
     }
     request.onerror = unexpectedErrorCallback;
-
-    transaction.oncomplete = function () {
-        evalAndLog("trans = db.transaction(info.name, 'readwrite')");
-        evalAndLog("objectStore = trans.objectStore(info.name)");
-        evalAndLog("index = objectStore.index('data_index')");
-        evalAndLog("uniqueIndex = objectStore.index('unique_data_index')");
-        openCursor();
-    };
 }
 
 function openCursor()
 {
+    evalAndLog("trans = db.transaction(info.name, 'readwrite')");
+    evalAndLog("trans.oncomplete = test");
+    trans.onabort = unexpectedAbortCallback;
+    evalAndLog("objectStore = trans.objectStore(info.name)");
+    evalAndLog("index = objectStore.index('data_index')");
+    evalAndLog("uniqueIndex = objectStore.index('unique_data_index')");
     request = evalAndLog("request = objectStore.openCursor();");
     request.onsuccess = updateCursor;
     request.onerror = unexpectedErrorCallback;
@@ -115,7 +97,5 @@ function checkIndex2()
 {
     shouldBe("value.data", "event.target.result.data");
     evalAndLog("i++;");
-    setVersion();
+    evalAndLog("db.close()");
 }
-
-test();
\ No newline at end of file
index 106e785..81decd8 100644 (file)
@@ -11,34 +11,13 @@ if (this.importScripts) {
 
 description("Test IndexedDB's event.target.source in success callbacks");
 
-function test()
-{
-    removeVendorPrefixes();
-
-    name = self.location.pathname;
-    request = evalAndLog("indexedDB.open(name)");
-    request.onsuccess = openSuccess;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function openSuccess()
+indexedDBTest(prepareDatabase, finishJSTest);
+function prepareDatabase()
 {
+    db = event.target.result;
     source = evalAndLog("source = event.target.source;");
     shouldBeNull("source");
 
-    db = evalAndLog("db = event.target.result");
-    request = evalAndLog("request = db.setVersion('1')");
-    request.onsuccess = cleanDatabase;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function cleanDatabase()
-{
-    source = evalAndLog("source = event.target.source;");
-    shouldBe("source", "db");
-
-    deleteAllObjectStores(db);
-
     objectStoreName = "Objects";
     objectStore = evalAndLog("objectStore = db.createObjectStore(objectStoreName, { autoIncrement: true });");
     request = evalAndLog("request = objectStore.add({});");
@@ -50,7 +29,4 @@ function areWeDoneYet()
 {
     source = evalAndLog("source = event.target.source;");
     shouldBe("source", "objectStore");
-    finishJSTest();
 }
-
-test();
\ No newline at end of file
index 00fdca1..6d9788b 100644 (file)
@@ -11,34 +11,16 @@ if (this.importScripts) {
 
 description("Test IndexedDB's opening DB more than once");
 
-function test()
+indexedDBTest(prepareDatabase);
+function prepareDatabase()
 {
-    removeVendorPrefixes();
-
-    name = self.location.pathname;
-    request = evalAndLog("indexedDB.open(name)");
-    request.onsuccess = openSuccess;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function openSuccess()
-{
-    db1 = evalAndLog("db1 = event.target.result");
-
-    request = evalAndLog("request = db1.setVersion('1')");
-    request.onsuccess = cleanDatabase;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function cleanDatabase()
-{
-    deleteAllObjectStores(db1);
+    db1 = event.target.result;
 
     objectStoreName = "Objects";
     objectStoreOptions = { keyPath: 'id', autoIncrement: true };
     evalAndLog("db1.createObjectStore(objectStoreName, objectStoreOptions);");
 
-    request = evalAndLog("indexedDB.open(name);");
+    request = evalAndLog("indexedDB.open(dbname);");
     request.onsuccess = open2Success;
     request.onerror = unexpectedErrorCallback;
 }
@@ -64,5 +46,3 @@ function open2Success()
 
     finishJSTest();
 }
-
-test();
\ No newline at end of file
index 8e0e747..9b32ffe 100644 (file)
@@ -11,31 +11,11 @@ if (this.importScripts) {
 
 description("Test IndexedDB's behavior put()ing with null key");
 
-function test()
+indexedDBTest(prepareDatabase);
+function prepareDatabase()
 {
-    removeVendorPrefixes();
-
-    name = self.location.pathname;
-    request = evalAndLog("indexedDB.open(name)");
-    request.onsuccess = openSuccess;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function openSuccess()
-{
-    db = evalAndLog("db = event.target.result");
-
-    request = evalAndLog("request = db.setVersion('1')");
-    request.onsuccess = cleanDatabase;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function cleanDatabase()
-{
-    deleteAllObjectStores(db);
+    db = event.target.result;
     objectStore = evalAndLog("objectStore = db.createObjectStore('bar');");
     evalAndExpectException("objectStore.put({}, null);", "IDBDatabaseException.DATA_ERR");
     finishJSTest();
 }
-
-test();
\ No newline at end of file
index 36f85cb..547ca6d 100644 (file)
@@ -11,14 +11,13 @@ if (this.importScripts) {
 
 description("Test IndexedDB: request result persists in setTimeout callback");
 
-function test()
+indexedDBTest(prepareDatabase, openSuccess);
+function prepareDatabase()
 {
-    removeVendorPrefixes();
-
-    name = self.location.pathname;
-    request = evalAndLog("indexedDB.open(name)");
-    request.onsuccess = openSuccess;
-    request.onerror = unexpectedErrorCallback;
+    request = event.target;
+    db = event.target.result;
+    objectStore = evalAndLog("objectStore = db.createObjectStore('foo', { keyPath: 'key', autoIncrement: true });");
+    index = evalAndLog("index = objectStore.createIndex('foo', 'index');");
 }
 
 function openSuccess()
@@ -28,6 +27,7 @@ function openSuccess()
     setTimeout(function() {
         db = evalAndLog("db = request.result;");
         checkDatabaseType();
+        addRecord();
     }, 0);
 }
 
@@ -36,18 +36,6 @@ function checkDatabaseType()
     debug("checkDatabaseType():");
     shouldBeTrue("db instanceof IDBDatabase");
     db.onerror = unexpectedErrorCallback;
-    request = evalAndLog("request = db.setVersion('1')");
-    request.onsuccess = setupObjectStore;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function setupObjectStore()
-{
-    debug("setupObjectStore():");
-    deleteAllObjectStores(db);
-    objectStore = evalAndLog("objectStore = db.createObjectStore('foo', { keyPath: 'key', autoIncrement: true });");
-    index = evalAndLog("index = objectStore.createIndex('foo', 'index');");
-    evalAndLog("event.target.transaction.oncomplete = addRecord;");
 }
 
 function addRecord()
@@ -112,5 +100,3 @@ function deleteSuccess()
     debug("deleteSuccess():");
     finishJSTest();
 }
-
-test();
\ No newline at end of file
index fb8c0f1..f6a1ca9 100644 (file)
@@ -11,31 +11,12 @@ if (this.importScripts) {
 
 description("Test IndexedDB deleting an object store");
 
-function test()
+indexedDBTest(prepareDatabase, checkObjectStore);
+function prepareDatabase()
 {
-    removeVendorPrefixes();
-
-    name = self.location.pathname;
-    request = evalAndLog("indexedDB.open(name)");
-    request.onsuccess = openSuccess;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function openSuccess()
-{
-    db = evalAndLog("db = event.target.result");
+    db = event.target.result;
     shouldBe("db.objectStoreNames.length", "0");
 
-    request = evalAndLog("request = db.setVersion('1')");
-    request.onsuccess = createAndPopulateObjectStore;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function createAndPopulateObjectStore()
-{
-    var v1_transaction = event.target.result;
-    deleteAllObjectStores(db);
-
     objectStoreName = evalAndLog("objectStoreName = 'Objects';");
     objectStore = evalAndLog("objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });");
 
@@ -43,22 +24,24 @@ function createAndPopulateObjectStore()
         request = evalAndLog("request = objectStore.add({foo: i});");
         request.onerror = unexpectedErrorCallback;
     }
-    v1_transaction.oncomplete = checkObjectStore;
 }
 
 function checkObjectStore()
 {
     shouldBe("db.objectStoreNames.length", "1");
     shouldBe("db.objectStoreNames.item(0)", "objectStoreName");
+    evalAndLog("db.close()");
 
-    request = db.setVersion('2');
+    evalAndLog("request = indexedDB.open(dbname, 2)");
     request.onerror = unexpectedErrorCallback;
-    request.onsuccess = postSetVersion2;
+    request.onblocked = unexpectedBlockedCallback;
+    request.onupgradeneeded = inSetVersion2;
+    request.onsuccess = setVersion3;
 }
 
-function postSetVersion2()
+function inSetVersion2()
 {
-    var v2_transaction = event.target.result;
+    db = event.target.result;
     evalAndLog("db.deleteObjectStore(objectStore.name);");
     shouldBe("db.objectStoreNames.length", "0");
 
@@ -72,7 +55,6 @@ function postSetVersion2()
         shouldBe("event.target.result", "null");
         deleteSecondObjectStore();
     };
-    v2_transaction.oncomplete = setVersion3;
 }
 
 function deleteSecondObjectStore()
@@ -83,13 +65,18 @@ function deleteSecondObjectStore()
 
 function setVersion3()
 {
-    request = evalAndLog("request = db.setVersion('3');");
+    evalAndLog("db.close()");
+
+    evalAndLog("request = indexedDB.open(dbname, 3)");
     request.onerror = unexpectedErrorCallback;
-    request.onsuccess = postSetVersion3;
+    request.onblocked = unexpectedBlockedCallback;
+    request.onupgradeneeded = inSetVersion3;
+    request.onsuccess = finishJSTest;
 }
 
-function postSetVersion3()
+function inSetVersion3()
 {
+    db = event.target.result;
     objectStore = evalAndLog("objectStore = db.createObjectStore(objectStoreName, { keyPath: 'foo' });");
     request = evalAndLog("request = objectStore.add({foo:'bar'});");
     request.onerror = unexpectedErrorCallback;
@@ -99,7 +86,4 @@ function postSetVersion3()
 function deleteThirdObjectStore()
 {
     evalAndLog("db.deleteObjectStore(objectStoreName);");
-    finishJSTest();
 }
-
-test();
\ No newline at end of file
index f6c8bb1..daa395f 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
 Test IndexedDB's webkitIDBObjectStore.deleteObjectStore().
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -17,9 +16,8 @@ db.transaction(['storeName'])
 store = transaction.objectStore('storeName')
 store.get('key')
 PASS event.target.result is "value"
-db.setVersion('new version')
-trans = event.target.result
-PASS trans is non-null.
+db.close()
+indexedDB.open(dbname, 2)
 db.deleteObjectStore('storeName')
 db.createObjectStore('storeName', null)
 db.transaction(['storeName'])
index 41e5c76..9040abc 100644 (file)
@@ -23,26 +23,34 @@ function getValue()
 {
     transaction = evalAndLog("db.transaction(['storeName'])");
     transaction.onabort = unexpectedErrorCallback;
+    transaction.oncomplete = addIndex;
     var store = evalAndLog("store = transaction.objectStore('storeName')");
 
     request = evalAndLog("store.get('key')");
-    request.onsuccess = addIndex;
+    request.onsuccess = checkResult;
     request.onerror = unexpectedErrorCallback;
 }
 
-function addIndex()
+function checkResult()
 {
     shouldBeEqualToString("event.target.result", "value");
+}
+
+function addIndex()
+{
+    evalAndLog("db.close()");
 
-    request = evalAndLog("db.setVersion('new version')");
-    request.onsuccess = deleteObjectStore;
+    request = evalAndLog("indexedDB.open(dbname, 2)");
+    request.onupgradeneeded = deleteObjectStore;
     request.onerror = unexpectedErrorCallback;
+    request.onsuccess = getValueAgain;
+    request.onblocked = unexpectedBlockedCallback;
 }
 
 function deleteObjectStore()
 {
-    self.trans = evalAndLog("trans = event.target.result");
-    shouldBeNonNull("trans");
+    trans = request.transaction;
+    db = request.result;
     trans.onabort = unexpectedAbortCallback;
 
     evalAndLog("db.deleteObjectStore('storeName')");
@@ -52,7 +60,6 @@ function deleteObjectStore()
 function createObjectStoreAgain()
 {
     evalAndLog("db.createObjectStore('storeName', null)");
-    trans.oncomplete = getValueAgain;
 }
 
 function getValueAgain()