Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <html> | |
| 2 <head> | |
| 3 <script src="../../resources/js-test.js"></script> | |
| 4 <script src="resources/shared.js"></script> | |
| 5 </head> | |
| 6 <body> | |
| 7 <iframe id="frame0"></iframe> | |
| 8 <iframe id="frame1"></iframe> | |
| 9 <iframe id="frame2"></iframe> | |
| 10 <script> | |
| 11 | |
| 12 description("Confirm that blobs stay alive after their records are deleted."); | |
| 13 | |
| 14 indexedDBTest(prepareDatabase, doRead); | |
| 15 function prepareDatabase() | |
| 16 { | |
| 17 db = event.target.result; | |
| 18 event.target.transaction.onabort = unexpectedAbortCallback; | |
| 19 evalAndLog("store = db.createObjectStore('store')"); | |
| 20 blobAContent = "Blob A content"; | |
| 21 blobBContent = "Blob B content"; | |
| 22 var blobA = new Blob([blobAContent], {"type" : "text\/plain"}); | |
| 23 var blobB = new Blob([blobBContent], {"type" : "text\/plain"}); | |
| 24 key = "key" | |
| 25 value = { a0: blobA, a1: blobA, b0: blobB }; | |
| 26 evalAndLog("store.put(value, key)"); | |
| 27 delete value; | |
| 28 } | |
| 29 | |
| 30 function doRead() | |
| 31 { | |
| 32 preamble(); | |
| 33 evalAndLog("trans = db.transaction('store')"); | |
| 34 evalAndLog("store = trans.objectStore('store')"); | |
| 35 evalAndLog("request = store.get(key)"); | |
| 36 request.onsuccess = didRead; | |
| 37 } | |
| 38 | |
| 39 function didRead() | |
| 40 { | |
| 41 record = request.result; | |
| 42 trans.oncomplete = doDelete; | |
| 43 } | |
| 44 | |
| 45 function doDelete() | |
| 46 { | |
| 47 evalAndLog("trans = db.transaction('store', 'readwrite')"); | |
| 48 evalAndLog("store = trans.objectStore('store')"); | |
| 49 evalAndLog("request = store.delete(key)"); | |
| 50 trans.oncomplete = didDelete; | |
| 51 } | |
| 52 | |
| 53 function didDelete() | |
| 54 { | |
| 55 urlA0 = URL.createObjectURL(record.a0); | |
| 56 urlA1 = URL.createObjectURL(record.a1); | |
| 57 urlB = URL.createObjectURL(record.b0); | |
| 58 document.getElementById('frame0').src = urlA0; | |
| 59 document.getElementById('frame0').onload = verification; | |
| 60 document.getElementById('frame1').src = urlA1; | |
| 61 document.getElementById('frame1').onload = verification; | |
| 62 document.getElementById('frame2').src = urlB; | |
| 63 document.getElementById('frame2').onload = verification; | |
| 64 } | |
| 65 | |
| 66 var loadCount = 0; | |
| 67 function verification() | |
| 68 { | |
| 69 if (++loadCount < 3) | |
|
jsbell
2014/06/02 23:05:06
I wouldn't change this now, but in the future we s
ericu
2014/06/02 23:53:08
Yeah, it'd be nice to pull out all such hacks.
| |
| 70 return; | |
| 71 URL.revokeObjectURL(urlA0); | |
| 72 URL.revokeObjectURL(urlA1); | |
| 73 URL.revokeObjectURL(urlB); | |
| 74 shouldBe("document.getElementById('frame0').contentDocument.body.innerText", | |
| 75 "blobAContent"); | |
| 76 shouldBe("document.getElementById('frame1').contentDocument.body.innerText", | |
| 77 "blobAContent"); | |
| 78 shouldBe("document.getElementById('frame2').contentDocument.body.innerText", | |
| 79 "blobBContent"); | |
| 80 finishJSTest(); | |
| 81 } | |
| 82 | |
| 83 </script> | |
| 84 </body> | |
| 85 </html> | |
| 86 | |
| OLD | NEW |