Index: LayoutTests/storage/indexeddb/empty-filesystem-file.html |
diff --git a/LayoutTests/storage/indexeddb/empty-filesystem-file.html b/LayoutTests/storage/indexeddb/empty-filesystem-file.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..de908ca5049c405453b4b8d122675022c0ea23a2 |
--- /dev/null |
+++ b/LayoutTests/storage/indexeddb/empty-filesystem-file.html |
@@ -0,0 +1,89 @@ |
+<script src="../../resources/js-test.js"></script> |
jsbell
2014/07/31 18:53:50
Add <!DOCTYPE html> at the top of the file
pwnall-personal
2014/08/01 00:01:12
Done.
|
+<script src="resources/shared.js"></script> |
+</head> |
jsbell
2014/07/31 18:53:51
Unmatched </head> tag - remove it
pwnall-personal
2014/08/01 00:01:11
Done.
|
+<body> |
jsbell
2014/07/31 18:53:51
<body></body> is probably not required
pwnall-personal
2014/08/01 00:01:12
Done.
|
+<script> |
+ |
+description("Confirm that IndexedDB can store an empty File from the Filesystem API"); |
+ |
+function prepareDatabase() |
+{ |
+ db = event.target.result; |
+ var trans = event.target.transaction; |
+ evalAndLog("store = db.createObjectStore('storeName')"); |
+ evalAndLog("store.put('value', 'key')"); |
+ trans.onerror = unexpectedErrorCallback; |
+ trans.onabort = unexpectedAbortCallback; |
+} |
+ |
+var fileValidation = ".size == 0"; |
+function testEmptyFilesystemFile() |
+{ |
+ debug(""); |
jsbell
2014/07/31 18:53:51
Same as in other file (you could use preamble() he
pwnall-personal
2014/08/01 00:01:12
Done.
|
+ debug("testEmptyFile():"); |
+ evalAndLog("file = window.emptyFile"); |
+ validateResult("file", fileValidation, cleanupFs); |
+} |
+ |
+function validateResult(variable, validation, onComplete) |
+{ |
+ var keyName = variable + "key"; |
+ debug(""); |
+ debug("validateResult(" + variable + "):"); |
+ evalAndLog("transaction = db.transaction('storeName', 'readwrite')"); |
+ evalAndLog("store = transaction.objectStore('storeName')"); |
+ evalAndLog("store.put(" + variable + ", '" + keyName + "')"); |
+ transaction.onerror = unexpectedErrorCallback; |
+ transaction.onabort = unexpectedAbortCallback; |
+ var readTransactionOnComplete = function (e) { |
jsbell
2014/07/31 18:53:50
Same as in other file (this is used as a callback
pwnall-personal
2014/08/01 00:01:12
Done.
|
+ shouldBeTrue("event.target.result" + validation); |
+ onComplete(); |
+ } |
+ transaction.oncomplete = function () { |
+ doRead(keyName, readTransactionOnComplete); |
+ } |
+} |
+ |
+function doRead(keyName, onComplete) |
+{ |
+ evalAndLog("transaction = db.transaction('storeName', 'readwrite')"); |
+ evalAndLog("store = transaction.objectStore('storeName')"); |
+ evalAndLog("request = store.get('" + keyName + "')"); |
+ request.onsuccess = onComplete; |
+ transaction.onerror = unexpectedErrorCallback; |
+ transaction.onabort = unexpectedAbortCallback; |
+} |
+ |
+function fsError(error) |
+{ |
+ debug("Filesystem error:" + error.name); |
+ cleanupFs(); |
+} |
+function fsCreated(fs) |
+{ |
+ debug("Got FileSystem:" + fs.name); |
+ window.fileSystem = fs; |
+ |
+ fs.root.getFile("empty.txt", {create: true}, function(entry) { |
+ entry.file(function(file) { |
+ window.emptyFile = file; |
+ indexedDBTest(prepareDatabase, testEmptyFilesystemFile); |
+ }); |
+ }, fsError); |
+} |
+window.webkitRequestFileSystem(TEMPORARY, 100, fsCreated, fsError); |
jsbell
2014/07/31 18:53:50
Can you make this do something informative in fire
pwnall-personal
2014/08/01 00:01:12
Done.
|
+ |
+function cleanupFs() |
+{ |
+ if (window.fileSystem) { |
+ var fs = window.fileSystem; |
+ // cleanupFs shouldn't get called again if an error occurs below. |
+ window.fileSystem = null; |
+ fs.root.getFile("empty.txt", {create: false}, function (entry) { |
+ entry.remove(finishJSTest, fsError); |
+ }, fsError); |
+ } |
+} |
+</script> |
+</body> |
+</html> |
jsbell
2014/07/31 18:53:51
Unmatched </html> - remove it
pwnall-personal
2014/08/01 00:01:12
Done.
|