Index: LayoutTests/storage/indexeddb/empty-blob-file.html |
diff --git a/LayoutTests/storage/indexeddb/empty-blob-file.html b/LayoutTests/storage/indexeddb/empty-blob-file.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..2ccadb9cb47878229e78f3b7b99460737f498f5e |
--- /dev/null |
+++ b/LayoutTests/storage/indexeddb/empty-blob-file.html |
@@ -0,0 +1,117 @@ |
+<script src="../../resources/js-test.js"></script> |
jsbell
2014/07/31 18:53:50
Add <!DOCTYPE html>
pwnall-personal
2014/08/01 00:01:10
Done. Thank you!
|
+<script src="resources/shared.js"></script> |
+</head> |
jsbell
2014/07/31 18:53:50
Unmatched </head> - remove it
pwnall-personal
2014/08/01 00:01:11
Done.
|
+<body> |
+<input type="file" id="emptyFileInput"></input> |
+<input type="file" id="emptyFileListInput" multiple></input> |
+<script> |
+ |
+description("Confirm that IndexedDB can store an empty Blob/File/FileList"); |
+ |
+var emptyFileInput = document.getElementById("emptyFileInput"); |
+var emptyFileListInput = document.getElementById("emptyFileListInput"); |
+if (window.eventSender) { |
+ var fileRect = emptyFileInput.getClientRects()[0]; |
jsbell
2014/07/31 18:53:50
Inconsistent indentation.
pwnall-personal
2014/08/01 00:01:10
Done. Sorry!
|
+ var targetX = fileRect.left + fileRect.width / 2; |
+ var targetY = fileRect.top + fileRect.height / 2; |
+ eventSender.beginDragWithFiles(['resources/empty.txt']); |
+ eventSender.mouseMoveTo(targetX, targetY); |
+ eventSender.mouseUp(); |
+} |
+ |
+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 blobValidation = ".size == 0"; |
+function testEmptyBlob() |
+{ |
+ debug(""); |
+ debug("testEmptyBlob():"); |
jsbell
2014/07/31 18:53:50
You can replace these two debug() calls with the p
pwnall-personal
2014/08/01 00:01:11
Done. Thank you!
|
+ |
+ shouldBeTrue("FileReader != null"); |
jsbell
2014/07/31 18:53:50
What is this assertion for?
pwnall-personal
2014/08/01 00:01:11
Removed. Thank you!
Copied it blindly. I didn't re
|
+ evalAndLog("blob = new Blob([])"); |
+ validateResult("blob", blobValidation, testEmptyDataBlob); |
+} |
+function testEmptyDataBlob() |
+{ |
+ debug(""); |
+ debug("testEmptyDataBlob():"); |
+ |
+ shouldBeTrue("FileReader != null"); |
+ evalAndLog("blob = new Blob(['', '', ''])"); |
+ validateResult("blob", blobValidation, testEmptyNestedBlob); |
+} |
+function testEmptyNestedBlob() |
+{ |
+ debug(""); |
+ debug("testEmptyNestedBlob():"); |
+ |
+ shouldBeTrue("FileReader != null"); |
+ evalAndLog("blob = new Blob(['', new Blob([]), ''])"); |
+ validateResult("blob", blobValidation, testEmptyFile); |
+} |
+ |
+var fileValidation = ".size == 0"; |
+function testEmptyFile() |
+{ |
+ debug(""); |
+ debug("testEmptyFile():"); |
+ evalAndLog("file = emptyFileInput.files[0]"); |
+ validateResult("file", fileValidation, testEmptyFileList); |
+} |
+ |
+var fileListValidation = ".length == 0"; |
+function testEmptyFileList() |
+{ |
+ debug(""); |
+ debug("testEmptyFileList():"); |
+ evalAndLog("fileList = emptyFileListInput.files"); |
+ validateResult("fileList", |
+ fileListValidation, finishJSTest); |
+} |
+ |
+function validateResult(variable, validation, onComplete) |
+{ |
+ var keyName = variable + "key"; |
+ debug(""); |
+ debug("validateResult(" + variable + "):"); |
+ evalAndLog("transaction = db.transaction('storeName', 'readwrite')"); |
jsbell
2014/07/31 18:53:50
Would it be useful to add this here:
shouldBeTrue
pwnall-personal
2014/08/01 00:01:11
Awesome! Thanks!
|
+ 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
This is actually running on 'success' of a get req
pwnall-personal
2014/08/01 00:01:11
Done.
Thank you!
|
+ 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; |
+} |
+ |
+if (window.eventSender) { |
+ indexedDBTest(prepareDatabase, testEmptyBlob); |
+} else { |
+ alert("Select an empty file using the left input control above to initiate the test"); |
+ document.getElementById("emptyFileInput").onchange = function() { indexedDBTest(prepareDatabase, testEmptyBlob); }; |
+} |
+</script> |
+</body> |
+</html> |
jsbell
2014/07/31 18:53:50
Unmatched </html> - remove it
pwnall-personal
2014/08/01 00:01:11
Done.
|