Diff
Modified: trunk/LayoutTests/ChangeLog (134334 => 134335)
--- trunk/LayoutTests/ChangeLog 2012-11-13 02:09:35 UTC (rev 134334)
+++ trunk/LayoutTests/ChangeLog 2012-11-13 02:09:45 UTC (rev 134335)
@@ -1,3 +1,37 @@
+2012-11-12 David Grogan <[email protected]>
+
+ IndexedDB: Convert some non-simple tests from setVersion to upgradeneeded
+ https://bugs.webkit.org/show_bug.cgi?id=101959
+
+ Reviewed by Tony Chang.
+
+ Ongoing work to remove calls to setVersion from our tests before
+ removing it from the IndexedDB API.
+
+ * storage/indexeddb/create-and-remove-object-store-expected.txt:
+ * storage/indexeddb/deletedatabase-delayed-by-open-and-versionchange-expected.txt:
+ * storage/indexeddb/duplicates-expected.txt:
+ * storage/indexeddb/resources/create-and-remove-object-store.js:
+ Create and delete were running between open and setVersion, which no
+ longer makes sense.
+
+ * storage/indexeddb/resources/database-deletepending-flag.js:
+ Use optional object parameter instead of optional version parameter.
+
+ * storage/indexeddb/resources/deletedatabase-delayed-by-open-and-versionchange.js:
+ This used to call delete just after issuing setVersion but before
+ receiving the corresponding success event. Now it calls delete while
+ in the upgradeneeded transaction, still causing the delete to be
+ delayed by an in flight versionchange transaction.
+
+ * storage/indexeddb/resources/duplicates.js:
+ Call indexedDBTest twice to rerun the tests with a different
+ database.
+
+ * storage/indexeddb/resources/shared.js:
+ Added a suffix option to support duplicates.js, switched to an
+ optional object parameter.
+
2012-11-12 Raphael Kubo da Costa <[email protected]>
[EFL] WebKit1 gardening.
Modified: trunk/LayoutTests/storage/indexeddb/create-and-remove-object-store-expected.txt (134334 => 134335)
--- trunk/LayoutTests/storage/indexeddb/create-and-remove-object-store-expected.txt 2012-11-13 02:09:35 UTC (rev 134334)
+++ trunk/LayoutTests/storage/indexeddb/create-and-remove-object-store-expected.txt 2012-11-13 02:09:45 UTC (rev 134335)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
Test IndexedDB's create and removeObjectStore
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -6,31 +5,9 @@
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
-indexedDB.open('create-and-remove-object-store')
-openSuccess():
-db = event.target.result
-Trying create
-Expecting exception from db.createObjectStore("some os")
-PASS Exception was thrown.
-PASS code is DOMException.INVALID_STATE_ERR
-PASS ename is 'InvalidStateError'
-Trying remove
-Expecting exception from db.deleteObjectStore("some os")
-PASS Exception was thrown.
-PASS code is DOMException.INVALID_STATE_ERR
-PASS ename is 'InvalidStateError'
-result = db.setVersion('version 1')
-Trying create
-Expecting exception from db.createObjectStore("some os")
-PASS Exception was thrown.
-PASS code is DOMException.INVALID_STATE_ERR
-PASS ename is 'InvalidStateError'
-Trying remove
-Expecting exception from db.deleteObjectStore("some os")
-PASS Exception was thrown.
-PASS code is DOMException.INVALID_STATE_ERR
-PASS ename is 'InvalidStateError'
-Deleted all object stores.
+dbname = "create-and-remove-object-store.html"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
db.createObjectStore('tmp')
Expecting exception from db.createObjectStore('tmp')
PASS Exception was thrown.
Modified: trunk/LayoutTests/storage/indexeddb/deletedatabase-delayed-by-open-and-versionchange-expected.txt (134334 => 134335)
--- trunk/LayoutTests/storage/indexeddb/deletedatabase-delayed-by-open-and-versionchange-expected.txt 2012-11-13 02:09:35 UTC (rev 134334)
+++ trunk/LayoutTests/storage/indexeddb/deletedatabase-delayed-by-open-and-versionchange-expected.txt 2012-11-13 02:09:45 UTC (rev 134335)
@@ -1,4 +1,3 @@
-CONSOLE MESSAGE: The setVersion() method is non-standard and will be removed. Use the "upgradeneeded" event instead.
Test that deleteDatabase is delayed if a VERSION_CHANGE transaction is running
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -7,22 +6,17 @@
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
dbname = "deletedatabase-delayed-by-open-and-versionchange.html"
-ver = 1
-versionChangeComplete = false
+indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
-
-openOnSuccess():
+versionChangeComplete = false
h = event.target.result
-h.setVersion(String(ver++))
indexedDB.deleteDatabase(dbname)
-setVersionOnSuccess():
-
transactionOnComplete():
versionChangeComplete = true
onVersionChange():
-old = "1"
+old = 1
new = ""
deleteDatabaseOnBlocked():
Modified: trunk/LayoutTests/storage/indexeddb/duplicates-expected.txt (134334 => 134335)
--- trunk/LayoutTests/storage/indexeddb/duplicates-expected.txt 2012-11-13 02:09:35 UTC (rev 134334)
+++ trunk/LayoutTests/storage/indexeddb/duplicates-expected.txt 2012-11-13 02:09:45 UTC (rev 134335)
@@ -1,5 +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.
Verify that you can put the same data in 2 different databases without uniqueness constraints firing.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
@@ -7,13 +5,9 @@
indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
-indexedDB.open('duplicates-1')
-db = event.target.result
-db.setVersion('new version')
-setVersionSuccess():
-trans = event.target.result
-PASS trans is non-null.
-Deleted all object stores.
+dbname = "duplicates.html-1"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
db.createObjectStore('storeName', null)
store.createIndex('indexName', 'x')
store.add({x: 'value', y: 'zzz'}, 'key')
@@ -49,13 +43,11 @@
PASS event.target.result.value.y is "zzz2"
event.target.result.continue()
PASS event.target.result is null
-indexedDB.open('duplicates-2')
-db = event.target.result
-db.setVersion('new version')
-setVersionSuccess():
-trans = event.target.result
-PASS trans is non-null.
-Deleted all object stores.
+indexedDB = self.indexedDB || self.webkitIndexedDB || self.mozIndexedDB || self.msIndexedDB || self.OIndexedDB;
+
+dbname = "duplicates.html-2"
+indexedDB.deleteDatabase(dbname)
+indexedDB.open(dbname)
db.createObjectStore('storeName', null)
store.createIndex('indexName', 'x')
store.add({x: 'value', y: 'zzz'}, 'key')
Modified: trunk/LayoutTests/storage/indexeddb/resources/create-and-remove-object-store.js (134334 => 134335)
--- trunk/LayoutTests/storage/indexeddb/resources/create-and-remove-object-store.js 2012-11-13 02:09:35 UTC (rev 134334)
+++ trunk/LayoutTests/storage/indexeddb/resources/create-and-remove-object-store.js 2012-11-13 02:09:45 UTC (rev 134335)
@@ -5,55 +5,31 @@
description("Test IndexedDB's create and removeObjectStore");
-function test()
+indexedDBTest(prepareDatabase, setVersionComplete);
+function prepareDatabase()
{
- removeVendorPrefixes();
- request = evalAndLog("indexedDB.open('create-and-remove-object-store')");
- request._onsuccess_ = openSuccess;
- request._onerror_ = unexpectedErrorCallback;
-}
-
-function openSuccess()
-{
- debug("openSuccess():");
- self.db = evalAndLog("db = event.target.result");
- testCreateAndRemove();
- request = evalAndLog("result = db.setVersion('version 1')");
- request._onsuccess_ = cleanDatabase;
- request._onerror_ = unexpectedErrorCallback;
- testCreateAndRemove();
-}
-
-function testCreateAndRemove()
-{
- debug("Trying create");
- evalAndExpectException('db.createObjectStore("some os")', "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
- debug("Trying remove");
- evalAndExpectException('db.deleteObjectStore("some os")', "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
-}
-
-function cleanDatabase()
-{
- deleteAllObjectStores(db);
-
+ db = event.target.result;
+ event.target.transaction._onabort_ = unexpectedAbortCallback;
os = evalAndLog("db.createObjectStore('tmp')");
evalAndExpectException("db.createObjectStore('tmp')", "IDBDatabaseException.CONSTRAINT_ERR", "'ConstraintError'");
- event.target.result._oncomplete_ = setVersionComplete;
}
function setVersionComplete()
{
trans = evalAndLog("trans = db.transaction(['tmp'])");
request = evalAndLog("trans.objectStore('tmp').get(0)");
- request._onsuccess_ = tryOnceMore;
+ request._onsuccess_ = tryToCreateAndDelete;
request._onerror_ = unexpectedErrorCallback;
}
-function tryOnceMore()
+function tryToCreateAndDelete()
{
shouldBeUndefined("event.target.result");
- testCreateAndRemove();
+ debug("Trying create");
+ evalAndExpectException('db.createObjectStore("some os")', "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
+ debug("Trying remove");
+ evalAndExpectException('db.deleteObjectStore("some os")', "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
debug("Trying create with store that already exists");
evalAndExpectException("db.createObjectStore('tmp')", "DOMException.INVALID_STATE_ERR", "'InvalidStateError'");
@@ -62,5 +38,3 @@
finishJSTest();
}
-
-test();
\ No newline at end of file
Modified: trunk/LayoutTests/storage/indexeddb/resources/database-deletepending-flag.js (134334 => 134335)
--- trunk/LayoutTests/storage/indexeddb/resources/database-deletepending-flag.js 2012-11-13 02:09:35 UTC (rev 134334)
+++ trunk/LayoutTests/storage/indexeddb/resources/database-deletepending-flag.js 2012-11-13 02:09:45 UTC (rev 134335)
@@ -5,7 +5,7 @@
description("Test IndexedDB IDBDatabase internal delete pending flag");
-indexedDBTest(prepareDatabase, testDatabaseDelete, 5);
+indexedDBTest(prepareDatabase, testDatabaseDelete, {"version": 5});
function prepareDatabase()
{
connection = event.target.result;
Modified: trunk/LayoutTests/storage/indexeddb/resources/deletedatabase-delayed-by-open-and-versionchange.js (134334 => 134335)
--- trunk/LayoutTests/storage/indexeddb/resources/deletedatabase-delayed-by-open-and-versionchange.js 2012-11-13 02:09:35 UTC (rev 134334)
+++ trunk/LayoutTests/storage/indexeddb/resources/deletedatabase-delayed-by-open-and-versionchange.js 2012-11-13 02:09:45 UTC (rev 134335)
@@ -5,53 +5,36 @@
description("Test that deleteDatabase is delayed if a VERSION_CHANGE transaction is running");
-function test() {
- removeVendorPrefixes();
- setDBNameFromPath();
- evalAndLog("ver = 1");
+indexedDBTest(prepareDatabase);
+function prepareDatabase()
+{
evalAndLog("versionChangeComplete = false");
+ event.target.transaction._onabort_ = unexpectedAbortCallback;
+ evalAndLog("h = event.target.result");
- request = evalAndLog("indexedDB.open(dbname)");
- request._onblocked_ = unexpectedBlockedCallback;
- request._onerror_ = unexpectedErrorCallback;
- request._onsuccess_ = function openOnSuccess(evt) {
+ h._onversionchange_ = function onVersionChange(evt) {
preamble(evt);
- evalAndLog("h = event.target.result");
+ debug("old = " + JSON.stringify(event.target.version));
+ debug("new = " + JSON.stringify(event.version));
+ };
- h._onversionchange_ = function onVersionChange(evt) {
- preamble(evt);
- debug("old = " + JSON.stringify(event.target.version));
- debug("new = " + JSON.stringify(event.version));
- };
+ transaction = event.target.transaction;
+ transaction._oncomplete_ = function transactionOnComplete(evt) {
+ preamble(evt);
+ evalAndLog("versionChangeComplete = true");
+ };
- request = evalAndLog("h.setVersion(String(ver++))");
- request._onerror_ = unexpectedErrorCallback;
- request._onblocked_ = unexpectedBlockedCallback;
- request._onsuccess_ = function setVersionOnSuccess(evt) {
- preamble(evt);
+ request = evalAndLog("indexedDB.deleteDatabase(dbname)");
+ request._onerror_ = unexpectedErrorCallback;
+ request._onblocked_ = function deleteDatabaseOnBlocked(evt) {
+ preamble(evt);
- transaction = event.target.result;
- transaction._onabort_ = unexpectedAbortCallback;
- transaction._oncomplete_ = function transactionOnComplete(evt) {
- preamble(evt);
- evalAndLog("versionChangeComplete = true");
- };
- };
-
- request = evalAndLog("indexedDB.deleteDatabase(dbname)");
- request._onerror_ = unexpectedErrorCallback;
- request._onblocked_ = function deleteDatabaseOnBlocked(evt) {
- preamble(evt);
-
- evalAndLog("h.close()");
- };
- request._onsuccess_ = function deleteDatabaseOnSuccess(evt) {
- preamble(evt);
- shouldBeTrue("versionChangeComplete");
- finishJSTest();
- };
+ evalAndLog("h.close()");
};
+ request._onsuccess_ = function deleteDatabaseOnSuccess(evt) {
+ preamble(evt);
+ shouldBeTrue("versionChangeComplete");
+ finishJSTest();
+ };
}
-
-test();
Modified: trunk/LayoutTests/storage/indexeddb/resources/duplicates.js (134334 => 134335)
--- trunk/LayoutTests/storage/indexeddb/resources/duplicates.js 2012-11-13 02:09:35 UTC (rev 134334)
+++ trunk/LayoutTests/storage/indexeddb/resources/duplicates.js 2012-11-13 02:09:45 UTC (rev 134335)
@@ -6,34 +6,18 @@
description("Verify that you can put the same data in 2 different databases without uniqueness constraints firing.");
testCount = 0;
+test();
function test()
{
if (testCount++ == 0)
- request = evalAndLog("indexedDB.open('duplicates-1')");
+ indexedDBTest(prepareDatabase, test, {'suffix': '-1'});
else
- request = evalAndLog("indexedDB.open('duplicates-2')");
- request._onsuccess_ = setVersion;
- request._onerror_ = unexpectedErrorCallback;
+ indexedDBTest(prepareDatabase, finishJSTest, {'suffix': '-2'});
}
-
-function setVersion()
+function prepareDatabase()
{
- db = evalAndLog("db = event.target.result");
+ db = event.target.result;
- request = evalAndLog("db.setVersion('new version')");
- request._onsuccess_ = deleteExisting;
- request._onerror_ = unexpectedErrorCallback;
-}
-
-function deleteExisting()
-{
- debug("setVersionSuccess():");
- self.trans = evalAndLog("trans = event.target.result");
- shouldBeNonNull("trans");
- trans._onabort_ = unexpectedAbortCallback;
-
- deleteAllObjectStores(db);
-
self.store = evalAndLog("db.createObjectStore('storeName', null)");
self.indexObject = evalAndLog("store.createIndex('indexName', 'x')");
addData();
@@ -156,11 +140,4 @@
{
shouldBeNull("event.target.result");
- if (testCount == 1)
- test();
- else
- finishJSTest();
}
-
-removeVendorPrefixes();
-test();
\ No newline at end of file
Modified: trunk/LayoutTests/storage/indexeddb/resources/shared.js (134334 => 134335)
--- trunk/LayoutTests/storage/indexeddb/resources/shared.js 2012-11-13 02:09:35 UTC (rev 134334)
+++ trunk/LayoutTests/storage/indexeddb/resources/shared.js 2012-11-13 02:09:45 UTC (rev 134335)
@@ -130,8 +130,11 @@
debug("Deleted all object stores.");
}
-function setDBNameFromPath() {
- evalAndLog('dbname = "' + self.location.pathname.substring(1 + self.location.pathname.lastIndexOf("/")) + '"');
+function setDBNameFromPath(suffix) {
+ var name = self.location.pathname.substring(1 + self.location.pathname.lastIndexOf("/"));
+ if (suffix)
+ name += suffix;
+ evalAndLog('dbname = "' + name + '"');
}
function preamble(evt)
@@ -173,18 +176,22 @@
};
}
-function indexedDBTest(upgradeCallback, optionalOpenCallback, optionalVersion) {
+function indexedDBTest(upgradeCallback, optionalOpenCallback, optionalParameters) {
removeVendorPrefixes();
- setDBNameFromPath();
+ if (optionalParameters && 'suffix' in optionalParameters) {
+ setDBNameFromPath(optionalParameters['suffix']);
+ } else {
+ setDBNameFromPath();
+ }
var deleteRequest = evalAndLog("indexedDB.deleteDatabase(dbname)");
deleteRequest._onerror_ = unexpectedErrorCallback;
deleteRequest._onblocked_ = unexpectedBlockedCallback;
deleteRequest._onsuccess_ = function() {
var openRequest;
- if (optionalVersion)
- openRequest = evalAndLog("indexedDB.open(dbname, " + optionalVersion + ")");
+ if (optionalParameters && 'version' in optionalParameters)
+ openRequest = evalAndLog("indexedDB.open(dbname, " + optionalParameters['version'] + ")");
else
- openRequest = evalAndLog("indexedDB.open(dbname)");
+ openRequest = evalAndLog("indexedDB.open(dbname)");
openRequest._onerror_ = unexpectedErrorCallback;
openRequest._onupgradeneeded_ = upgradeCallback;
openRequest._onblocked_ = unexpectedBlockedCallback;