<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/shared.js"></script>
</head>
<body>
<script>
description("Test that deleting an object store and a database containing blobs doesn't crash.");
indexedDBTest(prepareDatabase, reopen, {version: 1});
function prepareDatabase()
{
db = event.target.result;
event.target.transaction.onabort = unexpectedAbortCallback;
evalAndLog("store0 = db.createObjectStore('store0')");
evalAndLog("store1 = db.createObjectStore('store1')");
blobAContent = "First blob content";
blobA = new Blob([blobAContent], {"type" : "text/plain"});
key = "blob key";
evalAndLog("store0.put(blobA, key)");
}
function reopen()
{
evalAndLog("db.close()");
preamble();
evalAndLog("request = indexedDB.open(dbname, 2)");
request.onupgradeneeded = deleteObjectStore;
request.onsuccess = unexpectedSuccessCallback;
request.onerror = unexpectedErrorCallback;
request.onblocked = unexpectedBlockedCallback;
}
function deleteObjectStore(e)
{
preamble();
db = e.target.result;
evalAndLog("db.deleteObjectStore('store0')");
request.onsuccess = didDeleteObjectStore;
}
function didDeleteObjectStore()
{
preamble();
blobBContent = "Second blob content";
evalAndLog("trans = db.transaction('store1', 'readwrite', {durability: 'relaxed'})");
evalAndLog("store1 = trans.objectStore('store1')");
blobB = new Blob([blobBContent], {"type" : "text/plain"});
evalAndLog("store1.put(blobB, key)");
trans.oncomplete = deleteDatabase;
trans.onabort = unexpectedAbortCallback;
}
function deleteDatabase()
{
evalAndLog("db.close()");
evalAndLog("request = indexedDB.deleteDatabase(dbname)");
request.onerror = unexpectedErrorCallback;
request.onsuccess = reportSuccess;
}
function reportSuccess()
{
debug("Database deleted.");
finishJSTest();
}
</script>
</body>
</html>