Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / storage / indexeddb / blob-delete-objectstore-db.html
blob6f983852093b81860511334dd77da1300f1a6b2e
1 <html>
2 <head>
3 <script src="../../resources/js-test.js"></script>
4 <script src="resources/shared.js"></script>
5 </head>
6 <body>
7 <script>
9 description("Test that deleting an object store and a database containing blobs doesn't crash.");
11 indexedDBTest(prepareDatabase, reopen, {version: 1});
12 function prepareDatabase()
14 db = event.target.result;
15 event.target.transaction.onabort = unexpectedAbortCallback;
16 evalAndLog("store0 = db.createObjectStore('store0')");
17 evalAndLog("store1 = db.createObjectStore('store1')");
18 blobAContent = "First blob content";
19 blobA = new Blob([blobAContent], {"type" : "text/plain"});
20 key = "blob key";
21 evalAndLog("store0.put(blobA, key)");
24 function reopen()
26 evalAndLog("db.close()");
27 preamble();
28 evalAndLog("request = indexedDB.open(dbname, 2)");
29 request.onupgradeneeded = deleteObjectStore;
30 request.onsuccess = unexpectedSuccessCallback;
31 request.onerror = unexpectedErrorCallback;
32 request.onblocked = unexpectedBlockedCallback;
35 function deleteObjectStore(e)
37 preamble();
38 db = e.target.result;
39 evalAndLog("db.deleteObjectStore('store0')");
40 request.onsuccess = didDeleteObjectStore;
43 function didDeleteObjectStore()
45 preamble();
46 blobBContent = "Second blob content";
47 evalAndLog("trans = db.transaction('store1', 'readwrite')");
48 evalAndLog("store1 = trans.objectStore('store1')");
49 blobB = new Blob([blobBContent], {"type" : "text/plain"});
50 evalAndLog("store1.put(blobB, key)");
51 trans.oncomplete = deleteDatabase;
52 trans.onabort = unexpectedAbortCallback;
55 function deleteDatabase()
57 evalAndLog("db.close()");
58 evalAndLog("request = indexedDB.deleteDatabase(dbname)");
59 request.onerror = unexpectedErrorCallback;
60 request.onsuccess = reportSuccess;
63 function reportSuccess()
65 debug("Database deleted.");
66 finishJSTest();
68 </script>
69 </body>
70 </html>