blob: 7eb92997a161198f4a8b15e9cb1382dae28e5120 [file] [log] [blame]
<html>
<head>
<script src="/js-test-resources/js-test.js"></script>
<script src="resources/shared.js"></script>
</head>
<body>
<script>
if (window.testRunner)
testRunner.setAllowStorageQuotaIncrease(false);
description("This test makes sure that storage of indexedDB does not grow unboundedly.");
window.caches.open("test").then(cache => {
return cache.put(new Request("/test"), new Response(new Uint8Array(204800)));
}).then(() => {
indexedDBTest(prepareDatabase, onOpenSuccess, {'suffix': '-1'});
}).catch(e => {
testFailed("Cache API store operation failed: " + e);
finishJSTest();
});
function prepareDatabase(event)
{
evalAndLog("db = event.target.result");
evalAndLog("store = db.createObjectStore('store')");
}
// Quota for test is 400ko, but IDB is eating some of it when initializing files.
// Let's make sure that 200ko is fine but 200ko after 200ko is not fine.
async function onOpenSuccess(event)
{
evalAndLog("db = event.target.result");
evalAndLog("store = db.transaction('store', 'readwrite').objectStore('store')");
evalAndLog("request = store.add(new Uint8Array(204800), 'key')");
request.onerror = function(event) {
shouldBeTrue("'error' in request");
shouldBe("request.error.code", "DOMException.QUOTA_EXCEEDED_ERR");
shouldBeEqualToString("request.error.name", "QuotaExceededError");
finishJSTest();
}
request.onsuccess = function(event) {
testFailed("Add operation should fail because storage limit is reached, but succeeded.");
finishJSTest();
}
}
</script>
</body>
</html>