chromium/third_party/blink/web_tests/storage/indexeddb/empty-blob-file-expected.txt

Confirm that IndexedDB can store an empty Blob/File/FileList

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".

dbname = "empty-blob-file.html"
indexedDB.deleteDatabase(dbname)
indexedDB.open(dbname)
store = db.createObjectStore('storeName')
store.put('value', 'key')


testEmptyBlob():
blob = new Blob([])


validateResult(blob):
PASS blob.size == 0 is true
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
store.put(blob, 'blobkey')
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
request = store.get('blobkey')
PASS event.target.result.size == 0 is true


testEmptyDataBlob():
blob = new Blob(['', '', ''])


validateResult(blob):
PASS blob.size == 0 is true
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
store.put(blob, 'blobkey')
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
request = store.get('blobkey')
PASS event.target.result.size == 0 is true


testEmptyNestedBlob():
blob = new Blob(['', new Blob([]), ''])


validateResult(blob):
PASS blob.size == 0 is true
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
store.put(blob, 'blobkey')
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
request = store.get('blobkey')
PASS event.target.result.size == 0 is true


testEmptyNestedDataBlob():
blob = new Blob(['', new Blob(['']), ''])


validateResult(blob):
PASS blob.size == 0 is true
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
store.put(blob, 'blobkey')
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
request = store.get('blobkey')
PASS event.target.result.size == 0 is true


testEmptyFileInsideBlob():
file = emptyFileInput.files[0]
blob = new Blob(['', file, ''])


validateResult(blob):
PASS blob.size == 0 is true
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
store.put(blob, 'blobkey')
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
request = store.get('blobkey')
PASS event.target.result.size == 0 is true


testEmptyFileInsideNestedBlob():
file = emptyFileInput.files[0]
blob = new Blob(['', new Blob([file]), ''])


validateResult(blob):
PASS blob.size == 0 is true
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
store.put(blob, 'blobkey')
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
request = store.get('blobkey')
PASS event.target.result.size == 0 is true


testEmptyFile():
file = emptyFileInput.files[0]


validateResult(file):
PASS file.size == 0 is true
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
store.put(file, 'filekey')
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
request = store.get('filekey')
PASS event.target.result.size == 0 is true


testEmptyFileList():
fileList = emptyFileListInput.files


validateResult(fileList):
PASS fileList.length == 0 is true
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
store.put(fileList, 'fileListkey')
transaction = db.transaction('storeName', 'readwrite', {durability: 'relaxed'})
store = transaction.objectStore('storeName')
request = store.get('fileListkey')
PASS event.target.result.length == 0 is true
PASS successfullyParsed is true

TEST COMPLETE