gecko/dom/indexedDB/test/browser_quotaPrompt.html

85 lines
2.5 KiB
HTML

<!--
Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/
-->
<html>
<head>
<title>Indexed Database Test</title>
<script type="text/javascript;version=1.7">
const READ_WRITE = Components.interfaces.nsIIDBTransaction.READ_WRITE;
let db;
function onAddMore() {
let transaction = db.transaction("foo", READ_WRITE);
transaction.oncomplete = function(event) {
setTimeout(testFinishedCallback, 0, "complete");
}
transaction.onabort = function(event) {
setTimeout(testFinishedCallback, 0, "abort");
}
let objectStore = transaction.objectStore("foo");
let obj = {
foo: " ",
bar: " ",
baz: " "
};
for (let i = 0; i < 1000; i++) {
objectStore.add(obj).onerror = errorHandler;
}
}
function onDone() {
window.removeEventListener("indexedDB-addMore", onAddMore, true);
window.removeEventListener("indexedDB-done", onDone, true);
let request = db.setVersion("2");
request.onerror = errorHandler;
request.onsuccess = function(event) {
db.deleteObjectStore("foo");
request.transaction.oncomplete = function(event) {
testResult = "finished";
testException = undefined;
finishTest();
}
}
}
function testSteps()
{
const name = window.location.pathname;
const description = "My Test Database";
window.addEventListener("indexedDB-addMore", onAddMore, true);
window.addEventListener("indexedDB-done", onDone, true);
let request = mozIndexedDB.open(name, description);
request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler;
let event = yield;
db = event.target.result;
request = db.setVersion("1");
request.onerror = errorHandler;
request.onsuccess = grabEventAndContinueHandler;
event = yield;
db.createObjectStore("foo", { autoIncrement: true });
setTimeout(testFinishedCallback, 0, "ready");
yield;
}
</script>
<script type="text/javascript;version=1.7" src="browserHelpers.js"></script>
</head>
<body onload="runTest();" onunload="finishTestNow();"></body>
</html>