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.
9 <title>IDB test that database deletion triggers a compaction
</title>
10 <script type=
"text/javascript" src=
"common.js"></script>
13 var dbname
= 'delete_compact';
15 // Follow navigation requests from the browser test.
16 window
.onhashchange
= test
;
20 if (location
.hash
=== '#fill')
22 else if (location
.hash
=== '#purge')
24 else if (location
.hash
!== '#pass' && location
.hash
!== '#fail')
25 fail('unexpected hash');
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
);
42 request
.onsuccess = function() {
43 var db
= request
.result
;
45 done('filled with ' + bytes
+ ' bytes');
51 var request
= indexedDB
.deleteDatabase(dbname
);
52 request
.onsuccess = function() {
59 <body onload=
"test()">
60 <div id=
"status">Starting...
</div>