Chromium Code Reviews| Index: content/test/data/indexeddb/blob_did_ack.html |
| diff --git a/content/test/data/indexeddb/blob_did_ack.html b/content/test/data/indexeddb/blob_did_ack.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..4ab354ccb9ac25e7471d6b7d85c823a0ccfc072c |
| --- /dev/null |
| +++ b/content/test/data/indexeddb/blob_did_ack.html |
| @@ -0,0 +1,78 @@ |
| +<!DOCTYPE html> |
| +<html> |
| +<!-- |
| + Copyright 2015 The Chromium Authors. All rights reserved. |
| + Use of this source code is governed by a BSD-style license that can be |
| + found in the LICENSE file. |
| +--> |
| +<head> |
| +<title>IDB Test that reading a blob from the database does send an ack back to browser process</title> |
| +<script src="common.js"></script> |
| +<script> |
| + |
| +// Constants. |
| +var store_name = 'blobs_ack'; |
| +var blob_key = 'blob_key'; |
| +var blob_size = 200; |
| + |
| +// Shared variables. |
| +var db; |
| +var put_blob; |
| +var got_blob; |
| + |
| +function test() { |
| + indexedDBTest(prepareDatabase, putBlob); |
| +} |
| + |
| +function prepareDatabase() { |
| + db = event.target.result; |
| + db.createObjectStore(store_name); |
| +} |
| + |
| +function putBlob() { |
| + debug("Writing blob."); |
| + |
| + var trans = db.transaction(store_name, 'readwrite'); |
| + trans.onabort = unexpectedAbortCallback; |
| + trans.oncomplete = getBlob; |
| + |
| + var data = new Array(1 + blob_size).join("X"); |
| + put_blob = new Blob([data]); |
| + var request = trans.objectStore(store_name).put(put_blob, blob_key); |
| + request.onerror = unexpectedErrorCallback; |
| +} |
| + |
| +function getBlob() { |
| + debug("Deleting blob."); |
| + put_blob = undefined; // So that the blob can be GC'd |
| + got_blob = false; |
| + var trans = db.transaction(store_name, 'readonly'); |
| + trans.onabort = unexpectedAbortCallback; |
| + trans.oncomplete = onGetComplete; |
| + |
| + var request = trans.objectStore(store_name).get(blob_key); |
| + request.onerror = unexpectedErrorCallback; |
| + request.onsuccess = onGetSuccess; |
| +} |
| + |
| +function onGetComplete() { |
| + if (got_blob) { |
|
jsbell
2015/02/13 21:16:37
Now that the test doesn't call blob.close(), I thi
|
| + gc(); |
| + done(); |
| + } else { |
| + fail('Did not close the blob'); |
| + } |
| +} |
| + |
| +function onGetSuccess(evt) { |
| + got_blob = true; |
| +} |
| + |
| +</script> |
| +</head> |
| +<body onLoad="test()"> |
| + <div id="status">Starting...<br> |
| + <p>Run this test with --js-flags=--expose-gc when run from Chrome.</p> |
| + </div> |
| +</body> |
| +</html> |