Chromium Code Reviews| Index: LayoutTests/storage/indexeddb/blob-valid-after-deletion.html |
| diff --git a/LayoutTests/storage/indexeddb/blob-valid-after-deletion.html b/LayoutTests/storage/indexeddb/blob-valid-after-deletion.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cb2c2a5f9243ad6a69bfbe080f2d73aec80edd1a |
| --- /dev/null |
| +++ b/LayoutTests/storage/indexeddb/blob-valid-after-deletion.html |
| @@ -0,0 +1,89 @@ |
| +<html> |
| +<head> |
| +<script src="../../resources/js-test.js"></script> |
| +<script src="resources/shared.js"></script> |
| +</head> |
| +<body> |
| +<iframe id="frame0"></iframe> |
| +<iframe id="frame1"></iframe> |
| +<iframe id="frame2"></iframe> |
| +<script> |
| + |
| +description("Confirm that blobs stay alive after their records are deleted."); |
| + |
| +indexedDBTest(prepareDatabase, doRead); |
| +function prepareDatabase() |
| +{ |
| + db = event.target.result; |
| + event.target.transaction.onabort = unexpectedAbortCallback; |
| + evalAndLog("store = db.createObjectStore('store')"); |
| + blobAContent = "Blob A content"; |
| + blobBContent = "Blob B content"; |
| + var blobA = new Blob([blobAContent], {"type" : "text\/plain"}); |
| + var blobB = new Blob([blobBContent], {"type" : "text\/plain"}); |
| + key = "key" |
| + value = { a0: blobA, a1: blobA, b0: blobB }; |
| + evalAndLog("store.put(value, key)"); |
| + delete value; |
| +} |
| + |
| +function doRead() |
| +{ |
| + debug(""); |
| + debug("doRead():"); |
|
jsbell
2014/05/29 00:40:06
FYI, we have a `preamble();` helper in shared.js t
ericu
2014/06/02 22:18:47
Done.
|
| + evalAndLog("trans = db.transaction('store')"); |
| + evalAndLog("store = trans.objectStore('store')"); |
| + evalAndLog("request = store.get(key)"); |
| + request.onsuccess = didRead; |
| +} |
| + |
| +function didRead() |
| +{ |
| + record = request.result; |
| + trans.oncomplete = doDelete; |
| +} |
| + |
| +function doDelete() |
| +{ |
| + evalAndLog("trans = db.transaction('store', 'readwrite')"); |
| + evalAndLog("store = trans.objectStore('store')"); |
| + evalAndLog("request = store.delete(key)"); |
| + trans.oncomplete = didDelete; |
| +} |
| + |
| +function didDelete() |
| +{ |
| + urlA0 = URL.createObjectURL(record.a0); |
| + urlA1 = URL.createObjectURL(record.a1); |
| + urlB = URL.createObjectURL(record.b0); |
| + document.getElementById('frame0').src = urlA0; |
| + document.getElementById('frame0').onload = verification; |
| + document.getElementById('frame1').src = urlA1; |
| + document.getElementById('frame1').onload = verification; |
| + document.getElementById('frame2').src = urlB; |
| + document.getElementById('frame2').onload = verification; |
| +} |
| + |
| +var loadCount = 0; |
| +function verification() |
| +{ |
| + if (++loadCount < 3) |
| + return; |
| + delete record; |
|
jsbell
2014/05/29 00:40:06
This use of the delete operator is even weirder. W
ericu
2014/06/02 22:18:47
It's a brain-o, and furthermore, completely superf
|
| + record = null; |
| + URL.revokeObjectURL(urlA0); |
| + URL.revokeObjectURL(urlA1); |
| + URL.revokeObjectURL(urlB); |
| + shouldBe("document.getElementById('frame0').contentDocument.body.innerText", |
| + "blobAContent"); |
| + shouldBe("document.getElementById('frame1').contentDocument.body.innerText", |
| + "blobAContent"); |
| + shouldBe("document.getElementById('frame2').contentDocument.body.innerText", |
| + "blobBContent"); |
| + finishJSTest(); |
| +} |
| + |
| +</script> |
| +</body> |
| +</html> |
| + |