blob: e1cc781fd9957ab8bbb08ce8b7d3c3de5fcc093e [file] [log] [blame]
<!DOCTYPE html>
<html>
<!--
Copyright (c) 2013 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<head>
<title>IDB test that origins over quota aren't trapped</title>
<script type="text/javascript" src="common.js"></script>
</head>
<script>
function test() {
// This file runs after fill_up_5k puts this origin over quota.
request = indexedDB.open("fill_up_5k.html");
request.onblocked = unexpectedBlockedCallback;
request.onupgradeneeded = unexpectedUpgradeNeededCallback;
request.onsuccess = onOpen;
request.onerror = unexpectedErrorCallback;
}
function onOpen() {
db = event.target.result;
shouldBe("db.objectStoreNames.length", "1");
trans = db.transaction(db.objectStoreNames, "readwrite");
trans.objectStore(db.objectStoreNames[0]).put("dogs", "cats");
trans.oncomplete = unexpectedCompleteCallback;
trans.onabort = function() {
shouldBeEqualToString("trans.error.name", "QuotaExceededError");
testOnlyDeleteTransaction();
}
}
function testOnlyDeleteTransaction() {
trans = db.transaction(db.objectStoreNames, "readwrite");
request = trans.objectStore(db.objectStoreNames[0]).openCursor();
request.onerror = unexpectedErrorCallback;
request.onsuccess = function() {
cursor = request.result;
shouldBeTrue("cursor != null");
cursor.delete();
}
trans.onabort = unexpectedAbortCallback;
trans.oncomplete = testReadOnlyTransaction;
}
function testReadOnlyTransaction() {
trans = db.transaction(db.objectStoreNames, "readonly");
trans.objectStore(db.objectStoreNames[0]).get("cats").onerror =
unexpectedErrorCallback;
trans.onabort = unexpectedAbortCallback;
trans.oncomplete = done;
}
</script>
<body onLoad="test()">
<div id="status">Starting...</div>
</body>
</html>