[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / content / test / data / indexeddb / delete_compact.html
blobddad88d55ac4e6b13bdd95f6fdf4bf94c9c9d265
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <!--
5 Copyright 2013 The Chromium Authors. All rights reserved.
6 Use of this source code is governed by a BSD-style license that can be
7 found in the LICENSE file.
8 -->
9 <title>IDB test that database deletion triggers a compaction</title>
10 <script type="text/javascript" src="common.js"></script>
11 <script>
13 var dbname = 'delete_compact';
15 // Follow navigation requests from the browser test.
16 window.onhashchange = test;
18 function test()
20 if (location.hash === '#fill')
21 fill();
22 else if (location.hash === '#purge')
23 purge();
24 else if (location.hash !== '#pass' && location.hash !== '#fail')
25 fail('unexpected hash');
28 function fill()
30 var bytes = 0;
31 var request = indexedDB.open(dbname);
32 request.onerror = unexpectedErrorCallback;
33 request.onupgradeneeded = function() {
34 var db = request.result;
35 var store = db.createObjectStore('store');
36 var kilobyte = Array(512+1).join('\u0100'); // 2 bytes in UTF-8 or UTF-16.
37 var megabyte = Array(1024+1).join(kilobyte);
38 for (var i = 0; i < 5; ++i) {
39 store.put(megabyte, i);
40 bytes += 1024 * 1024;
43 request.onsuccess = function() {
44 var db = request.result;
45 db.close();
46 done('filled with ' + bytes + ' bytes');
50 function purge()
52 var request = indexedDB.deleteDatabase(dbname);
53 request.onerror = unexpectedErrorCallback;
54 request.onsuccess = function() {
55 done('purged');
59 </script>
60 </head>
61 <body onload="test()">
62 <div id="status">Starting...</div>
63 </body>
64 </html>