<!DOCTYPE html>
<html>
<!--
Copyright 2013 The Chromium Authors
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_quota puts this origin over quota.
request = indexedDB.open("fill_quota.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", generateRandomString(1));
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>