Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <html> | |
| 3 <!-- | |
| 4 Copyright 2015 The Chromium Authors. All rights reserved. | |
| 5 Use of this source code is governed by a BSD-style license that can be | |
| 6 found in the LICENSE file. | |
| 7 --> | |
| 8 <head> | |
| 9 <title>IDB Test that reading a blob from the database does send an ack back to b rowser process</title> | |
| 10 <script src="common.js"></script> | |
| 11 <script> | |
| 12 | |
| 13 // Constants. | |
| 14 var store_name = 'blobs_ack'; | |
| 15 var blob_key = 'blob_key'; | |
| 16 var blob_size = 200; | |
| 17 | |
| 18 // Shared variables. | |
| 19 var db; | |
| 20 var put_blob; | |
| 21 var got_blob; | |
| 22 | |
| 23 function test() { | |
| 24 indexedDBTest(prepareDatabase, putBlob); | |
| 25 } | |
| 26 | |
| 27 function prepareDatabase() { | |
| 28 db = event.target.result; | |
| 29 db.createObjectStore(store_name); | |
| 30 } | |
| 31 | |
| 32 function putBlob() { | |
| 33 debug("Writing blob."); | |
| 34 | |
| 35 var trans = db.transaction(store_name, 'readwrite'); | |
| 36 trans.onabort = unexpectedAbortCallback; | |
| 37 trans.oncomplete = getBlob; | |
| 38 | |
| 39 var data = new Array(1 + blob_size).join("X"); | |
| 40 put_blob = new Blob([data]); | |
| 41 var request = trans.objectStore(store_name).put(put_blob, blob_key); | |
| 42 request.onerror = unexpectedErrorCallback; | |
| 43 } | |
| 44 | |
| 45 function getBlob() { | |
| 46 debug("Deleting blob."); | |
| 47 put_blob = undefined; // So that the blob can be GC'd | |
| 48 got_blob = false; | |
| 49 var trans = db.transaction(store_name, 'readonly'); | |
| 50 trans.onabort = unexpectedAbortCallback; | |
| 51 trans.oncomplete = onGetComplete; | |
| 52 | |
| 53 var request = trans.objectStore(store_name).get(blob_key); | |
| 54 request.onerror = unexpectedErrorCallback; | |
| 55 request.onsuccess = onGetSuccess; | |
| 56 } | |
| 57 | |
| 58 function onGetComplete() { | |
| 59 if (got_blob) { | |
|
jsbell
2015/02/13 21:16:37
Now that the test doesn't call blob.close(), I thi
| |
| 60 gc(); | |
| 61 done(); | |
| 62 } else { | |
| 63 fail('Did not close the blob'); | |
| 64 } | |
| 65 } | |
| 66 | |
| 67 function onGetSuccess(evt) { | |
| 68 got_blob = true; | |
| 69 } | |
| 70 | |
| 71 </script> | |
| 72 </head> | |
| 73 <body onLoad="test()"> | |
| 74 <div id="status">Starting...<br> | |
| 75 <p>Run this test with --js-flags=--expose-gc when run from Chrome.</p> | |
| 76 </div> | |
| 77 </body> | |
| 78 </html> | |
| OLD | NEW |