IndexedDB: setVersion excision batch 9
authordgrogan@chromium.org <dgrogan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Nov 2012 00:52:27 +0000 (00:52 +0000)
committerdgrogan@chromium.org <dgrogan@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Nov 2012 00:52:27 +0000 (00:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=102455

Reviewed by Tony Chang.

* storage/indexeddb/persistence-expected.txt:
* storage/indexeddb/resources/persistence.js:
(prepareDatabase):
Little awkwardness to get the initial version number to be 0 (actually,
because of a bug it's "") so that first() will trigger a
versionchange.
(first):

* storage/indexeddb/resources/set_version_blocked.js:
  Small "blocked" test. It's probably redundant due to our crazier
  tests, but it is nice to have a succinct test that checks one thing.

* storage/indexeddb/resources/shared.js:
(unexpectedBlockedCallback):
* storage/indexeddb/resources/transaction-basics.js:
  This test is a mess, obviously written near the dawn of IDB when no
  one knew how to write an effective test for it. In the interests of
  preventing the diff from exploding I didn't take all the
  clarification opportunities that were there.

* storage/indexeddb/resources/transaction-error.js:
* storage/indexeddb/set_version_blocked-expected.txt:
* storage/indexeddb/transaction-basics-expected.txt:
* storage/indexeddb/transaction-error-expected.txt:

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

LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/persistence-expected.txt
LayoutTests/storage/indexeddb/resources/persistence.js
LayoutTests/storage/indexeddb/resources/set_version_blocked.js
LayoutTests/storage/indexeddb/resources/shared.js
LayoutTests/storage/indexeddb/resources/transaction-basics.js
LayoutTests/storage/indexeddb/resources/transaction-error.js
LayoutTests/storage/indexeddb/set_version_blocked-expected.txt
LayoutTests/storage/indexeddb/transaction-basics-expected.txt
LayoutTests/storage/indexeddb/transaction-error-expected.txt

index f8dd973..2ffcc34 100644 (file)
@@ -1,3 +1,35 @@
+2012-11-16  David Grogan  <dgrogan@chromium.org>
+
+        IndexedDB: setVersion excision batch 9
+        https://bugs.webkit.org/show_bug.cgi?id=102455
+
+        Reviewed by Tony Chang.
+
+        * storage/indexeddb/persistence-expected.txt:
+        * storage/indexeddb/resources/persistence.js:
+        (prepareDatabase):
+        Little awkwardness to get the initial version number to be 0 (actually,
+        because of a bug it's "") so that first() will trigger a
+        versionchange.
+        (first):
+
+        * storage/indexeddb/resources/set_version_blocked.js:
+          Small "blocked" test. It's probably redundant due to our crazier
+          tests, but it is nice to have a succinct test that checks one thing.
+
+        * storage/indexeddb/resources/shared.js:
+        (unexpectedBlockedCallback):
+        * storage/indexeddb/resources/transaction-basics.js:
+          This test is a mess, obviously written near the dawn of IDB when no
+          one knew how to write an effective test for it. In the interests of
+          preventing the diff from exploding I didn't take all the
+          clarification opportunities that were there.
+
+        * storage/indexeddb/resources/transaction-error.js:
+        * storage/indexeddb/set_version_blocked-expected.txt:
+        * storage/indexeddb/transaction-basics-expected.txt:
+        * storage/indexeddb/transaction-error-expected.txt:
+
 2012-11-16  Dimitri Glazkov  <dglazkov@chromium.org>
 
         [Chromium] Removed unnecessary expectation.
index 005cbfc..6e7da55 100644 (file)
@@ -1,8 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
 Test IndexedDB persistence
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -10,25 +5,25 @@ 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;
 
-dbname = self.location.pathname
+dbname = "persistence.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
 
-request = indexedDB.open('dbname')
+request = indexedDB.open(dbname, 1)
 db = request.result
 PASS db is non-null.
-db.setVersion("1")
-PASS db.version is "1"
-PASS db.name is "dbname"
+PASS db.version is 1
+PASS db.name is "persistence.html"
 PASS db.objectStoreNames.length is 0
 db.createObjectStore('store1')
 PASS db.objectStoreNames.length is 1
 db.close()
 
-request = indexedDB.open('dbname')
+request = indexedDB.open(dbname, 2)
 db = request.result
 PASS db is non-null.
-db.setVersion("2")
-PASS db.version is "2"
-PASS db.name is "dbname"
+PASS db.version is 2
+PASS db.name is "persistence.html"
 PASS db.objectStoreNames.length is 1
 PASS db.objectStoreNames.contains('store1') is true
 db.createObjectStore('store2')
@@ -37,12 +32,11 @@ PASS db.objectStoreNames.contains('store1') is true
 PASS db.objectStoreNames.contains('store2') is true
 db.close()
 
-request = indexedDB.open('dbname')
+request = indexedDB.open(dbname, 3)
 db = request.result
 PASS db is non-null.
-db.setVersion("3")
-PASS db.version is "3"
-PASS db.name is "dbname"
+PASS db.version is 3
+PASS db.name is "persistence.html"
 PASS db.objectStoreNames.length is 2
 PASS db.objectStoreNames.contains('store1') is true
 PASS db.objectStoreNames.contains('store2') is true
@@ -52,12 +46,11 @@ PASS db.objectStoreNames.contains('store1') is false
 PASS db.objectStoreNames.contains('store2') is true
 db.close()
 
-request = indexedDB.open('dbname')
+request = indexedDB.open(dbname, 4)
 db = request.result
 PASS db is non-null.
-db.setVersion("4")
-PASS db.version is "4"
-PASS db.name is "dbname"
+PASS db.version is 4
+PASS db.name is "persistence.html"
 PASS db.objectStoreNames.length is 1
 PASS db.objectStoreNames.contains('store1') is false
 PASS db.objectStoreNames.contains('store2') is true
@@ -67,12 +60,11 @@ PASS db.objectStoreNames.contains('store1') is false
 PASS db.objectStoreNames.contains('store2') is false
 db.close()
 
-request = indexedDB.open('dbname')
+request = indexedDB.open(dbname, 5)
 db = request.result
 PASS db is non-null.
-db.setVersion("5")
-PASS db.version is "5"
-PASS db.name is "dbname"
+PASS db.version is 5
+PASS db.name is "persistence.html"
 PASS db.objectStoreNames.length is 0
 PASS db.objectStoreNames.contains('store1') is false
 PASS db.objectStoreNames.contains('store2') is false
index 6d2e6e3..9d1cb0d 100644 (file)
@@ -5,15 +5,25 @@ if (this.importScripts) {
 
 description("Test IndexedDB persistence");
 
-function test()
+indexedDBTest(prepareDatabase, unexpectedSuccessCallback);
+function prepareDatabase()
 {
-    removeVendorPrefixes();
-    evalAndLog("dbname = self.location.pathname");
+    request = event.target;
+    var db = request.result;
+    var trans = request.transaction;
+    trans.abort();
+    request.onerror = function() {
+        db.close();
+        first();
+    };
+}
 
-    openAndChangeVersion("1", function (connection) {
+function first()
+{
+    openAndChangeVersion(1, function (connection) {
         db = connection;
-        shouldBeEqualToString("db.version", "1");
-        shouldBeEqualToString("db.name", "dbname");
+        shouldBe("db.version", "1");
+        shouldBeEqualToString("db.name", dbname);
         shouldBe("db.objectStoreNames.length", "0");
         evalAndLog("db.createObjectStore('store1')");
         shouldBe("db.objectStoreNames.length", "1");
@@ -22,10 +32,10 @@ function test()
 
 function second()
 {
-    openAndChangeVersion("2", function (connection) {
+    openAndChangeVersion(2, function (connection) {
         db = connection;
-        shouldBeEqualToString("db.version", "2");
-        shouldBeEqualToString("db.name", "dbname");
+        shouldBe("db.version", "2");
+        shouldBeEqualToString("db.name", dbname);
         shouldBe("db.objectStoreNames.length", "1");
         shouldBeTrue("db.objectStoreNames.contains('store1')");
         evalAndLog("db.createObjectStore('store2')");
@@ -37,10 +47,10 @@ function second()
 
 function third()
 {
-    openAndChangeVersion("3", function (connection) {
+    openAndChangeVersion(3, function (connection) {
         db = connection;
-        shouldBeEqualToString("db.version", "3");
-        shouldBeEqualToString("db.name", "dbname");
+        shouldBe("db.version", "3");
+        shouldBeEqualToString("db.name", dbname);
         shouldBe("db.objectStoreNames.length", "2");
         shouldBeTrue("db.objectStoreNames.contains('store1')");
         shouldBeTrue("db.objectStoreNames.contains('store2')");
@@ -53,10 +63,10 @@ function third()
 
 function fourth()
 {
-    openAndChangeVersion("4", function (connection) {
+    openAndChangeVersion(4, function (connection) {
         db = connection;
-        shouldBeEqualToString("db.version", "4");
-        shouldBeEqualToString("db.name", "dbname");
+        shouldBe("db.version", "4");
+        shouldBeEqualToString("db.name", dbname);
         shouldBe("db.objectStoreNames.length", "1");
         shouldBeFalse("db.objectStoreNames.contains('store1')");
         shouldBeTrue("db.objectStoreNames.contains('store2')");
@@ -69,10 +79,10 @@ function fourth()
 
 function fifth()
 {
-    openAndChangeVersion("5", function (connection) {
+    openAndChangeVersion(5, function (connection) {
         db = connection;
-        shouldBeEqualToString("db.version", "5");
-        shouldBeEqualToString("db.name", "dbname");
+        shouldBe("db.version", "5");
+        shouldBeEqualToString("db.name", dbname);
         shouldBe("db.objectStoreNames.length", "0");
         shouldBeFalse("db.objectStoreNames.contains('store1')");
         shouldBeFalse("db.objectStoreNames.contains('store2')");
@@ -83,23 +93,16 @@ function fifth()
 function openAndChangeVersion(version, callback, next)
 {
     debug("");
-    evalAndLog("request = indexedDB.open('dbname')");
+    evalAndLog("request = indexedDB.open(dbname, " + version + ")");
+    request.onblocked = unexpectedBlockedCallback;
     request.onerror = unexpectedErrorCallback;
-    request.onsuccess = function () {
+    request.onupgradeneeded = function () {
         evalAndLog("db = request.result");
         shouldBeNonNull("db");
-        request = evalAndLog("db.setVersion(" + JSON.stringify(version) + ")");
-        request.onerror = unexpectedErrorCallback;
-        request.onsuccess = function () {
-            var trans = request.result;
-            trans.onabort = unexpectedAbortCallback;
-            callback(db);
-            trans.oncomplete = function () {
-                evalAndLog("db.close()");
-                next();
-            };
-        };
+        callback(db);
     };
+    request.onsuccess = function() {
+        evalAndLog("db.close()");
+        next();
+    }
 }
-
-test();
index a29aa5c..2cc5cc5 100644 (file)
@@ -5,33 +5,17 @@ if (this.importScripts) {
 
 description("An open connection blocks a separate connection's setVersion call");
 
-connections = []
-function test()
+indexedDBTest(prepareDatabase, openAnother);
+function prepareDatabase()
 {
-    removeVendorPrefixes();
-    openDBConnection();
-}
-
-function openDBConnection()
-{
-    request = evalAndLog("indexedDB.open('set-version-blocked')");
-    request.onsuccess = openSuccess;
-    request.onerror = unexpectedErrorCallback;
+    connection = event.target.result;
 }
 
-function openSuccess()
+function openAnother()
 {
-    connection = event.target.result;
-    connections.push(connection);
-    original_version = connection.version;
-    if (connections.length < 2)
-        openDBConnection();
-    else {
-        var versionChangeRequest = evalAndLog("connections[0].setVersion('version 1')");
-        versionChangeRequest.onerror = unexpectedErrorCallback;
-        versionChangeRequest.onsuccess = inSetVersion;
-        versionChangeRequest.onblocked = blocked;
-    }
+    openRequest = indexedDB.open(dbname, 2);
+    openRequest.onblocked = blocked;
+    openRequest.onupgradeneeded = inSetVersion;
 }
 
 seen_blocked_event = false;
@@ -39,17 +23,16 @@ function blocked()
 {
     evalAndLog("seen_blocked_event = true");
     blocked_event = event;
-    shouldBeEqualToString("blocked_event.version", "version 1");
+    shouldBe("blocked_event.oldVersion", "1");
+    shouldBe("blocked_event.newVersion", "2");
     shouldEvaluateTo("blocked_event.target.readyState", "'pending'");
-    evalAndLog("connections[1].close()");
+    evalAndLog("connection.close()");
 }
 
 function inSetVersion()
 {
     debug("in setVersion.onsuccess");
     shouldBeTrue("seen_blocked_event");
-    deleteAllObjectStores(connections[0]);
+    deleteAllObjectStores(connection);
     finishJSTest();
 }
-
-test();
index 1dfcac9..6c3cec9 100644 (file)
@@ -64,9 +64,9 @@ function unexpectedCompleteCallback()
     finishJSTest();
 }
 
-function unexpectedBlockedCallback()
+function unexpectedBlockedCallback(e)
 {
-    testFailed("onblocked called unexpectedly");
+    testFailed("onblocked called unexpectedly. oldVersion = " + e.oldVersion + ", newVersion = " + e.newVersion);
     finishJSTest();
 }
 
index f91532b..8eb7563 100644 (file)
@@ -5,43 +5,27 @@ if (this.importScripts) {
 
 description("Test IndexedDB transaction basics.");
 
-function test()
+indexedDBTest(prepareDatabase, testSetVersionAbort1);
+function prepareDatabase()
 {
-    removeVendorPrefixes();
-
-    request = evalAndLog("indexedDB.open('transaction-basics')");
-    request.onsuccess = openSuccess;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function openSuccess()
-{
-    debug("openSuccess():");
-    self.db = evalAndLog("db = event.target.result");
-    request = evalAndLog("request = db.setVersion('version 1')");
-    request.onsuccess = cleanDatabase;
-    request.onerror = unexpectedErrorCallback;
-}
-
-function cleanDatabase()
-{
-    deleteAllObjectStores(db, checkMetadataEmpty);
-    event.target.result.oncomplete = testSetVersionAbort1;
+    db = event.target.result;
 }
 
 function testSetVersionAbort1()
 {
     checkMetadataEmpty();
-    request = evalAndLog("request = startSetVersion('version fail')");
-    request.onsuccess = addRemoveIDBObjects;
+    evalAndLog("request = newConnection()");
+    request.onupgradeneeded = addRemoveIDBObjects;
+    request.onsuccess = unexpectedSuccessCallback;
+    request.onerror = testSetVersionAbort2;
 }
 
 function addRemoveIDBObjects()
 {
     debug("addRemoveIDBObjects():");
-    var trans = evalAndLog("trans = event.target.result");
+    db = event.target.result;
+    evalAndLog("trans = event.target.transaction");
     shouldBeNonNull("trans");
-    trans.addEventListener('abort', testSetVersionAbort2, true);
     trans.oncomplete = unexpectedCompleteCallback;
 
     var store = evalAndLog("store = db.createObjectStore('storeFail', null)");
@@ -58,14 +42,16 @@ function testSetVersionAbort2()
     debug("");
     debug("testSetVersionAbort2():");
     checkMetadataEmpty();
-    request = evalAndLog("request = startSetVersion('version fail')");
-    request.onsuccess = addRemoveAddIDBObjects;
+    evalAndLog("request = newConnection()");
+    request.onupgradeneeded = addRemoveAddIDBObjects;
+    request.onerror = null;
 }
 
 function addRemoveAddIDBObjects()
 {
     debug("addRemoveAddIDBObjects():");
-    var trans = evalAndLog("trans = event.target.result");
+    db = event.target.result;
+    var trans = evalAndLog("trans = event.target.transaction");
     shouldBeNonNull("trans");
     trans.addEventListener('abort', testSetVersionAbort3, false);
     trans.oncomplete = unexpectedCompleteCallback;
@@ -88,15 +74,18 @@ function testSetVersionAbort3()
     debug("testSetVersionAbort3():");
     shouldBeFalse("event.cancelable");
     checkMetadataEmpty();
-    request = evalAndLog("request = startSetVersion('version fail')");
-    request.onsuccess = addIDBObjects;
+    evalAndLog("request = newConnection()");
+    request.onupgradeneeded = addIDBObjects;
+    request.onsuccess = unexpectedSuccessCallback;
+    request.onerror = testSetVersionAbort4;
 }
 
 function addIDBObjects()
 {
     debug("addIDBObjects():");
+    db = event.target.result;
     shouldBeFalse("event.cancelable");
-    var trans = evalAndLog("trans = event.target.result");
+    var trans = evalAndLog("trans = event.target.transaction");
     shouldBeNonNull("trans");
     trans.onabort = testInactiveAbortedTransaction;
     trans.oncomplete = unexpectedCompleteCallback;
@@ -123,8 +112,6 @@ function testInactiveAbortedTransaction()
     evalAndExpectException("store.clear()", "IDBDatabaseException.TRANSACTION_INACTIVE_ERR", "'TransactionInactiveError'");
     evalAndExpectException("store.get(0)", "IDBDatabaseException.TRANSACTION_INACTIVE_ERR", "'TransactionInactiveError'");
     evalAndExpectException("store.openCursor()", "IDBDatabaseException.TRANSACTION_INACTIVE_ERR", "'TransactionInactiveError'");
-
-    testSetVersionAbort4();
 }
 
 function testSetVersionAbort4()
@@ -132,14 +119,17 @@ function testSetVersionAbort4()
     debug("");
     debug("testSetVersionAbort4():");
     checkMetadataEmpty();
-    request = evalAndLog("request = startSetVersion('version fail')");
-    request.onsuccess = addIDBObjectsAndCommit;
+    evalAndLog("request = newConnection()");
+    request.onupgradeneeded = addIDBObjectsAndCommit;
+    request.onerror = unexpectedErrorCallback;
+    request.onsuccess = testSetVersionAbort5;
 }
 
 function addIDBObjectsAndCommit()
 {
+    db = event.target.result;
     debug("addIDBObjectsAndCommit():");
-    var trans = evalAndLog("trans = event.target.result");
+    var trans = evalAndLog("trans = event.target.transaction");
     shouldBeNonNull("trans");
     trans.onabort = unexpectedAbortCallback;
 
@@ -165,8 +155,6 @@ function testInactiveCompletedTransaction()
     evalAndExpectException("store.clear()", "IDBDatabaseException.TRANSACTION_INACTIVE_ERR", "'TransactionInactiveError'");
     evalAndExpectException("store.get(0)", "IDBDatabaseException.TRANSACTION_INACTIVE_ERR", "'TransactionInactiveError'");
     evalAndExpectException("store.openCursor()", "IDBDatabaseException.TRANSACTION_INACTIVE_ERR", "'TransactionInactiveError'");
-
-    testSetVersionAbort5();
 }
 
 function testSetVersionAbort5()
@@ -174,16 +162,18 @@ function testSetVersionAbort5()
     debug("");
     debug("testSetVersionAbort5():");
     checkMetadataExistingObjectStore();
-    request = evalAndLog("request = startSetVersion('version fail')");
-    request.onsuccess = removeIDBObjects;
+    evalAndLog("request = newConnection()");
+    request.onupgradeneeded = removeIDBObjects;
+    request.onsuccess = unexpectedSuccessCallback;
+    request.onerror = testSetVersionAbort6;
 }
 
 function removeIDBObjects()
 {
+    db = event.target.result;
     debug("removeIDBObjects():");
-    var trans = evalAndLog("trans = event.target.result");
+    var trans = evalAndLog("trans = event.target.transaction");
     shouldBeNonNull("trans");
-    trans.onabort = testSetVersionAbort6;
     trans.oncomplete = unexpectedCompleteCallback;
 
     var store = evalAndLog("store = trans.objectStore('storeFail')");
@@ -198,14 +188,9 @@ function testSetVersionAbort6()
     debug("");
     debug("testSetVersionAbort6():");
     checkMetadataExistingObjectStore();
-    setNewVersion();
-}
-
-function startSetVersion(versionName)
-{
-    request = db.setVersion(versionName);
-    request.onerror = unexpectedErrorCallback;
-    return request;
+    evalAndLog("request = newConnection()");
+    request.onupgradeneeded = setVersionSuccess;
+    request.onsuccess = completeCallback;
 }
 
 function checkMetadataEmpty()
@@ -222,22 +207,24 @@ function checkMetadataExistingObjectStore()
     shouldBe("db.objectStoreNames.contains('storeFail')", "true");
 }
 
-function setNewVersion()
+var version = 1;
+function newConnection()
 {
-    request = evalAndLog("db.setVersion('new version')");
-    request.onsuccess = setVersionSuccess;
+    db.close();
+    var request = evalAndLog("indexedDB.open(dbname, " + (++version) + ")");
     request.onerror = unexpectedErrorCallback;
+    request.onblocked = unexpectedBlockedCallback;
+    return request;
 }
 
 function setVersionSuccess()
 {
+    db = event.target.result;
     debug("");
     debug("setVersionSuccess():");
-    self.trans = evalAndLog("trans = event.target.result");
+    evalAndLog("trans = event.target.transaction");
     shouldBeNonNull("trans");
     trans.onabort = unexpectedAbortCallback;
-    trans.addEventListener('complete', completeCallback, false);
-    self.completeEventFired = false;
 
     deleteAllObjectStores(db);
 
@@ -246,6 +233,7 @@ function setVersionSuccess()
 
 function completeCallback()
 {
+    preamble();
     shouldBeFalse("event.cancelable");
     testPassed("complete event fired");
     transaction = evalAndLog("db.transaction(['storeName'])");
@@ -272,7 +260,7 @@ function testDOMStringList()
       shouldBeNonNull("transaction.objectStore(" + JSON.stringify(db.objectStoreNames[i]) + ")");
     }
     testPassed("all stores present in transaction");
-    testInvalidMode();
+    transaction.oncomplete = testInvalidMode;
 }
 
 function testInvalidMode()
@@ -291,10 +279,11 @@ function testDegenerateNames()
     evalAndExpectException("db.transaction(null)", "DOMException.NOT_FOUND_ERR", "'NotFoundError'");
     evalAndExpectException("db.transaction(undefined)", "DOMException.NOT_FOUND_ERR", "'NotFoundError'");
 
-    request = evalAndLog("db.setVersion('funny names')");
+    evalAndLog("request = newConnection()");
     request.onerror = unexpectedErrorCallback;
-    request.onsuccess = function () {
-        var trans = request.result;
+    request.onupgradeneeded = function () {
+        var trans = request.transaction;
+        db = event.target.result;
         evalAndLog("db.createObjectStore('null')");
         evalAndLog("db.createObjectStore('undefined')");
         trans.oncomplete = verifyDegenerateNames;
@@ -307,5 +296,3 @@ function testDegenerateNames()
         finishJSTest();
     }
 }
-
-test();
index 581dc11..560629b 100644 (file)
@@ -5,32 +5,13 @@ if (this.importScripts) {
 
 description("Test IDBTransaction.error cases.");
 
-function test()
+indexedDBTest(prepareDatabase, startTest);
+function prepareDatabase()
 {
-    removeVendorPrefixes();
-
-    evalAndLog("dbname = self.location.pathname");
-    request = evalAndLog("indexedDB.deleteDatabase(dbname)");
-    request.onblocked = unexpectedBlockedCallback;
+    db = event.target.result;
+    evalAndLog("store = db.createObjectStore('storeName')");
+    request = evalAndLog("store.add('value', 'key')");
     request.onerror = unexpectedErrorCallback;
-    request.onsuccess = function() {
-        request = evalAndLog("indexedDB.open(dbname)");
-        request.onerror = unexpectedErrorCallback;
-        request.onsuccess = function() {
-            evalAndLog("db = request.result");
-            request = evalAndLog("db.setVersion('1')");
-            request.onblocked = unexpectedBlockedCallback;
-            request.onerror = unexpectedErrorCallback;
-            request.onsuccess = function() {
-                evalAndLog("trans = event.target.result");
-                trans.onabort = unexpectedAbortCallback;
-                evalAndLog("store = db.createObjectStore('storeName')");
-                request = evalAndLog("store.add('value', 'key')");
-                request.onerror = unexpectedErrorCallback;
-                trans.oncomplete = startTest;
-            };
-        };
-    };
 }
 
 function startTest()
@@ -115,11 +96,12 @@ function testErrorFromCommit()
     request.onerror = unexpectedErrorCallback;
     trans.onabort = unexpectedAbortCallback;
     trans.oncomplete = function() {
-        evalAndLog("request = db.setVersion('2')");
-        request.onerror = unexpectedErrorCallback;
+        db.close();
+        evalAndLog("request = indexedDB.open(dbname, 2)");
+        request.onerror = unexpectedSuccessCallback;
         request.onblocked = unexpectedBlockedCallback;
-        request.onsuccess = function() {
-            evalAndLog("trans = request.result");
+        request.onupgradeneeded = function() {
+            evalAndLog("trans = request.transaction");
             debug("This should fail due to the unique constraint:");
             evalAndLog("trans.objectStore('storeName').createIndex('indexName', 'id', {unique: true})");
             trans.oncomplete = unexpectedCompleteCallback;
@@ -134,5 +116,3 @@ function testErrorFromCommit()
         };
     };
 }
-
-test();
index 74fc498..0054d33 100644 (file)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
 An open connection blocks a separate connection's setVersion call
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -6,13 +5,14 @@ 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('set-version-blocked')
-indexedDB.open('set-version-blocked')
-connections[0].setVersion('version 1')
+dbname = "set_version_blocked.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
 seen_blocked_event = true
-PASS blocked_event.version is "version 1"
+PASS blocked_event.oldVersion is 1
+PASS blocked_event.newVersion is 2
 PASS blocked_event.target.readyState is 'pending'
-connections[1].close()
+connection.close()
 in setVersion.onsuccess
 PASS seen_blocked_event is true
 Deleted all object stores.
index 69da0ed..78f0c6b 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 transaction basics.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -6,17 +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('transaction-basics')
-openSuccess():
-db = event.target.result
-request = db.setVersion('version 1')
-Deleted all object stores.
+dbname = "transaction-basics.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
 PASS self.db.objectStoreNames is []
 PASS self.db.objectStoreNames.length is 0
 PASS self.db.objectStoreNames.contains('storeFail') is false
-request = startSetVersion('version fail')
+request = newConnection()
+indexedDB.open(dbname, 2)
 addRemoveIDBObjects():
-trans = event.target.result
+trans = event.target.transaction
 PASS trans is non-null.
 store = db.createObjectStore('storeFail', null)
 index = store.createIndex('indexFail', 'x')
@@ -30,9 +28,10 @@ testSetVersionAbort2():
 PASS self.db.objectStoreNames is []
 PASS self.db.objectStoreNames.length is 0
 PASS self.db.objectStoreNames.contains('storeFail') is false
-request = startSetVersion('version fail')
+request = newConnection()
+indexedDB.open(dbname, 3)
 addRemoveAddIDBObjects():
-trans = event.target.result
+trans = event.target.transaction
 PASS trans is non-null.
 store = db.createObjectStore('storeFail', null)
 index = store.createIndex('indexFail', 'x')
@@ -49,10 +48,11 @@ PASS event.cancelable is false
 PASS self.db.objectStoreNames is []
 PASS self.db.objectStoreNames.length is 0
 PASS self.db.objectStoreNames.contains('storeFail') is false
-request = startSetVersion('version fail')
+request = newConnection()
+indexedDB.open(dbname, 4)
 addIDBObjects():
 PASS event.cancelable is false
-trans = event.target.result
+trans = event.target.transaction
 PASS trans is non-null.
 store = db.createObjectStore('storeFail', null)
 index = store.createIndex('indexFail', 'x')
@@ -107,9 +107,10 @@ testSetVersionAbort4():
 PASS self.db.objectStoreNames is []
 PASS self.db.objectStoreNames.length is 0
 PASS self.db.objectStoreNames.contains('storeFail') is false
-request = startSetVersion('version fail')
+request = newConnection()
+indexedDB.open(dbname, 5)
 addIDBObjectsAndCommit():
-trans = event.target.result
+trans = event.target.transaction
 PASS trans is non-null.
 store = db.createObjectStore('storeFail', null)
 index = store.createIndex('indexFail', 'x')
@@ -164,9 +165,10 @@ testSetVersionAbort5():
 PASS db.objectStoreNames is ['storeFail']
 PASS db.objectStoreNames.length is 1
 PASS db.objectStoreNames.contains('storeFail') is true
-request = startSetVersion('version fail')
+request = newConnection()
+indexedDB.open(dbname, 6)
 removeIDBObjects():
-trans = event.target.result
+trans = event.target.transaction
 PASS trans is non-null.
 store = trans.objectStore('storeFail')
 store.deleteIndex('indexFail')
@@ -176,13 +178,16 @@ testSetVersionAbort6():
 PASS db.objectStoreNames is ['storeFail']
 PASS db.objectStoreNames.length is 1
 PASS db.objectStoreNames.contains('storeFail') is true
-db.setVersion('new version')
+request = newConnection()
+indexedDB.open(dbname, 7)
 
 setVersionSuccess():
-trans = event.target.result
+trans = event.target.transaction
 PASS trans is non-null.
 Deleted all object stores.
 db.createObjectStore('storeName', null)
+
+completeCallback():
 PASS event.cancelable is false
 PASS complete event fired
 db.transaction(['storeName'])
@@ -212,7 +217,8 @@ Expecting exception from db.transaction(undefined)
 PASS Exception was thrown.
 PASS code is DOMException.NOT_FOUND_ERR
 PASS ename is 'NotFoundError'
-db.setVersion('funny names')
+request = newConnection()
+indexedDB.open(dbname, 8)
 db.createObjectStore('null')
 db.createObjectStore('undefined')
 PASS transaction = db.transaction(null) did not throw exception.
index d341385..8091237 100644 (file)
@@ -1,5 +1,4 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
-CONSOLE MESSAGE: line 92: Uncaught Error: This should *NOT* be caught!
+CONSOLE MESSAGE: line 73: Uncaught Error: This should *NOT* be caught!
 Test IDBTransaction.error cases.
 
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -7,12 +6,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;
 
-dbname = self.location.pathname
+dbname = "transaction-error.html"
 indexedDB.deleteDatabase(dbname)
 indexedDB.open(dbname)
-db = request.result
-db.setVersion('1')
-trans = event.target.result
 store = db.createObjectStore('storeName')
 store.add('value', 'key')
 
@@ -49,8 +45,8 @@ If the transaction is aborted due to an error during commit, IDBTransaction.erro
 trans = db.transaction('storeName', 'readwrite')
 request = trans.objectStore('storeName').add({id: 1}, 'record1')
 request = trans.objectStore('storeName').add({id: 1}, 'record2')
-request = db.setVersion('2')
-trans = request.result
+request = indexedDB.open(dbname, 2)
+trans = request.transaction
 This should fail due to the unique constraint:
 trans.objectStore('storeName').createIndex('indexName', 'id', {unique: true})
 Transaction received abort event.