Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Side by Side Diff: LayoutTests/storage/indexeddb/empty-blob-file.html

Issue 433983002: LayoutTests for writing empty Blob/File/FileList to IndexedDB. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added Filesystem test. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <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!
2 <script src="resources/shared.js"></script>
3 </head>
jsbell 2014/07/31 18:53:50 Unmatched </head> - remove it
pwnall-personal 2014/08/01 00:01:11 Done.
4 <body>
5 <input type="file" id="emptyFileInput"></input>
6 <input type="file" id="emptyFileListInput" multiple></input>
7 <script>
8
9 description("Confirm that IndexedDB can store an empty Blob/File/FileList");
10
11 var emptyFileInput = document.getElementById("emptyFileInput");
12 var emptyFileListInput = document.getElementById("emptyFileListInput");
13 if (window.eventSender) {
14 var fileRect = emptyFileInput.getClientRects()[0];
jsbell 2014/07/31 18:53:50 Inconsistent indentation.
pwnall-personal 2014/08/01 00:01:10 Done. Sorry!
15 var targetX = fileRect.left + fileRect.width / 2;
16 var targetY = fileRect.top + fileRect.height / 2;
17 eventSender.beginDragWithFiles(['resources/empty.txt']);
18 eventSender.mouseMoveTo(targetX, targetY);
19 eventSender.mouseUp();
20 }
21
22 function prepareDatabase()
23 {
24 db = event.target.result;
25 var trans = event.target.transaction;
26 evalAndLog("store = db.createObjectStore('storeName')");
27 evalAndLog("store.put('value', 'key')");
28 trans.onerror = unexpectedErrorCallback;
29 trans.onabort = unexpectedAbortCallback;
30 }
31
32 var blobValidation = ".size == 0";
33 function testEmptyBlob()
34 {
35 debug("");
36 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!
37
38 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
39 evalAndLog("blob = new Blob([])");
40 validateResult("blob", blobValidation, testEmptyDataBlob);
41 }
42 function testEmptyDataBlob()
43 {
44 debug("");
45 debug("testEmptyDataBlob():");
46
47 shouldBeTrue("FileReader != null");
48 evalAndLog("blob = new Blob(['', '', ''])");
49 validateResult("blob", blobValidation, testEmptyNestedBlob);
50 }
51 function testEmptyNestedBlob()
52 {
53 debug("");
54 debug("testEmptyNestedBlob():");
55
56 shouldBeTrue("FileReader != null");
57 evalAndLog("blob = new Blob(['', new Blob([]), ''])");
58 validateResult("blob", blobValidation, testEmptyFile);
59 }
60
61 var fileValidation = ".size == 0";
62 function testEmptyFile()
63 {
64 debug("");
65 debug("testEmptyFile():");
66 evalAndLog("file = emptyFileInput.files[0]");
67 validateResult("file", fileValidation, testEmptyFileList);
68 }
69
70 var fileListValidation = ".length == 0";
71 function testEmptyFileList()
72 {
73 debug("");
74 debug("testEmptyFileList():");
75 evalAndLog("fileList = emptyFileListInput.files");
76 validateResult("fileList",
77 fileListValidation, finishJSTest);
78 }
79
80 function validateResult(variable, validation, onComplete)
81 {
82 var keyName = variable + "key";
83 debug("");
84 debug("validateResult(" + variable + "):");
85 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!
86 evalAndLog("store = transaction.objectStore('storeName')");
87 evalAndLog("store.put(" + variable + ", '" + keyName + "')");
88 transaction.onerror = unexpectedErrorCallback;
89 transaction.onabort = unexpectedAbortCallback;
90 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!
91 shouldBeTrue("event.target.result" + validation);
92 onComplete();
93 }
94 transaction.oncomplete = function () {
95 doRead(keyName, readTransactionOnComplete);
96 }
97 }
98
99 function doRead(keyName, onComplete)
100 {
101 evalAndLog("transaction = db.transaction('storeName', 'readwrite')");
102 evalAndLog("store = transaction.objectStore('storeName')");
103 evalAndLog("request = store.get('" + keyName + "')");
104 request.onsuccess = onComplete;
105 transaction.onerror = unexpectedErrorCallback;
106 transaction.onabort = unexpectedAbortCallback;
107 }
108
109 if (window.eventSender) {
110 indexedDBTest(prepareDatabase, testEmptyBlob);
111 } else {
112 alert("Select an empty file using the left input control above to initiate t he test");
113 document.getElementById("emptyFileInput").onchange = function() { indexedDBT est(prepareDatabase, testEmptyBlob); };
114 }
115 </script>
116 </body>
117 </html>
jsbell 2014/07/31 18:53:50 Unmatched </html> - remove it
pwnall-personal 2014/08/01 00:01:11 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698