1 Confirm that IndexedDB can store an empty Blob/File/FileList
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "empty-blob-file.html"
7 indexedDB.deleteDatabase(dbname)
9 store = db.createObjectStore('storeName')
10 store.put('value', 'key')
16 PASS blob.size == 0 is true
17 transaction = db.transaction('storeName', 'readwrite')
18 store = transaction.objectStore('storeName')
19 store.put(blob, 'blobkey')
20 transaction = db.transaction('storeName', 'readwrite')
21 store = transaction.objectStore('storeName')
22 request = store.get('blobkey')
23 PASS event.target.result.size == 0 is true
26 blob = new Blob(['', '', ''])
29 PASS blob.size == 0 is true
30 transaction = db.transaction('storeName', 'readwrite')
31 store = transaction.objectStore('storeName')
32 store.put(blob, 'blobkey')
33 transaction = db.transaction('storeName', 'readwrite')
34 store = transaction.objectStore('storeName')
35 request = store.get('blobkey')
36 PASS event.target.result.size == 0 is true
38 testEmptyNestedBlob():
39 blob = new Blob(['', new Blob([]), ''])
42 PASS blob.size == 0 is true
43 transaction = db.transaction('storeName', 'readwrite')
44 store = transaction.objectStore('storeName')
45 store.put(blob, 'blobkey')
46 transaction = db.transaction('storeName', 'readwrite')
47 store = transaction.objectStore('storeName')
48 request = store.get('blobkey')
49 PASS event.target.result.size == 0 is true
51 testEmptyNestedDataBlob():
52 blob = new Blob(['', new Blob(['']), ''])
55 PASS blob.size == 0 is true
56 transaction = db.transaction('storeName', 'readwrite')
57 store = transaction.objectStore('storeName')
58 store.put(blob, 'blobkey')
59 transaction = db.transaction('storeName', 'readwrite')
60 store = transaction.objectStore('storeName')
61 request = store.get('blobkey')
62 PASS event.target.result.size == 0 is true
64 testEmptyFileInsideBlob():
65 file = emptyFileInput.files[0]
66 blob = new Blob(['', file, ''])
69 PASS blob.size == 0 is true
70 transaction = db.transaction('storeName', 'readwrite')
71 store = transaction.objectStore('storeName')
72 store.put(blob, 'blobkey')
73 transaction = db.transaction('storeName', 'readwrite')
74 store = transaction.objectStore('storeName')
75 request = store.get('blobkey')
76 PASS event.target.result.size == 0 is true
78 testEmptyFileInsideNestedBlob():
79 file = emptyFileInput.files[0]
80 blob = new Blob(['', new Blob([file]), ''])
83 PASS blob.size == 0 is true
84 transaction = db.transaction('storeName', 'readwrite')
85 store = transaction.objectStore('storeName')
86 store.put(blob, 'blobkey')
87 transaction = db.transaction('storeName', 'readwrite')
88 store = transaction.objectStore('storeName')
89 request = store.get('blobkey')
90 PASS event.target.result.size == 0 is true
93 file = emptyFileInput.files[0]
96 PASS file.size == 0 is true
97 transaction = db.transaction('storeName', 'readwrite')
98 store = transaction.objectStore('storeName')
99 store.put(file, 'filekey')
100 transaction = db.transaction('storeName', 'readwrite')
101 store = transaction.objectStore('storeName')
102 request = store.get('filekey')
103 PASS event.target.result.size == 0 is true
106 fileList = emptyFileListInput.files
108 validateResult(fileList):
109 PASS fileList.length == 0 is true
110 transaction = db.transaction('storeName', 'readwrite')
111 store = transaction.objectStore('storeName')
112 store.put(fileList, 'fileListkey')
113 transaction = db.transaction('storeName', 'readwrite')
114 store = transaction.objectStore('storeName')
115 request = store.get('fileListkey')
116 PASS event.target.result.length == 0 is true
117 PASS successfullyParsed is true