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 unused cursor prefetches are acked back to browser process< /title> | |
| 10 <script src="common.js"></script> | |
| 11 <script> | |
| 12 | |
| 13 // Constants. | |
| 14 var store_name = 'blobs_ack'; | |
|
cmumford
2015/02/17 18:13:49
Are we guaranteed this name won't collide with the
jsbell
2015/02/17 18:15:11
We should not be preserving state across tests, bu
| |
| 15 var kNumToFetch = 15; // Enough to trigger prefetch, but not on a batch boundary . | |
| 16 | |
| 17 // Shared variables. | |
| 18 var db; | |
| 19 | |
| 20 function test() { | |
| 21 indexedDBTest(prepareDatabase, iterateCursor); | |
| 22 } | |
| 23 | |
| 24 function prepareDatabase() { | |
| 25 db = event.target.result; | |
| 26 var store = db.createObjectStore(store_name); | |
| 27 for (var i = 0; i < kNumToFetch + 10; ++i) | |
| 28 store.put(new Blob([String(i)]), i); | |
| 29 } | |
| 30 | |
| 31 function iterateCursor() { | |
| 32 var tx = db.transaction(store_name, 'readonly'); | |
| 33 var count = kNumToFetch; | |
| 34 var request = tx.objectStore(store_name).openCursor(); | |
| 35 request.onerror = unexpectedErrorCallback; | |
| 36 request.onsuccess = function() { | |
| 37 if (--count > 0) | |
| 38 request.result.continue(); | |
| 39 }; | |
| 40 tx.onabort = unexpectedAbortCallback; | |
| 41 tx.oncomplete = onComplete; | |
| 42 } | |
| 43 | |
| 44 function onComplete() { | |
| 45 gc(); | |
| 46 done(); | |
| 47 } | |
| 48 | |
| 49 </script> | |
| 50 </head> | |
| 51 <body onLoad="test()"> | |
| 52 <div id="status">Starting...<br> | |
| 53 <p>Run this test with --js-flags=--expose-gc when run from Chrome.</p> | |
| 54 </div> | |
| 55 </body> | |
| 56 </html> | |
| OLD | NEW |