Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(130)

Side by Side Diff: LayoutTests/storage/indexeddb/blob-valid-after-deletion.html

Issue 18590006: Blob support for IDB [Blink] (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebasing issue? Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 debug("");
33 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.
34 evalAndLog("trans = db.transaction('store')");
35 evalAndLog("store = trans.objectStore('store')");
36 evalAndLog("request = store.get(key)");
37 request.onsuccess = didRead;
38 }
39
40 function didRead()
41 {
42 record = request.result;
43 trans.oncomplete = doDelete;
44 }
45
46 function doDelete()
47 {
48 evalAndLog("trans = db.transaction('store', 'readwrite')");
49 evalAndLog("store = trans.objectStore('store')");
50 evalAndLog("request = store.delete(key)");
51 trans.oncomplete = didDelete;
52 }
53
54 function didDelete()
55 {
56 urlA0 = URL.createObjectURL(record.a0);
57 urlA1 = URL.createObjectURL(record.a1);
58 urlB = URL.createObjectURL(record.b0);
59 document.getElementById('frame0').src = urlA0;
60 document.getElementById('frame0').onload = verification;
61 document.getElementById('frame1').src = urlA1;
62 document.getElementById('frame1').onload = verification;
63 document.getElementById('frame2').src = urlB;
64 document.getElementById('frame2').onload = verification;
65 }
66
67 var loadCount = 0;
68 function verification()
69 {
70 if (++loadCount < 3)
71 return;
72 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
73 record = null;
74 URL.revokeObjectURL(urlA0);
75 URL.revokeObjectURL(urlA1);
76 URL.revokeObjectURL(urlB);
77 shouldBe("document.getElementById('frame0').contentDocument.body.innerText",
78 "blobAContent");
79 shouldBe("document.getElementById('frame1').contentDocument.body.innerText",
80 "blobAContent");
81 shouldBe("document.getElementById('frame2').contentDocument.body.innerText",
82 "blobBContent");
83 finishJSTest();
84 }
85
86 </script>
87 </body>
88 </html>
89
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698