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
.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
);
43 request
.onsuccess = function() {
44 var db
= request
.result
;
46 done('filled with ' + bytes
+ ' bytes');
52 var request
= indexedDB
.deleteDatabase(dbname
);
53 request
.onerror
= unexpectedErrorCallback
;
54 request
.onsuccess = function() {
61 <body onload=
"test()">
62 <div id=
"status">Starting...
</div>