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

Side by Side Diff: LayoutTests/storage/indexeddb/empty-filesystem-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> at the top of the file
pwnall-personal 2014/08/01 00:01:12 Done.
2 <script src="resources/shared.js"></script>
3 </head>
jsbell 2014/07/31 18:53:51 Unmatched </head> tag - remove it
pwnall-personal 2014/08/01 00:01:11 Done.
4 <body>
jsbell 2014/07/31 18:53:51 <body></body> is probably not required
pwnall-personal 2014/08/01 00:01:12 Done.
5 <script>
6
7 description("Confirm that IndexedDB can store an empty File from the Filesystem API");
8
9 function prepareDatabase()
10 {
11 db = event.target.result;
12 var trans = event.target.transaction;
13 evalAndLog("store = db.createObjectStore('storeName')");
14 evalAndLog("store.put('value', 'key')");
15 trans.onerror = unexpectedErrorCallback;
16 trans.onabort = unexpectedAbortCallback;
17 }
18
19 var fileValidation = ".size == 0";
20 function testEmptyFilesystemFile()
21 {
22 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.
23 debug("testEmptyFile():");
24 evalAndLog("file = window.emptyFile");
25 validateResult("file", fileValidation, cleanupFs);
26 }
27
28 function validateResult(variable, validation, onComplete)
29 {
30 var keyName = variable + "key";
31 debug("");
32 debug("validateResult(" + variable + "):");
33 evalAndLog("transaction = db.transaction('storeName', 'readwrite')");
34 evalAndLog("store = transaction.objectStore('storeName')");
35 evalAndLog("store.put(" + variable + ", '" + keyName + "')");
36 transaction.onerror = unexpectedErrorCallback;
37 transaction.onabort = unexpectedAbortCallback;
38 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.
39 shouldBeTrue("event.target.result" + validation);
40 onComplete();
41 }
42 transaction.oncomplete = function () {
43 doRead(keyName, readTransactionOnComplete);
44 }
45 }
46
47 function doRead(keyName, onComplete)
48 {
49 evalAndLog("transaction = db.transaction('storeName', 'readwrite')");
50 evalAndLog("store = transaction.objectStore('storeName')");
51 evalAndLog("request = store.get('" + keyName + "')");
52 request.onsuccess = onComplete;
53 transaction.onerror = unexpectedErrorCallback;
54 transaction.onabort = unexpectedAbortCallback;
55 }
56
57 function fsError(error)
58 {
59 debug("Filesystem error:" + error.name);
60 cleanupFs();
61 }
62 function fsCreated(fs)
63 {
64 debug("Got FileSystem:" + fs.name);
65 window.fileSystem = fs;
66
67 fs.root.getFile("empty.txt", {create: true}, function(entry) {
68 entry.file(function(file) {
69 window.emptyFile = file;
70 indexedDBTest(prepareDatabase, testEmptyFilesystemFile);
71 });
72 }, fsError);
73 }
74 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.
75
76 function cleanupFs()
77 {
78 if (window.fileSystem) {
79 var fs = window.fileSystem;
80 // cleanupFs shouldn't get called again if an error occurs below.
81 window.fileSystem = null;
82 fs.root.getFile("empty.txt", {create: false}, function (entry) {
83 entry.remove(finishJSTest, fsError);
84 }, fsError);
85 }
86 }
87 </script>
88 </body>
89 </html>
jsbell 2014/07/31 18:53:51 Unmatched </html> - remove it
pwnall-personal 2014/08/01 00:01:12 Done.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698