Title: [135018] trunk/LayoutTests
Revision
135018
Author
dgro...@chromium.org
Date
2012-11-16 16:52:27 -0800 (Fri, 16 Nov 2012)

Log Message

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:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (135017 => 135018)


--- trunk/LayoutTests/ChangeLog	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/ChangeLog	2012-11-17 00:52:27 UTC (rev 135018)
@@ -1,3 +1,35 @@
+2012-11-16  David Grogan  <dgro...@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  <dglaz...@chromium.org>
 
         [Chromium] Removed unnecessary expectation.

Modified: trunk/LayoutTests/storage/indexeddb/persistence-expected.txt (135017 => 135018)


--- trunk/LayoutTests/storage/indexeddb/persistence-expected.txt	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/storage/indexeddb/persistence-expected.txt	2012-11-17 00:52:27 UTC (rev 135018)
@@ -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 @@
 
 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('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('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('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

Modified: trunk/LayoutTests/storage/indexeddb/resources/persistence.js (135017 => 135018)


--- trunk/LayoutTests/storage/indexeddb/resources/persistence.js	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/storage/indexeddb/resources/persistence.js	2012-11-17 00:52:27 UTC (rev 135018)
@@ -5,15 +5,25 @@
 
 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 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 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 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 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 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();

Modified: trunk/LayoutTests/storage/indexeddb/resources/set_version_blocked.js (135017 => 135018)


--- trunk/LayoutTests/storage/indexeddb/resources/set_version_blocked.js	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/storage/indexeddb/resources/set_version_blocked.js	2012-11-17 00:52:27 UTC (rev 135018)
@@ -5,51 +5,34 @@
 
 description("An open connection blocks a separate connection's setVersion call");
 
-connections = []
-function test()
+indexedDBTest(prepareDatabase, openAnother);
+function prepareDatabase()
 {
-    removeVendorPrefixes();
-    openDBConnection();
+    connection = event.target.result;
 }
 
-function openDBConnection()
+function openAnother()
 {
-    request = evalAndLog("indexedDB.open('set-version-blocked')");
-    request._onsuccess_ = openSuccess;
-    request._onerror_ = unexpectedErrorCallback;
+    openRequest = indexedDB.open(dbname, 2);
+    openRequest._onblocked_ = blocked;
+    openRequest._onupgradeneeded_ = inSetVersion;
 }
 
-function openSuccess()
-{
-    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;
-    }
-}
-
 seen_blocked_event = false;
 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();

Modified: trunk/LayoutTests/storage/indexeddb/resources/shared.js (135017 => 135018)


--- trunk/LayoutTests/storage/indexeddb/resources/shared.js	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/storage/indexeddb/resources/shared.js	2012-11-17 00:52:27 UTC (rev 135018)
@@ -64,9 +64,9 @@
     finishJSTest();
 }
 
-function unexpectedBlockedCallback()
+function unexpectedBlockedCallback(e)
 {
-    testFailed("onblocked called unexpectedly");
+    testFailed("onblocked called unexpectedly. oldVersion = " + e.oldVersion + ", newVersion = " + e.newVersion);
     finishJSTest();
 }
 

Modified: trunk/LayoutTests/storage/indexeddb/resources/transaction-basics.js (135017 => 135018)


--- trunk/LayoutTests/storage/indexeddb/resources/transaction-basics.js	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/storage/indexeddb/resources/transaction-basics.js	2012-11-17 00:52:27 UTC (rev 135018)
@@ -5,43 +5,27 @@
 
 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;
+    db = event.target.result;
 }
 
-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;
-}
-
 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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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,16 +188,11 @@
     debug("");
     debug("testSetVersionAbort6():");
     checkMetadataExistingObjectStore();
-    setNewVersion();
+    evalAndLog("request = newConnection()");
+    request._onupgradeneeded_ = setVersionSuccess;
+    request._onsuccess_ = completeCallback;
 }
 
-function startSetVersion(versionName)
-{
-    request = db.setVersion(versionName);
-    request._onerror_ = unexpectedErrorCallback;
-    return request;
-}
-
 function checkMetadataEmpty()
 {
     shouldBe("self.db.objectStoreNames", "[]");
@@ -222,22 +207,24 @@
     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 completeCallback()
 {
+    preamble();
     shouldBeFalse("event.cancelable");
     testPassed("complete event fired");
     transaction = evalAndLog("db.transaction(['storeName'])");
@@ -272,7 +260,7 @@
       shouldBeNonNull("transaction.objectStore(" + JSON.stringify(db.objectStoreNames[i]) + ")");
     }
     testPassed("all stores present in transaction");
-    testInvalidMode();
+    transaction._oncomplete_ = testInvalidMode;
 }
 
 function testInvalidMode()
@@ -291,10 +279,11 @@
     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 @@
         finishJSTest();
     }
 }
-
-test();

Modified: trunk/LayoutTests/storage/indexeddb/resources/transaction-error.js (135017 => 135018)


--- trunk/LayoutTests/storage/indexeddb/resources/transaction-error.js	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/storage/indexeddb/resources/transaction-error.js	2012-11-17 00:52:27 UTC (rev 135018)
@@ -5,32 +5,13 @@
 
 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 @@
     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 @@
         };
     };
 }
-
-test();

Modified: trunk/LayoutTests/storage/indexeddb/set_version_blocked-expected.txt (135017 => 135018)


--- trunk/LayoutTests/storage/indexeddb/set_version_blocked-expected.txt	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/storage/indexeddb/set_version_blocked-expected.txt	2012-11-17 00:52:27 UTC (rev 135018)
@@ -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 @@
 
 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.

Modified: trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt (135017 => 135018)


--- trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/storage/indexeddb/transaction-basics-expected.txt	2012-11-17 00:52:27 UTC (rev 135018)
@@ -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 @@
 
 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 @@
 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 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 @@
 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 @@
 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 @@
 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 @@
 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.

Modified: trunk/LayoutTests/storage/indexeddb/transaction-error-expected.txt (135017 => 135018)


--- trunk/LayoutTests/storage/indexeddb/transaction-error-expected.txt	2012-11-17 00:40:15 UTC (rev 135017)
+++ trunk/LayoutTests/storage/indexeddb/transaction-error-expected.txt	2012-11-17 00:52:27 UTC (rev 135018)
@@ -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 @@
 
 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 @@
 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.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to