diff options
author | Steve Block <steveblock@google.com> | 2011-05-18 13:36:51 +0100 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2011-05-24 15:38:28 +0100 |
commit | 2fc2651226baac27029e38c9d6ef883fa32084db (patch) | |
tree | e396d4bf89dcce6ed02071be66212495b1df1dec /LayoutTests/storage/indexeddb/data-corruption.html | |
parent | b3725cedeb43722b3b175aaeff70552e562d2c94 (diff) | |
download | external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.zip external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.gz external_webkit-2fc2651226baac27029e38c9d6ef883fa32084db.tar.bz2 |
Merge WebKit at r78450: Initial merge by git.
Change-Id: I6d3e5f1f868ec266a0aafdef66182ddc3f265dc1
Diffstat (limited to 'LayoutTests/storage/indexeddb/data-corruption.html')
-rw-r--r-- | LayoutTests/storage/indexeddb/data-corruption.html | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/LayoutTests/storage/indexeddb/data-corruption.html b/LayoutTests/storage/indexeddb/data-corruption.html new file mode 100644 index 0000000..664ff6d --- /dev/null +++ b/LayoutTests/storage/indexeddb/data-corruption.html @@ -0,0 +1,88 @@ +<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> + +description("Test that data inserted into IndexedDB does not get corrupted on disk."); +if (window.layoutTestController) + layoutTestController.waitUntilDone(); + +function test() +{ + result = evalAndLog("webkitIndexedDB.open('name')"); + verifyResult(result); + result.onsuccess = openSuccess; + result.onerror = unexpectedErrorCallback; +} + +function openSuccess() +{ + debug("openSuccess():"); + verifySuccessEvent(event); + window.db = evalAndLog("db = event.result"); + + result = evalAndLog("db.setVersion('new version')"); + verifyResult(result); + result.onsuccess = setVersionSuccess; + result.onerror = unexpectedErrorCallback; +} + +function setVersionSuccess() +{ + debug("setVersionSuccess():"); + verifySuccessEvent(event); + window.trans = evalAndLog("trans = event.result"); + shouldBeTrue("trans !== null"); + trans.onabort = unexpectedAbortCallback; + trans.oncomplete = addData; + + deleteAllObjectStores(db, createObjectStore); +} + +function createObjectStore() +{ + debug("createObjectStore():"); + evalAndLog("db.createObjectStore('storeName')"); +} + +var testDate = new Date('February 24, 1955 12:00:08'); + +function addData() +{ + debug("addData():"); + var transaction = evalAndLog("transaction = db.transaction([], webkitIDBTransaction.READ_WRITE)"); + var result = evalAndLog("result = transaction.objectStore('storeName').add({x: testDate}, 'key')"); + result.onerror = unexpectedErrorCallback; + transaction.oncomplete = getData; +} + +function getData() +{ + debug("addData():"); + var transaction = evalAndLog("transaction = db.transaction([], webkitIDBTransaction.READ_ONLY)"); + var result = evalAndLog("result = transaction.objectStore('storeName').get('key')"); + result.onerror = unexpectedErrorCallback; + result.onsuccess = doCheck; +} + +function doCheck() +{ + verifySuccessEvent(event); + shouldBeTrue("event.result.x.toString() == testDate.toString()"); + done(); +} + +test(); + +var successfullyParsed = true; + +</script> +</body> +</html> |