Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / content / test / data / indexeddb / delete_compact.html
blobfc85cefd9c5de5e262e8c91056160ebca98f3815
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.onupgradeneeded = function() {
33 var db = request.result;
34 var store = db.createObjectStore('store');
35 var kilobyte = Array(512+1).join('\u0100'); // 2 bytes in UTF-8 or UTF-16.
36 var megabyte = Array(1024+1).join(kilobyte);
37 for (var i = 0; i < 5; ++i) {
38 store.put(megabyte, i);
39 bytes += 1024 * 1024;
42 request.onsuccess = function() {
43 var db = request.result;
44 db.close();
45 done('filled with ' + bytes + ' bytes');
49 function purge()
51 var request = indexedDB.deleteDatabase(dbname);
52 request.onsuccess = function() {
53 done('purged');
57 </script>
58 </head>
59 <body onload="test()">
60 <div id="status">Starting...</div>
61 </body>
62 </html>