1 Confirm basic Blob/File/FileList functionality.
3 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
6 dbname = "blob-basics-metadata.html"
7 indexedDB.deleteDatabase(dbname)
9 store = db.createObjectStore('storeName')
10 store.put('value', 'key')
13 PASS FileReader != null is true
14 test_content = 'This is a test. This is only a test.'
15 blob = new Blob([test_content])
18 PASS blob.size == test_content.length is true
19 transaction = db.transaction('storeName', 'readwrite')
20 store = transaction.objectStore('storeName')
21 store.put(blob, 'blobkey')
22 transaction = db.transaction('storeName', 'readwrite')
23 store = transaction.objectStore('storeName')
24 request = store.get('blobkey')
25 PASS event.target.result.size == test_content.length is true
28 file = fileInput.files[0]
31 PASS file.name == fileInput.files[0].name is true
32 transaction = db.transaction('storeName', 'readwrite')
33 store = transaction.objectStore('storeName')
34 store.put(file, 'filekey')
35 transaction = db.transaction('storeName', 'readwrite')
36 store = transaction.objectStore('storeName')
37 request = store.get('filekey')
38 PASS event.target.result.name == fileInput.files[0].name is true
41 newFile = new File([test_content], 'filename', {type:'text/plain'})
43 validateResult(newFile):
44 PASS newFile.name == newFile.name is true
45 transaction = db.transaction('storeName', 'readwrite')
46 store = transaction.objectStore('storeName')
47 store.put(newFile, 'newFilekey')
48 transaction = db.transaction('storeName', 'readwrite')
49 store = transaction.objectStore('storeName')
50 request = store.get('newFilekey')
51 PASS event.target.result.name == newFile.name is true
54 filelist = fileInput.files
56 validateResult(filelist):
57 PASS filelist[1].name == fileInput.files[1].name is true
58 transaction = db.transaction('storeName', 'readwrite')
59 store = transaction.objectStore('storeName')
60 store.put(filelist, 'filelistkey')
61 transaction = db.transaction('storeName', 'readwrite')
62 store = transaction.objectStore('storeName')
63 request = store.get('filelistkey')
64 PASS event.target.result[1].name == fileInput.files[1].name is true
67 transaction = db.transaction('storeName', 'readonly')
68 store = transaction.objectStore('storeName')
69 request = store.openCursor()
70 PASS cursor.value.size == test_content.length is true
72 PASS cursor.value.name == fileInput.files[0].name is true
74 PASS cursor.value[1].name == fileInput.files[1].name is true
76 PASS cursor.value == 'value' is true
78 PASS cursor.value.name == newFile.name is true
81 PASS successfullyParsed is true