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

Unified Diff: content/test/data/indexeddb/blob_did_ack.html

Issue 917353002: IndexedDB: Test that Blink ack's blobs upon receipt. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added comment to test and num_blobs -> blob_count Created 5 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/indexed_db/indexed_db_browsertest.cc ('k') | storage/browser/blob/blob_storage_context.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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>
« no previous file with comments | « content/browser/indexed_db/indexed_db_browsertest.cc ('k') | storage/browser/blob/blob_storage_context.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698