GPU workaround to simulate Out of Memory errors with large textures
[chromium-blink-merge.git] / content / test / data / indexeddb / fill_up_5k.html
blobaa3c4edf419704144b0cd60f2ea43e067826d12c
1 <!DOCTYPE html>
2 <html>
3 <!--
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.
7 -->
8 <head>
9 <title>IDB test that origins over quota aren't trapped Part 1 / 2</title>
10 <script type="text/javascript" src="common.js"></script>
11 <script>
13 function test() {
14 indexedDBTest(prepareDatabase, startNewTransaction);
17 function prepareDatabase()
19 db = event.target.result;
20 objectStore = db.createObjectStore("test123");
21 var len = 1024;
22 data = Array(1+len).join("X");
23 numTransactions = 0;
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() {
38 numTransactions++;
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();
51 else
52 done("Filled up " + returnedUsage);
55 function displaySize(bytes) {
56 var k = bytes / 1024;
57 var m = k / 1024;
58 return bytes + " (" + k + "k) (" + m + "m)";
61 </script>
62 </head>
63 <body onLoad="test()">
64 <div id="status">Starting...</div>
65 </body>
66 </html>