From 81bc750723a18f21cd17d1b173cd2a4dda9cea6e Mon Sep 17 00:00:00 2001
From: Ben Murdoch Test that a network namespace trumps a fallback namespace where they overlap. Should not crash or cause an assertion failure. A JavaScript failure on the console is expected, however, as the global object is cleared when closing a frame.
It actually helps to cause database activity by throwing an exception from a callback.
diff --git a/LayoutTests/storage/indexeddb/basics-expected.txt b/LayoutTests/storage/indexeddb/basics-expected.txt index cae16d8..fce5423 100644 --- a/LayoutTests/storage/indexeddb/basics-expected.txt +++ b/LayoutTests/storage/indexeddb/basics-expected.txt @@ -5,23 +5,49 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE PASS 'webkitIndexedDB' in window is true PASS webkitIndexedDB == null is false -webkitIndexedDB.open('name') -PASS 'onsuccess' in result is true -PASS 'onerror' in result is true -PASS 'readyState' in result is true -An event should fire shortly... - -Success event fired: -PASS 'result' in event is true -PASS 'code' in event is false -PASS 'message' in event is false -PASS 'source' in event is true -PASS event.source != null is true +PASS 'webkitIDBCursor' in window is true +PASS webkitIDBCursor == null is false +webkitIndexedDB.open('basics') +PASS 'result' in request is true +Expecting exception from request.result +PASS Exception was thrown. +PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR +PASS 'errorCode' in request is true +Expecting exception from request.errorCode +PASS Exception was thrown. +PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR +PASS 'webkitErrorMessage' in request is true +Expecting exception from request.webkitErrorMessage +PASS Exception was thrown. +PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR +PASS 'source' in request is true +PASS request.source is webkitIndexedDB +PASS 'transaction' in request is true +PASS request.transaction is null +PASS 'readyState' in request is true +PASS request.readyState is webkitIDBRequest.LOADING +PASS 'onsuccess' in request is true +PASS request.onsuccess is null +PASS 'onerror' in request is true +PASS request.onerror is null +PASS request.LOADING is 1 +PASS request.DONE is 2 +PASS 'result' in event.target is true +PASS !!event.target.result is true +PASS 'errorCode' in event.target is true +PASS event.target.errorCode is 0 +PASS 'webkitErrorMessage' in event.target is true +PASS event.target.webkitErrorMessage is undefined. +PASS 'source' in event.target is true +PASS request.source is webkitIndexedDB +PASS 'transaction' in event.target is true +PASS event.target.transaction is null +PASS 'readyState' in request is true +PASS event.target.readyState is webkitIDBRequest.DONE PASS 'onsuccess' in event.target is true PASS 'onerror' in event.target is true -PASS 'readyState' in event.target is true -PASS event.target.readyState is event.target.DONE - +PASS event.target.LOADING is 1 +PASS event.target.DONE is 2 PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/storage/indexeddb/basics.html b/LayoutTests/storage/indexeddb/basics.html index 2415070..593046d 100644 --- a/LayoutTests/storage/indexeddb/basics.html +++ b/LayoutTests/storage/indexeddb/basics.html @@ -19,20 +19,53 @@ function test() shouldBeTrue("'webkitIndexedDB' in window"); shouldBeFalse("webkitIndexedDB == null"); - // FIXME: Verify other IndexedDatabaseRequest constructors, once they're implemented. - - result = evalAndLog("webkitIndexedDB.open('name')"); - verifyResult(result); - result.onsuccess = openCallback; - result.onerror = unexpectedErrorCallback; -} - -function openCallback() -{ - verifySuccessEvent(event); - done(); + shouldBeTrue("'webkitIDBCursor' in window"); + shouldBeFalse("webkitIDBCursor == null"); + + request = evalAndLog("webkitIndexedDB.open('basics')"); + shouldBeTrue("'result' in request"); + evalAndExpectException("request.result", "webkitIDBDatabaseException.NOT_ALLOWED_ERR"); + shouldBeTrue("'errorCode' in request"); + evalAndExpectException("request.errorCode", "webkitIDBDatabaseException.NOT_ALLOWED_ERR"); + shouldBeTrue("'webkitErrorMessage' in request"); + evalAndExpectException("request.webkitErrorMessage", "webkitIDBDatabaseException.NOT_ALLOWED_ERR"); + shouldBeTrue("'source' in request"); + shouldBe("request.source", "webkitIndexedDB"); + shouldBeTrue("'transaction' in request"); + shouldBeNull("request.transaction"); + shouldBeTrue("'readyState' in request"); + shouldBe("request.readyState", "webkitIDBRequest.LOADING"); + shouldBeTrue("'onsuccess' in request"); + shouldBeNull("request.onsuccess"); + shouldBeTrue("'onerror' in request"); + shouldBeNull("request.onerror"); + shouldBe("request.LOADING", "1"); + shouldBe("request.DONE", "2"); + request.onsuccess = openCallback; + request.onerror = unexpectedErrorCallback; } +function openCallback() +{ + shouldBeTrue("'result' in event.target"); + shouldBeTrue("!!event.target.result"); + shouldBeTrue("'errorCode' in event.target"); + shouldBe("event.target.errorCode", "0"); + shouldBeTrue("'webkitErrorMessage' in event.target"); + shouldBeUndefined("event.target.webkitErrorMessage"); + shouldBeTrue("'source' in event.target"); + shouldBe("request.source", "webkitIndexedDB"); + shouldBeTrue("'transaction' in event.target"); + shouldBeNull("event.target.transaction"); + shouldBeTrue("'readyState' in request"); + shouldBe("event.target.readyState", "webkitIDBRequest.DONE"); + shouldBeTrue("'onsuccess' in event.target"); + shouldBeTrue("'onerror' in event.target"); + shouldBe("event.target.LOADING", "1"); + shouldBe("event.target.DONE", "2"); + + done(); +} test(); diff --git a/LayoutTests/storage/indexeddb/create-and-remove-object-store-expected.txt b/LayoutTests/storage/indexeddb/create-and-remove-object-store-expected.txt index 21f7d8d..528ba89 100644 --- a/LayoutTests/storage/indexeddb/create-and-remove-object-store-expected.txt +++ b/LayoutTests/storage/indexeddb/create-and-remove-object-store-expected.txt @@ -3,68 +3,41 @@ Test IndexedDB's create and removeObjectStore On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". -PASS 'webkitIndexedDB' in window is true -PASS webkitIndexedDB == null is false -webkitIndexedDB.open('name') -PASS 'onsuccess' in result is true -PASS 'onerror' in result is true -PASS 'readyState' in result is true -An event should fire shortly... - +webkitIndexedDB.open('create-and-remove-object-store') openSuccess(): -Success event fired: -PASS 'result' in event is true -PASS 'code' in event is false -PASS 'message' in event is false -PASS 'source' in event is true -PASS event.source != null is true -PASS 'onsuccess' in event.target is true -PASS 'onerror' in event.target is true -PASS 'readyState' in event.target is true -PASS event.target.readyState is event.target.DONE - -db = event.result +db = event.target.result Trying create +Expecting exception from db.createObjectStore("some os") +PASS Exception was thrown. PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR Trying remove +Expecting exception from db.createObjectStore("some os") +PASS Exception was thrown. PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR result = db.setVersion('version 1') Trying create +Expecting exception from db.createObjectStore("some os") +PASS Exception was thrown. PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR Trying remove +Expecting exception from db.createObjectStore("some os") +PASS Exception was thrown. PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR -Success event fired: -PASS 'result' in event is true -PASS 'code' in event is false -PASS 'message' in event is false -PASS 'source' in event is true -PASS event.source != null is true -PASS 'onsuccess' in event.target is true -PASS 'onerror' in event.target is true -PASS 'readyState' in event.target is true -PASS event.target.readyState is event.target.DONE - Deleted all object stores. db.createObjectStore('tmp') -Adding 'tmp' again +Expecting exception from db.createObjectStore('tmp') +PASS Exception was thrown. PASS code is webkitIDBDatabaseException.CONSTRAINT_ERR trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE}) trans.objectStore('tmp').get(0) -Success event fired: -PASS 'result' in event is true -PASS 'code' in event is false -PASS 'message' in event is false -PASS 'source' in event is true -PASS event.source != null is true -PASS 'onsuccess' in event.target is true -PASS 'onerror' in event.target is true -PASS 'readyState' in event.target is true -PASS event.target.readyState is event.target.DONE - -PASS event.result is undefined +PASS event.target.result is undefined. Trying create +Expecting exception from db.createObjectStore("some os") +PASS Exception was thrown. PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR Trying remove +Expecting exception from db.createObjectStore("some os") +PASS Exception was thrown. PASS code is webkitIDBDatabaseException.NOT_ALLOWED_ERR PASS successfullyParsed is true diff --git a/LayoutTests/storage/indexeddb/create-and-remove-object-store.html b/LayoutTests/storage/indexeddb/create-and-remove-object-store.html index 7bde468..43c1fe1 100644 --- a/LayoutTests/storage/indexeddb/create-and-remove-object-store.html +++ b/LayoutTests/storage/indexeddb/create-and-remove-object-store.html @@ -16,74 +16,46 @@ if (window.layoutTestController) function test() { - shouldBeTrue("'webkitIndexedDB' in window"); - shouldBeFalse("webkitIndexedDB == null"); - - result = evalAndLog("webkitIndexedDB.open('name')"); - verifyResult(result); - result.onsuccess = openSuccess; - result.onerror = unexpectedErrorCallback; + request = evalAndLog("webkitIndexedDB.open('create-and-remove-object-store')"); + request.onsuccess = openSuccess; + request.onerror = unexpectedErrorCallback; } function openSuccess() { debug("openSuccess():"); - verifySuccessEvent(event); - window.db = evalAndLog("db = event.result"); + window.db = evalAndLog("db = event.target.result"); testCreateAndRemove(); - result = evalAndLog("result = db.setVersion('version 1')"); - result.onsuccess = cleanDatabase; - result.onerror = unexpectedErrorCallback; + request = evalAndLog("result = db.setVersion('version 1')"); + request.onsuccess = cleanDatabase; + request.onerror = unexpectedErrorCallback; testCreateAndRemove(); } function testCreateAndRemove() { debug("Trying create"); - try { - db.createObjectStore("some os"); - testFailed("No exception thrown!"); - } catch (e) { - code = e.code; - shouldBe("code", "webkitIDBDatabaseException.NOT_ALLOWED_ERR"); - } + evalAndExpectException('db.createObjectStore("some os")', "webkitIDBDatabaseException.NOT_ALLOWED_ERR"); debug("Trying remove"); - try { - db.createObjectStore("some os"); - testFailed("No exception thrown!"); - } catch (e) { - code = e.code; - shouldBe("code", "webkitIDBDatabaseException.NOT_ALLOWED_ERR"); - } + evalAndExpectException('db.createObjectStore("some os")', "webkitIDBDatabaseException.NOT_ALLOWED_ERR"); } function cleanDatabase() { - verifySuccessEvent(event); - deleteAllObjectStores(db, cleaned); -} + deleteAllObjectStores(db); -function cleaned() -{ os = evalAndLog("db.createObjectStore('tmp')"); - debug("Adding 'tmp' again"); - try { - db.createObjectStore('tmp'); - testFailed("No exception thrown!"); - } catch (e) { - code = e.code; - shouldBe("code", "webkitIDBDatabaseException.CONSTRAINT_ERR"); - } + evalAndExpectException("db.createObjectStore('tmp')", "webkitIDBDatabaseException.CONSTRAINT_ERR"); + trans = evalAndLog("trans = db.transaction({mode: webkitIDBTransaction.READ_WRITE})"); - req = evalAndLog("trans.objectStore('tmp').get(0)"); - req.onsuccess = tryOnceMore; - req.onerror = unexpectedErrorCallback; + request = evalAndLog("trans.objectStore('tmp').get(0)"); + request.onsuccess = tryOnceMore; + request.onerror = unexpectedErrorCallback; } function tryOnceMore() { - verifySuccessEvent(event); - shouldBe("event.result", "undefined"); + shouldBeUndefined("event.target.result"); testCreateAndRemove(); diff --git a/LayoutTests/storage/indexeddb/create-object-store-options-expected.txt b/LayoutTests/storage/indexeddb/create-object-store-options-expected.txt index 5519508..5f0e94d 100644 --- a/LayoutTests/storage/indexeddb/create-object-store-options-expected.txt +++ b/LayoutTests/storage/indexeddb/create-object-store-options-expected.txt @@ -5,14 +5,9 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE PASS 'webkitIndexedDB' in window is true PASS webkitIndexedDB == null is false -webkitIndexedDB.open('name', 'description') -PASS 'onsuccess' in result is true -PASS 'onerror' in result is true -PASS 'readyState' in result is true -An event should fire shortly... - -db = event.result -result = db.setVersion('version 1') +webkitIndexedDB.open('create-object-store-options', 'description') +db = event.target.result +request = db.setVersion('version 1') Deleted all object stores. db.createObjectStore('a', {keyPath: 'a'}) db.createObjectStore('b') @@ -22,9 +17,9 @@ PASS trans.mode is webkitIDBTransaction.READ_WRITE trans.objectStore('a').put({'a': 0}) trans.objectStore('b').put({'a': 0}, 0) trans.objectStore('a').get(0) -PASS event.result.a is {a: 0} +PASS event.target.result.a is {a: 0} trans.objectStore('b').get(0) -PASS event.result.a is {a: 0} +PASS event.target.result.a is {a: 0} PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/storage/indexeddb/create-object-store-options.html b/LayoutTests/storage/indexeddb/create-object-store-options.html index 6709e58..bf600d7 100644 --- a/LayoutTests/storage/indexeddb/create-object-store-options.html +++ b/LayoutTests/storage/indexeddb/create-object-store-options.html @@ -19,28 +19,24 @@ function test() shouldBeTrue("'webkitIndexedDB' in window"); shouldBeFalse("webkitIndexedDB == null"); - result = evalAndLog("webkitIndexedDB.open('name', 'description')"); - verifyResult(result); - result.onsuccess = openSuccess; - result.onerror = unexpectedErrorCallback; + request = evalAndLog("webkitIndexedDB.open('create-object-store-options', 'description')"); + request.onsuccess = openSuccess; + request.onerror = unexpectedErrorCallback; } function openSuccess() { - db = evalAndLog("db = event.result"); + db = evalAndLog("db = event.target.result"); - result = evalAndLog("result = db.setVersion('version 1')"); - result.onsuccess = cleanDatabase; - result.onerror = unexpectedErrorCallback; + request = evalAndLog("request = db.setVersion('version 1')"); + request.onsuccess = cleanDatabase; + request.onerror = unexpectedErrorCallback; } function cleanDatabase() { - deleteAllObjectStores(db, cleaned); -} + deleteAllObjectStores(db); -function cleaned() -{ evalAndLog("db.createObjectStore('a', {keyPath: 'a'})"); evalAndLog("db.createObjectStore('b')"); @@ -71,7 +67,7 @@ function getA() function getB() { - shouldBe("event.result.a", "{a: 0}"); + shouldBe("event.target.result.a", "{a: 0}"); req = evalAndLog("trans.objectStore('b').get(0)"); req.onsuccess = checkB; @@ -80,7 +76,7 @@ function getB() function checkB() { - shouldBe("event.result.a", "{a: 0}"); + shouldBe("event.target.result.a", "{a: 0}"); done(); } diff --git a/LayoutTests/storage/indexeddb/cursor-continue-expected.txt b/LayoutTests/storage/indexeddb/cursor-continue-expected.txt new file mode 100644 index 0000000..80a338c --- /dev/null +++ b/LayoutTests/storage/indexeddb/cursor-continue-expected.txt @@ -0,0 +1,79 @@ +Test IndexedDB's IDBCursor.continue() with a key parameter. + +On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". + + +webkitIndexedDB.open('cursor-continue') +db = event.target.result +db.setVersion('new version') +trans = event.target.result +PASS trans !== null is true +Deleted all object stores. +db.createObjectStore('someObjectStore') +objectStore.createIndex('someIndex', 'x') +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) +objectStore.add({'x': testData[nextToAdd]}, nextToAdd) + +indexObject.openKeyCursor(null, webkitIDBCursor.NEXT) +PASS event.target.result.primaryKey is 0 +event.target.result.continue(3.14159) +PASS event.target.result.primaryKey is 3 +event.target.result.continue(3.14159) +PASS event.target.result.primaryKey is 4 +event.target.result.continue(3.14159) +PASS event.target.result.primaryKey is 5 +event.target.result.continue(12) +PASS event.target.result.primaryKey is 7 +event.target.result.continue(date) +PASS event.target.result.primaryKey is 9 +event.target.result.continue(date) +PASS event.target.result.primaryKey is 10 +event.target.result.continue(date) +PASS event.target.result.primaryKey is 11 +event.target.result.continue('A bit1') +PASS event.target.result.primaryKey is 14 +event.target.result.continue('A bit3') +PASS event.target.result.primaryKey is 16 +event.target.result.continue('the BIGGEST string') +PASS event.target.result.primaryKey is 17 +event.target.result.continue('the BIGGEST string') +PASS event.target.result is null + +indexObject.openKeyCursor(null, webkitIDBCursor.PREV) +PASS event.target.result.primaryKey is 17 +event.target.result.continue('A bit2') +PASS event.target.result.primaryKey is 15 +event.target.result.continue('A bit2') +PASS event.target.result.primaryKey is 14 +event.target.result.continue(date) +PASS event.target.result.primaryKey is 10 +event.target.result.continue(date) +PASS event.target.result.primaryKey is 9 +event.target.result.continue(1) +PASS event.target.result.primaryKey is 2 +event.target.result.continue(1) +PASS event.target.result.primaryKey is 1 +event.target.result.continue(1) +PASS event.target.result.primaryKey is 0 +event.target.result.continue(1) +PASS event.target.result is null +PASS successfullyParsed is true + +TEST COMPLETE + diff --git a/LayoutTests/storage/indexeddb/cursor-continue.html b/LayoutTests/storage/indexeddb/cursor-continue.html new file mode 100644 index 0000000..ce4d436 --- /dev/null +++ b/LayoutTests/storage/indexeddb/cursor-continue.html @@ -0,0 +1,183 @@ + +
+ + + + + +
+