| <!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 unused cursor prefetches are acked back to browser process</title> |
| <script src="common.js"></script> |
| <script> |
| |
| // Constants. |
| var store_name = 'prefetch_blobs_ack'; |
| var kNumToFetch = 15; // Enough to trigger prefetch, but not on a batch boundary. |
| |
| // Shared variables. |
| var db; |
| |
| function test() { |
| indexedDBTest(prepareDatabase, iterateCursor); |
| } |
| |
| function prepareDatabase() { |
| db = event.target.result; |
| var store = db.createObjectStore(store_name); |
| for (var i = 0; i < kNumToFetch + 10; ++i) |
| store.put(new Blob([String(i)]), i); |
| } |
| |
| function iterateCursor() { |
| var tx = db.transaction(store_name, 'readonly'); |
| var count = kNumToFetch; |
| var request = tx.objectStore(store_name).openCursor(); |
| request.onerror = unexpectedErrorCallback; |
| request.onsuccess = function() { |
| if (--count > 0) |
| request.result.continue(); |
| }; |
| tx.onabort = unexpectedAbortCallback; |
| tx.oncomplete = onComplete; |
| } |
| |
| function onComplete() { |
| gc(); |
| done(); |
| } |
| |
| </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> |