4 Copyright (c) 2013 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.
9 <title>IDB test that origins over quota aren't trapped Part 1 / 2</title>
10 <script type="text/javascript" src="common.js"></script>
14 indexedDBTest(prepareDatabase, startNewTransaction);
17 function prepareDatabase()
19 db = event.target.result;
20 objectStore = db.createObjectStore("test123");
22 data = Array(1+len).join("X");
26 function startNewTransaction() {
27 debug("Starting new transaction.");
29 var trans = db.transaction(['test123'], 'readwrite');
30 trans.onabort = unexpectedAbortCallback;
31 trans.oncomplete = getQuotaAndUsage;
32 var store = trans.objectStore('test123');
33 request = store.put({x: data}, numTransactions);
34 request.onerror = unexpectedErrorCallback;
37 function getQuotaAndUsage() {
39 webkitStorageInfo.queryUsageAndQuota(webkitStorageInfo.TEMPORARY,
40 usageCallback, unexpectedErrorCallback);
43 function usageCallback(usage, quota) {
44 debug("Transaction finished.");
45 returnedUsage = usage;
46 returnedQuota = quota;
47 debug("Allotted quota is " + displaySize(returnedQuota));
48 debug("LevelDB usage is " + displaySize(returnedUsage));
49 if (returnedUsage < 5 * 1024)
50 startNewTransaction();
52 done("Filled up " + returnedUsage);
55 function displaySize(bytes) {
58 return bytes + " (" + k + "k) (" + m + "m)";
63 <body onLoad="test()">
64 <div id="status">Starting...</div>