diff options
Diffstat (limited to 'LayoutTests/storage')
17 files changed, 558 insertions, 396 deletions
diff --git a/LayoutTests/storage/indexeddb/basics.html b/LayoutTests/storage/indexeddb/basics.html index 24af453..9f5f20f 100644 --- a/LayoutTests/storage/indexeddb/basics.html +++ b/LayoutTests/storage/indexeddb/basics.html @@ -8,6 +8,35 @@ <body> <p id="description"></p> <div id="console"></div> -<script src="script-tests/basics.js"></script> +<script> + +description("Test IndexedDB's basics."); +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +function openCallback() +{ + verifySuccessEvent(event); + done(); +} + +function test() +{ + shouldBeTrue("'indexedDB' in window"); + shouldBeFalse("indexedDB == null"); + + // FIXME: Verify other IndexedDatabaseRequest constructors, once they're implemented. + + result = evalAndLog("indexedDB.open('name', 'description')"); + verifyResult(result); + result.onsuccess = openCallback; + result.onerror = unexpectedErrorCallback; +} + +test(); + +var successfullyParsed = true; + +</script> </body> </html> diff --git a/LayoutTests/storage/indexeddb/database-basics-expected.txt b/LayoutTests/storage/indexeddb/database-basics-expected.txt index 1321f4d..fc224cc 100644 --- a/LayoutTests/storage/indexeddb/database-basics-expected.txt +++ b/LayoutTests/storage/indexeddb/database-basics-expected.txt @@ -23,11 +23,6 @@ PASS 'readyState' in event.target is true PASS event.target.readyState is event.target.DONE db = event.result -PASS db.name is "name" -PASS db.objectStores is [] -PASS db.objectStores.length is 0 -PASS db.objectStores.contains('') is false - Testing setVersion. db.setVersion("version a") PASS 'onsuccess' in result is true @@ -36,6 +31,18 @@ PASS 'abort' 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 'onsuccess' in event.target is true +PASS 'onerror' in event.target is true +PASS 'abort' in event.target is true +PASS 'readyState' in event.target is true +PASS event.target.readyState is event.target.DONE + db.setVersion("version b") PASS 'onsuccess' in result is true PASS 'onerror' in result is true @@ -43,8 +50,47 @@ PASS 'abort' 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 'onsuccess' in event.target is true +PASS 'onerror' in event.target is true +PASS 'abort' in event.target is true +PASS 'readyState' in event.target is true +PASS event.target.readyState is event.target.DONE + PASS db.version is "version b" +PASS db.name is "name" +PASS db.objectStores is [] +PASS db.objectStores.length is 0 +PASS db.objectStores.contains('') is false +db.createObjectStore("test123") +PASS 'onsuccess' in result is true +PASS 'onerror' in result is true +PASS 'abort' 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 'onsuccess' in event.target is true +PASS 'onerror' in event.target is true +PASS 'abort' in event.target is true +PASS 'readyState' in event.target is true +PASS event.target.readyState is event.target.DONE + +PASS db.objectStores is ['test123'] +PASS db.objectStores.length is 1 +PASS db.objectStores.contains('') is false +PASS db.objectStores.contains('test456') is false +PASS db.objectStores.contains('test123') is true PASS successfullyParsed is true TEST COMPLETE - diff --git a/LayoutTests/storage/indexeddb/database-basics.html b/LayoutTests/storage/indexeddb/database-basics.html index 9c92194..b099a49 100644 --- a/LayoutTests/storage/indexeddb/database-basics.html +++ b/LayoutTests/storage/indexeddb/database-basics.html @@ -8,6 +8,80 @@ <body> <p id="description"></p> <div id="console"></div> -<script src="script-tests/database-basics.js"></script> +<script> + +description("Test the basics of IndexedDB's IDBDatabase."); +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +function openSuccess() +{ + verifySuccessEvent(event); + + var db = evalAndLog("db = event.result"); + deleteAllObjectStores(db); + + // We must do something asynchronous before anything synchronous since + // deleteAllObjectStores only schedules the object stores to be removed. + // We don't know for sure whether it's happened until an IDBRequest object + // that was created after the removes fires. + + debug("Testing setVersion."); + result = evalAndLog('db.setVersion("version a")'); + verifyResult(result); + result.onsuccess = setVersionAgain; + result.onError = unexpectedErrorCallback; +} + +function setVersionAgain() +{ + verifySuccessEvent(event); + + result = evalAndLog('db.setVersion("version b")'); + verifyResult(result); + result.onsuccess = createObjectStore; + result.onError = unexpectedErrorCallback; +} + +function createObjectStore() +{ + verifySuccessEvent(event); + shouldBeEqualToString("db.version", "version b"); + shouldBeEqualToString("db.name", "name"); + shouldBe("db.objectStores", "[]"); + shouldBe("db.objectStores.length", "0"); + shouldBe("db.objectStores.contains('')", "false"); + + result = evalAndLog('db.createObjectStore("test123")'); + verifyResult(result); + result.onsuccess = checkObjectStore; + result.onError = unexpectedErrorCallback; +} + +function checkObjectStore() +{ + verifySuccessEvent(event); + shouldBe("db.objectStores", "['test123']"); + shouldBe("db.objectStores.length", "1"); + shouldBe("db.objectStores.contains('')", "false"); + shouldBe("db.objectStores.contains('test456')", "false"); + shouldBe("db.objectStores.contains('test123')", "true"); + + done(); +} + +function test() +{ + result = evalAndLog("indexedDB.open('name', 'description')"); + verifyResult(result); + result.onsuccess = openSuccess; + result.onerror = unexpectedErrorCallback; +} + +test(); + +var successfullyParsed = true; + +</script> </body> </html> diff --git a/LayoutTests/storage/indexeddb/keyrange-expected.txt b/LayoutTests/storage/indexeddb/keyrange-expected.txt index a510a80..6528a11 100644 --- a/LayoutTests/storage/indexeddb/keyrange-expected.txt +++ b/LayoutTests/storage/indexeddb/keyrange-expected.txt @@ -3,6 +3,33 @@ Test IndexedDB's KeyRange. On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". +PASS 'SINGLE' in IDBKeyRange is true +PASS 'LEFT_OPEN' in IDBKeyRange is true +PASS 'RIGHT_OPEN' in IDBKeyRange is true +PASS 'LEFT_BOUND' in IDBKeyRange is true +PASS 'RIGHT_BOUND' in IDBKeyRange is true +PASS 'left' in IDBKeyRange is false +PASS 'right' in IDBKeyRange is false +PASS 'flags' in IDBKeyRange is false +PASS 'only' in IDBKeyRange is true +PASS 'leftBound' in IDBKeyRange is true +PASS 'rightBound' in IDBKeyRange is true +PASS 'bound' in IDBKeyRange is true + +instance = IDBKeyRange.only(1) +PASS 'SINGLE' in instance is true +PASS 'LEFT_OPEN' in instance is true +PASS 'RIGHT_OPEN' in instance is true +PASS 'LEFT_BOUND' in instance is true +PASS 'RIGHT_BOUND' in instance is true +PASS 'left' in instance is true +PASS 'right' in instance is true +PASS 'flags' in instance is true +PASS 'only' in instance is false +PASS 'leftBound' in instance is false +PASS 'rightBound' in instance is false +PASS 'bound' in instance is false + IDBKeyRange.only(1) PASS keyRange.left is 1 PASS keyRange.right is 1 @@ -117,3 +144,4 @@ PASS rightFlags is keyRange.RIGHT_OPEN | keyRange.RIGHT_BOUND PASS successfullyParsed is true TEST COMPLETE + diff --git a/LayoutTests/storage/indexeddb/keyrange.html b/LayoutTests/storage/indexeddb/keyrange.html index d4ef58e..d60cb15 100644 --- a/LayoutTests/storage/indexeddb/keyrange.html +++ b/LayoutTests/storage/indexeddb/keyrange.html @@ -8,6 +8,117 @@ <body> <p id="description"></p> <div id="console"></div> -<script src="script-tests/keyrange.js"></script> +<script> + +description("Test IndexedDB's KeyRange."); +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +function checkSingleKeyRange(value) +{ + keyRange = evalAndLog("IDBKeyRange.only(" + value + ")"); + shouldBe("keyRange.left", "" + value); + shouldBe("keyRange.right", "" + value); + shouldBe("keyRange.flags", "keyRange.SINGLE"); +} + +function checkLeftBoundKeyRange(value, open) +{ + keyRange = evalAndLog("IDBKeyRange.leftBound(" + value + "," + open + ")"); + shouldBe("keyRange.left", "" + value); + shouldBeNull("keyRange.right"); + shouldBe("keyRange.flags", open ? "keyRange.LEFT_OPEN | keyRange.LEFT_BOUND" : "keyRange.LEFT_BOUND"); +} + +function checkRightBoundKeyRange(value, open) +{ + keyRange = evalAndLog("IDBKeyRange.rightBound(" + value + "," + open + ")"); + shouldBe("keyRange.right", "" + value); + shouldBeNull("keyRange.left"); + shouldBe("keyRange.flags", open ? "keyRange.RIGHT_OPEN | keyRange.RIGHT_BOUND" : "keyRange.RIGHT_BOUND"); +} + +function checkBoundKeyRange(left, right, openLeft, openRight) +{ + keyRange = evalAndLog("IDBKeyRange.bound(" + left + "," + right + "," + openLeft + "," + openRight + ")"); + shouldBe("keyRange.left", "" + left); + shouldBe("keyRange.right", "" + right); + leftFlags = keyRange.flags & (keyRange.LEFT_OPEN | keyRange.LEFT_BOUND); + shouldBe("leftFlags", openLeft ? "keyRange.LEFT_OPEN | keyRange.LEFT_BOUND" : "keyRange.LEFT_BOUND"); + rightFlags = keyRange.flags & (keyRange.RIGHT_OPEN | keyRange.RIGHT_BOUND); + shouldBe("rightFlags", openRight ? "keyRange.RIGHT_OPEN | keyRange.RIGHT_BOUND" : "keyRange.RIGHT_BOUND"); +} + +function test() +{ + shouldBeTrue("'SINGLE' in IDBKeyRange"); + shouldBeTrue("'LEFT_OPEN' in IDBKeyRange"); + shouldBeTrue("'RIGHT_OPEN' in IDBKeyRange"); + shouldBeTrue("'LEFT_BOUND' in IDBKeyRange"); + shouldBeTrue("'RIGHT_BOUND' in IDBKeyRange"); + shouldBeFalse("'left' in IDBKeyRange"); + shouldBeFalse("'right' in IDBKeyRange"); + shouldBeFalse("'flags' in IDBKeyRange"); + shouldBeTrue("'only' in IDBKeyRange"); + shouldBeTrue("'leftBound' in IDBKeyRange"); + shouldBeTrue("'rightBound' in IDBKeyRange"); + shouldBeTrue("'bound' in IDBKeyRange"); + + debug(""); + + var instance = evalAndLog("instance = IDBKeyRange.only(1)"); + shouldBeTrue("'SINGLE' in instance"); + shouldBeTrue("'LEFT_OPEN' in instance"); + shouldBeTrue("'RIGHT_OPEN' in instance"); + shouldBeTrue("'LEFT_BOUND' in instance"); + shouldBeTrue("'RIGHT_BOUND' in instance"); + shouldBeTrue("'left' in instance"); + shouldBeTrue("'right' in instance"); + shouldBeTrue("'flags' in instance"); + shouldBeFalse("'only' in instance"); + shouldBeFalse("'leftBound' in instance"); + shouldBeFalse("'rightBound' in instance"); + shouldBeFalse("'bound' in instance"); + + debug(""); + + checkSingleKeyRange(1); + checkSingleKeyRange("'a'"); + + checkLeftBoundKeyRange(10, true); + checkLeftBoundKeyRange(11, false); + checkLeftBoundKeyRange(12); + checkLeftBoundKeyRange("'aa'", true); + checkLeftBoundKeyRange("'ab'", false); + checkLeftBoundKeyRange("'ac'"); + + checkRightBoundKeyRange(20, true); + checkRightBoundKeyRange(21, false); + checkRightBoundKeyRange(22); + checkRightBoundKeyRange("'ba'", true); + checkRightBoundKeyRange("'bb'", false); + checkRightBoundKeyRange("'bc'"); + + checkBoundKeyRange(30, 40); + checkBoundKeyRange(31, 41, false, false); + checkBoundKeyRange(32, 42, false, true); + checkBoundKeyRange(33, 43, true, false); + checkBoundKeyRange(34, 44, true, true); + + checkBoundKeyRange("'aaa'", "'aba'", false, false); + checkBoundKeyRange("'aab'", "'abb'"); + checkBoundKeyRange("'aac'", "'abc'", false, false); + checkBoundKeyRange("'aad'", "'abd'", false, true); + checkBoundKeyRange("'aae'", "'abe'", true, false); + checkBoundKeyRange("'aaf'", "'abf'", true, true); + +} + +test(); + +var successfullyParsed = true; +done(); + +</script> </body> </html> diff --git a/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt b/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt index 105058d..a60e857 100644 --- a/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt +++ b/LayoutTests/storage/indexeddb/objectstore-basics-expected.txt @@ -50,7 +50,28 @@ PASS store.name is "storeName" PASS store.keyPath is null PASS storeNames.contains('storeName') is true PASS storeNames.length is 1 -store.add('value', 'key') +event.result.createIndex('indexName', 'x') +PASS 'onsuccess' in result is true +PASS 'onerror' in result is true +PASS 'abort' in result is true +PASS 'readyState' in result is true +An event should fire shortly... + +addIndexSuccess(): +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 'abort' in event.target is true +PASS 'readyState' in event.target is true +PASS event.target.readyState is event.target.DONE + +PASS event.source.indexNames.contains('indexName') is true +event.source.add({x: 'value'}, 'key') PASS 'onsuccess' in result is true PASS 'onerror' in result is true PASS 'abort' in result is true @@ -92,7 +113,7 @@ PASS 'abort' in event.target is true PASS 'readyState' in event.target is true PASS event.target.readyState is event.target.DONE -PASS event.result is "value" +PASS event.result.x is "value" store = event.source store.remove('key') PASS 'onsuccess' in result is true @@ -118,3 +139,4 @@ PASS event.result is null PASS successfullyParsed is true TEST COMPLETE + diff --git a/LayoutTests/storage/indexeddb/objectstore-basics.html b/LayoutTests/storage/indexeddb/objectstore-basics.html index 09eb68c..8b696c4 100644 --- a/LayoutTests/storage/indexeddb/objectstore-basics.html +++ b/LayoutTests/storage/indexeddb/objectstore-basics.html @@ -8,6 +8,103 @@ <body> <p id="description"></p> <div id="console"></div> -<script src="script-tests/objectstore-basics.js"></script> +<script> + +description("Test the basics of IndexedDB's IDBObjectStore."); +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +function test() +{ + result = evalAndLog("indexedDB.open('name', 'description')"); + verifyResult(result); + result.onsuccess = openSuccess; + result.onerror = unexpectedErrorCallback; +} + +function openSuccess() +{ + debug("openSuccess():"); + verifySuccessEvent(event); + db = evalAndLog("db = event.result"); + + deleteAllObjectStores(db); + + result = evalAndLog("db.createObjectStore('storeName', null)"); + verifyResult(result); + result.onsuccess = createSuccess; + result.onerror = unexpectedErrorCallback; +} + +function createSuccess() +{ + debug("createSuccess():"); + verifySuccessEvent(event); + var store = evalAndLog("store = event.result"); + var storeNames = evalAndLog("storeNames = db.objectStores"); + + shouldBeEqualToString("store.name", "storeName"); + shouldBeNull("store.keyPath"); + shouldBe("storeNames.contains('storeName')", "true"); + shouldBe("storeNames.length", "1"); + // FIXME: test all of object store's methods. + + result = evalAndLog("event.result.createIndex('indexName', 'x')"); + verifyResult(result); + result.onsuccess = addIndexSuccess; + result.onerror = unexpectedErrorCallback; +} + +function addIndexSuccess() +{ + debug("addIndexSuccess():"); + verifySuccessEvent(event); + shouldBeTrue("event.source.indexNames.contains('indexName')"); + + result = evalAndLog("event.source.add({x: 'value'}, 'key')"); + verifyResult(result); + result.onsuccess = addSuccess; + result.onerror = unexpectedErrorCallback; +} + +function addSuccess() +{ + debug("addSuccess():"); + verifySuccessEvent(event); + shouldBeEqualToString("event.result", "key"); + var store = evalAndLog("store = event.source"); + + result = evalAndLog("store.get('key')"); + verifyResult(result); + result.onsuccess = getSuccess; + result.onerror = unexpectedErrorCallback; +} + +function getSuccess() +{ + debug("getSuccess():"); + verifySuccessEvent(event); + shouldBeEqualToString("event.result.x", "value"); + var store = evalAndLog("store = event.source"); + + result = evalAndLog("store.remove('key')"); + verifyResult(result); + result.onsuccess = removeSuccess; + result.onerror = unexpectedErrorCallback; +} + +function removeSuccess() +{ + debug("removeSuccess():"); + verifySuccessEvent(event); + shouldBeNull("event.result"); + done(); +} + +test(); + +var successfullyParsed = true; + +</script> </body> </html> diff --git a/LayoutTests/storage/indexeddb/objectstore-cursor.html b/LayoutTests/storage/indexeddb/objectstore-cursor.html index bc69b43..25e9456 100644 --- a/LayoutTests/storage/indexeddb/objectstore-cursor.html +++ b/LayoutTests/storage/indexeddb/objectstore-cursor.html @@ -195,10 +195,7 @@ function cursorIteration() window.expectedIndex = ascending ? expectedIndex+1 : expectedIndex-1; testWithinBounds(); - request = event.result.continue(); - // FIXME: The spec says we should not return an IDBRequest and instead re-use the original request. - request.onsuccess = cursorIteration; - request.onerror = unexpectedErrorCallback; + event.result.continue(); } openDatabase(); // The first step. diff --git a/LayoutTests/storage/indexeddb/open-cursor.html b/LayoutTests/storage/indexeddb/open-cursor.html index f60365d..03d1da0 100644 --- a/LayoutTests/storage/indexeddb/open-cursor.html +++ b/LayoutTests/storage/indexeddb/open-cursor.html @@ -8,6 +8,92 @@ <body> <p id="description"></p> <div id="console"></div> -<script src="script-tests/open-cursor.js"></script> +<script> + +description("Test IndexedDB's openCursor."); +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +function emptyCursorSuccess() +{ + debug("Empty cursor opened successfully.") + verifySuccessEvent(event); + // FIXME: check that we can iterate the cursor. + done(); +} + +function openEmptyCursor() +{ + debug("Opening an empty cursor."); + keyRange = IDBKeyRange.leftBound("InexistentKey"); + result = evalAndLog("objectStore.openCursor(keyRange)"); + verifyResult(result); + result.onsuccess = emptyCursorSuccess; + result.onerror = unexpectedErrorCallback; +} + +function cursorSuccess() +{ + debug("Cursor opened successfully.") + verifySuccessEvent(event); + // FIXME: check that we can iterate the cursor. + shouldBe("event.result.direction", "0"); + shouldBe("event.result.key", "'myKey'"); + shouldBe("event.result.value", "'myValue'"); + debug(""); + openEmptyCursor(); +} + +function openCursor() +{ + debug("Opening cursor"); + keyRange = IDBKeyRange.leftBound("myKey"); + result = evalAndLog("objectStore.openCursor(keyRange)"); + verifyResult(result); + result.onsuccess = cursorSuccess; + result.onerror = unexpectedErrorCallback; +} + +function populateObjectStore(objectStore) +{ + result = evalAndLog("objectStore.add('myValue', 'myKey')"); + verifyResult(result); + result.onsuccess = openCursor; + result.onerror = unexpectedErrorCallback; +} + +function createObjectStoreSuccess() +{ + verifySuccessEvent(event); + var objectStore = evalAndLog("objectStore = event.result"); + populateObjectStore(objectStore); +} + +function openSuccess() +{ + verifySuccessEvent(event); + var db = evalAndLog("db = event.result"); + + deleteAllObjectStores(db); + + result = evalAndLog("db.createObjectStore('test')"); + verifyResult(result); + result.onsuccess = createObjectStoreSuccess; + result.onerror = unexpectedErrorCallback; +} + +function test() +{ + result = evalAndLog("indexedDB.open('name', 'description')"); + verifyResult(result); + result.onsuccess = openSuccess; + result.onerror = unexpectedErrorCallback; +} + +test(); + +var successfullyParsed = true; + +</script> </body> </html> diff --git a/LayoutTests/storage/indexeddb/script-tests/TEMPLATE.html b/LayoutTests/storage/indexeddb/script-tests/TEMPLATE.html deleted file mode 100644 index 865fadb..0000000 --- a/LayoutTests/storage/indexeddb/script-tests/TEMPLATE.html +++ /dev/null @@ -1,13 +0,0 @@ -<html> -<head> -<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css"> -<script src="../../fast/js/resources/js-test-pre.js"></script> -<script src="../../fast/js/resources/js-test-post-function.js"></script> -<script src="resources/shared.js"></script> -</head> -<body> -<p id="description"></p> -<div id="console"></div> -<script src="YOUR_JS_FILE_HERE"></script> -</body> -</html> diff --git a/LayoutTests/storage/indexeddb/script-tests/basics.js b/LayoutTests/storage/indexeddb/script-tests/basics.js deleted file mode 100644 index cebd48f..0000000 --- a/LayoutTests/storage/indexeddb/script-tests/basics.js +++ /dev/null @@ -1,26 +0,0 @@ -description("Test IndexedDB's basics."); -if (window.layoutTestController) - layoutTestController.waitUntilDone(); - -function openCallback() -{ - verifySuccessEvent(event); - done(); -} - -function test() -{ - shouldBeTrue("'indexedDB' in window"); - shouldBeFalse("indexedDB == null"); - - // FIXME: Verify other IndexedDatabaseRequest constructors, once they're implemented. - - result = evalAndLog("indexedDB.open('name', 'description')"); - verifyResult(result); - result.onsuccess = openCallback; - result.onerror = unexpectedErrorCallback; -} - -test(); - -var successfullyParsed = true; diff --git a/LayoutTests/storage/indexeddb/script-tests/database-basics.js b/LayoutTests/storage/indexeddb/script-tests/database-basics.js deleted file mode 100644 index 04ebbd3..0000000 --- a/LayoutTests/storage/indexeddb/script-tests/database-basics.js +++ /dev/null @@ -1,51 +0,0 @@ -description("Test the basics of IndexedDB's IDBDatabase."); -if (window.layoutTestController) - layoutTestController.waitUntilDone(); - -function openSuccess() -{ - verifySuccessEvent(event); - - var db = evalAndLog("db = event.result"); - shouldBeEqualToString("db.name", "name"); - shouldBe("db.objectStores", "[]"); - shouldBe("db.objectStores.length", "0"); - shouldBe("db.objectStores.contains('')", "false"); - // FIXME: Test .item() once it's possible to get back a non-empty list. - - // FIXME: Test the other properties of IDBDatabase as they're written. - - debug(""); - debug("Testing setVersion."); - result = evalAndLog('db.setVersion("version a")'); - verifyResult(result); - result.onsuccess = setVersionAgain; - result.onError = unexpectedErrorCallback; -} - -function setVersionAgain() -{ - result = evalAndLog('db.setVersion("version b")'); - verifyResult(result); - result.onsuccess = checkVersion; - result.onError = unexpectedErrorCallback; -} - -function checkVersion() -{ - shouldBeEqualToString("db.version", "version b"); - - done(); -} - -function test() -{ - result = evalAndLog("indexedDB.open('name', 'description')"); - verifyResult(result); - result.onsuccess = openSuccess; - result.onerror = unexpectedErrorCallback; -} - -test(); - -var successfullyParsed = true; diff --git a/LayoutTests/storage/indexeddb/script-tests/keyrange.js b/LayoutTests/storage/indexeddb/script-tests/keyrange.js deleted file mode 100644 index 907d817..0000000 --- a/LayoutTests/storage/indexeddb/script-tests/keyrange.js +++ /dev/null @@ -1,76 +0,0 @@ -description("Test IndexedDB's KeyRange."); -if (window.layoutTestController) - layoutTestController.waitUntilDone(); - -function checkSingleKeyRange(value) -{ - keyRange = evalAndLog("IDBKeyRange.only(" + value + ")"); - shouldBe("keyRange.left", "" + value); - shouldBe("keyRange.right", "" + value); - shouldBe("keyRange.flags", "keyRange.SINGLE"); -} - -function checkLeftBoundKeyRange(value, open) -{ - keyRange = evalAndLog("IDBKeyRange.leftBound(" + value + "," + open + ")"); - shouldBe("keyRange.left", "" + value); - shouldBeNull("keyRange.right"); - shouldBe("keyRange.flags", open ? "keyRange.LEFT_OPEN | keyRange.LEFT_BOUND" : "keyRange.LEFT_BOUND"); -} - -function checkRightBoundKeyRange(value, open) -{ - keyRange = evalAndLog("IDBKeyRange.rightBound(" + value + "," + open + ")"); - shouldBe("keyRange.right", "" + value); - shouldBeNull("keyRange.left"); - shouldBe("keyRange.flags", open ? "keyRange.RIGHT_OPEN | keyRange.RIGHT_BOUND" : "keyRange.RIGHT_BOUND"); -} - -function checkBoundKeyRange(left, right, openLeft, openRight) -{ - keyRange = evalAndLog("IDBKeyRange.bound(" + left + "," + right + "," + openLeft + "," + openRight + ")"); - shouldBe("keyRange.left", "" + left); - shouldBe("keyRange.right", "" + right); - leftFlags = keyRange.flags & (keyRange.LEFT_OPEN | keyRange.LEFT_BOUND); - shouldBe("leftFlags", openLeft ? "keyRange.LEFT_OPEN | keyRange.LEFT_BOUND" : "keyRange.LEFT_BOUND"); - rightFlags = keyRange.flags & (keyRange.RIGHT_OPEN | keyRange.RIGHT_BOUND); - shouldBe("rightFlags", openRight ? "keyRange.RIGHT_OPEN | keyRange.RIGHT_BOUND" : "keyRange.RIGHT_BOUND"); -} - -function test() -{ - checkSingleKeyRange(1); - checkSingleKeyRange("'a'"); - - checkLeftBoundKeyRange(10, true); - checkLeftBoundKeyRange(11, false); - checkLeftBoundKeyRange(12); - checkLeftBoundKeyRange("'aa'", true); - checkLeftBoundKeyRange("'ab'", false); - checkLeftBoundKeyRange("'ac'"); - - checkRightBoundKeyRange(20, true); - checkRightBoundKeyRange(21, false); - checkRightBoundKeyRange(22); - checkRightBoundKeyRange("'ba'", true); - checkRightBoundKeyRange("'bb'", false); - checkRightBoundKeyRange("'bc'"); - - checkBoundKeyRange(30, 40); - checkBoundKeyRange(31, 41, false, false); - checkBoundKeyRange(32, 42, false, true); - checkBoundKeyRange(33, 43, true, false); - checkBoundKeyRange(34, 44, true, true); - - checkBoundKeyRange("'aaa'", "'aba'", false, false); - checkBoundKeyRange("'aab'", "'abb'"); - checkBoundKeyRange("'aac'", "'abc'", false, false); - checkBoundKeyRange("'aad'", "'abd'", false, true); - checkBoundKeyRange("'aae'", "'abe'", true, false); - checkBoundKeyRange("'aaf'", "'abf'", true, true); -} - -test(); - -var successfullyParsed = true; -done(); diff --git a/LayoutTests/storage/indexeddb/script-tests/objectstore-basics.js b/LayoutTests/storage/indexeddb/script-tests/objectstore-basics.js deleted file mode 100644 index 63675ad..0000000 --- a/LayoutTests/storage/indexeddb/script-tests/objectstore-basics.js +++ /dev/null @@ -1,82 +0,0 @@ -description("Test the basics of IndexedDB's IDBObjectStore."); -if (window.layoutTestController) - layoutTestController.waitUntilDone(); - -function test() -{ - result = evalAndLog("indexedDB.open('name', 'description')"); - verifyResult(result); - result.onsuccess = openSuccess; - result.onerror = unexpectedErrorCallback; -} - -function openSuccess() -{ - debug("openSuccess():"); - verifySuccessEvent(event); - db = evalAndLog("db = event.result"); - - deleteAllObjectStores(db); - - result = evalAndLog("db.createObjectStore('storeName', null)"); - verifyResult(result); - result.onsuccess = createSuccess; - result.onerror = unexpectedErrorCallback; -} - -function createSuccess() -{ - debug("createSuccess():"); - verifySuccessEvent(event); - var store = evalAndLog("store = event.result"); - var storeNames = evalAndLog("storeNames = db.objectStores"); - - shouldBeEqualToString("store.name", "storeName"); - shouldBeNull("store.keyPath"); - shouldBe("storeNames.contains('storeName')", "true"); - shouldBe("storeNames.length", "1"); - // FIXME: test store.indexNames, as well as all object store's methods. - - result = evalAndLog("store.add('value', 'key')"); - verifyResult(result); - result.onsuccess = addSuccess; - result.onerror = unexpectedErrorCallback; -} - -function addSuccess() -{ - debug("addSuccess():"); - verifySuccessEvent(event); - shouldBeEqualToString("event.result", "key"); - var store = evalAndLog("store = event.source"); - - result = evalAndLog("store.get('key')"); - verifyResult(result); - result.onsuccess = getSuccess; - result.onerror = unexpectedErrorCallback; -} - -function getSuccess() -{ - debug("getSuccess():"); - verifySuccessEvent(event); - shouldBeEqualToString("event.result", "value"); - var store = evalAndLog("store = event.source"); - - result = evalAndLog("store.remove('key')"); - verifyResult(result); - result.onsuccess = removeSuccess; - result.onerror = unexpectedErrorCallback; -} - -function removeSuccess() -{ - debug("removeSuccess():"); - verifySuccessEvent(event); - shouldBeNull("event.result"); - done(); -} - -test(); - -var successfullyParsed = true; diff --git a/LayoutTests/storage/indexeddb/script-tests/open-cursor.js b/LayoutTests/storage/indexeddb/script-tests/open-cursor.js deleted file mode 100644 index 53ea96b..0000000 --- a/LayoutTests/storage/indexeddb/script-tests/open-cursor.js +++ /dev/null @@ -1,83 +0,0 @@ -description("Test IndexedDB's openCursor."); -if (window.layoutTestController) - layoutTestController.waitUntilDone(); - -function emptyCursorSuccess() -{ - debug("Empty cursor opened successfully.") - verifySuccessEvent(event); - // FIXME: check that we can iterate the cursor. - done(); -} - -function openEmptyCursor() -{ - debug("Opening an empty cursor."); - keyRange = IDBKeyRange.leftBound("InexistentKey"); - result = evalAndLog("objectStore.openCursor(keyRange)"); - verifyResult(result); - result.onsuccess = emptyCursorSuccess; - result.onerror = unexpectedErrorCallback; -} - -function cursorSuccess() -{ - debug("Cursor opened successfully.") - verifySuccessEvent(event); - // FIXME: check that we can iterate the cursor. - shouldBe("event.result.direction", "0"); - shouldBe("event.result.key", "'myKey'"); - shouldBe("event.result.value", "'myValue'"); - debug(""); - openEmptyCursor(); -} - -function openCursor() -{ - debug("Opening cursor"); - keyRange = IDBKeyRange.leftBound("myKey"); - result = evalAndLog("objectStore.openCursor(keyRange)"); - verifyResult(result); - result.onsuccess = cursorSuccess; - result.onerror = unexpectedErrorCallback; -} - -function populateObjectStore(objectStore) -{ - result = evalAndLog("objectStore.add('myValue', 'myKey')"); - verifyResult(result); - result.onsuccess = openCursor; - result.onerror = unexpectedErrorCallback; -} - -function createObjectStoreSuccess() -{ - verifySuccessEvent(event); - var objectStore = evalAndLog("objectStore = event.result"); - populateObjectStore(objectStore); -} - -function openSuccess() -{ - verifySuccessEvent(event); - var db = evalAndLog("db = event.result"); - - deleteAllObjectStores(db); - - result = evalAndLog("db.createObjectStore('test')"); - verifyResult(result); - result.onsuccess = createObjectStoreSuccess; - result.onerror = unexpectedErrorCallback; -} - -function test() -{ - result = evalAndLog("indexedDB.open('name', 'description')"); - verifyResult(result); - result.onsuccess = openSuccess; - result.onerror = unexpectedErrorCallback; -} - -test(); - -var successfullyParsed = true; diff --git a/LayoutTests/storage/indexeddb/script-tests/transaction-basics.js b/LayoutTests/storage/indexeddb/script-tests/transaction-basics.js deleted file mode 100644 index 58ac2a7..0000000 --- a/LayoutTests/storage/indexeddb/script-tests/transaction-basics.js +++ /dev/null @@ -1,47 +0,0 @@ -description("Test IndexedDB transaction basics."); -if (window.layoutTestController) - layoutTestController.waitUntilDone(); - -function test() -{ - shouldBeTrue("'indexedDB' in window"); - shouldBeFalse("indexedDB == null"); - - result = evalAndLog("indexedDB.open('name', 'description')"); - verifyResult(result); - result.onsuccess = openSuccess; - result.onerror = unexpectedErrorCallback; -} - -function openSuccess() -{ - debug("createObjectStoreCallback():"); - verifySuccessEvent(event); - db = evalAndLog("db = event.result"); - - deleteAllObjectStores(db); - - result = evalAndLog("db.createObjectStore('storeName', null)"); - verifyResult(result); - result.onsuccess = createSuccess; - result.onerror = unexpectedErrorCallback; -} - -function createSuccess() -{ - verifySuccessEvent(event); - transaction = evalAndLog("db.transaction()"); - transaction.onabort = abortCallback; - var store = evalAndLog("store = transaction.objectStore('storeName')"); - shouldBeEqualToString("store.name", "storeName"); -} - -function abortCallback() -{ - verifyAbortEvent(event); - done(); -} - -test(); - -var successfullyParsed = true; diff --git a/LayoutTests/storage/indexeddb/transaction-basics.html b/LayoutTests/storage/indexeddb/transaction-basics.html index a7238f6..cea5d5d 100644 --- a/LayoutTests/storage/indexeddb/transaction-basics.html +++ b/LayoutTests/storage/indexeddb/transaction-basics.html @@ -8,6 +8,56 @@ <body> <p id="description"></p> <div id="console"></div> -<script src="script-tests/transaction-basics.js"></script> +<script> + +description("Test IndexedDB transaction basics."); +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +function test() +{ + shouldBeTrue("'indexedDB' in window"); + shouldBeFalse("indexedDB == null"); + + result = evalAndLog("indexedDB.open('name', 'description')"); + verifyResult(result); + result.onsuccess = openSuccess; + result.onerror = unexpectedErrorCallback; +} + +function openSuccess() +{ + debug("createObjectStoreCallback():"); + verifySuccessEvent(event); + db = evalAndLog("db = event.result"); + + deleteAllObjectStores(db); + + result = evalAndLog("db.createObjectStore('storeName', null)"); + verifyResult(result); + result.onsuccess = createSuccess; + result.onerror = unexpectedErrorCallback; +} + +function createSuccess() +{ + verifySuccessEvent(event); + transaction = evalAndLog("db.transaction()"); + transaction.onabort = abortCallback; + var store = evalAndLog("store = transaction.objectStore('storeName')"); + shouldBeEqualToString("store.name", "storeName"); +} + +function abortCallback() +{ + verifyAbortEvent(event); + done(); +} + +test(); + +var successfullyParsed = true; + +</script> </body> </html> |