blob: 336761cb3eaaa2d3ff5ed18f3837d8c9279a0667 [file] [log] [blame]
<script>
var dbName = "StoreBlobToBeDeleted";
var db;
function sendMessage(text)
{
window.webkit.messageHandlers.testHandler.postMessage(text);
}
function deleteDatabase(successHandler)
{
var request = window.indexedDB.deleteDatabase(dbName);
request.onsuccess = successHandler;
request.onerror = function() {
sendMessage('Error deleting database');
}
}
function storeBlobInDatabase()
{
var request = window.indexedDB.open(dbName);
request.onupgradeneeded = function(e) {
db = e.target.result;
var objectStore = db.createObjectStore("TestStore");
const blobData = ["fun ", "times ", "all ", "around!"];
let blob = new Blob(blobData, { type: "text/plain" });
var addRequest = objectStore.add(blob, "BlobKey");
addRequest.onerror = function() {
sendMessage('Error storing blob in database');
}
}
request.onsuccess = function() {
db.close();
sendMessage('Success');
}
request.onerror = function() {
sendMessage('Error storing blob in database');
}
}
deleteDatabase(storeBlobInDatabase);
</script>