mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
117 lines
3.2 KiB
HTML
117 lines
3.2 KiB
HTML
<!--
|
|
Any copyright is dedicated to the Public Domain.
|
|
http://creativecommons.org/publicdomain/zero/1.0/
|
|
-->
|
|
<html>
|
|
<head>
|
|
<title>Indexed Database Property Test</title>
|
|
|
|
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
<script type="text/javascript;version=1.7">
|
|
let testGenerator = testSteps();
|
|
|
|
function ok(val, message) {
|
|
val = val ? "true" : "false";
|
|
window.parent.postMessage("SimpleTest.ok(" + val + ", '" + message +
|
|
"');", "*");
|
|
}
|
|
|
|
function is(a, b, message) {
|
|
ok(a == b, message);
|
|
}
|
|
|
|
function grabEventAndContinueHandler(event) {
|
|
testGenerator.send(event);
|
|
}
|
|
|
|
function errorHandler(event) {
|
|
ok(false, "indexedDB error, code " + event.target.errorCode);
|
|
finishTest();
|
|
}
|
|
|
|
function unexpectedSuccessHandler(event) {
|
|
ok(false, "got success when it was not expected!");
|
|
finishTest();
|
|
}
|
|
|
|
function finishTest() {
|
|
// Let window.onerror have a chance to fire
|
|
setTimeout(function() {
|
|
setTimeout(function() {
|
|
testGenerator.close();
|
|
window.parent.postMessage("SimpleTest.finish();", "*");
|
|
}, 0);
|
|
}, 0);
|
|
}
|
|
|
|
window.onerror = function() {
|
|
return false;
|
|
};
|
|
|
|
function testSteps() {
|
|
window.parent.SpecialPowers.addPermission("indexedDB", true, document);
|
|
|
|
let request = mozIndexedDB.open(window.location.pathname, 1);
|
|
request.onerror = grabEventAndContinueHandler;
|
|
request.onsuccess = errorHandler;
|
|
request.onupgradeneeded = function () {
|
|
throw "STOP";
|
|
};
|
|
|
|
let event = yield;
|
|
|
|
is(event.type, "error",
|
|
"Throwing during an upgradeneeded event should fire an error.");
|
|
|
|
let request = mozIndexedDB.open(window.location.pathname, 1);
|
|
request.onerror = grabEventAndContinueHandler;
|
|
request.onblocked = errorHandler;
|
|
request.onupgradeneeded = grabEventAndContinueHandler;
|
|
let openrequest = request;
|
|
let event = yield;
|
|
|
|
let db = event.target.result;
|
|
db.onerror = function(event) {
|
|
event.preventDefault();
|
|
};
|
|
|
|
event.target.transaction.oncomplete = unexpectedSuccessHandler;
|
|
event.target.transaction.onabort = grabEventAndContinueHandler;
|
|
|
|
is(db.version, 1, "Correct version");
|
|
is(db.objectStoreNames.length, 0, "Correct objectStoreNames length");
|
|
|
|
let objectStore = db.createObjectStore("foo");
|
|
|
|
is(db.objectStoreNames.length, 1, "Correct objectStoreNames length");
|
|
ok(db.objectStoreNames.contains("foo"), "Has correct objectStore");
|
|
|
|
request = objectStore.add({}, 1);
|
|
request.onsuccess = function(event) {
|
|
throw "foo";
|
|
};
|
|
|
|
event = yield;
|
|
|
|
is(event.type, "abort", "Got transaction abort event");
|
|
is(event.target.error, null, "Got null error object");
|
|
|
|
event = yield;
|
|
|
|
is(event.type, "error", "Got IDBOpenDBRequest error event");
|
|
is(event.target, openrequest, "Right event target");
|
|
is(event.target.error.name, "AbortError", "Right error name");
|
|
|
|
finishTest();
|
|
yield;
|
|
}
|
|
</script>
|
|
|
|
</head>
|
|
|
|
<body onload="testGenerator.next();"></body>
|
|
|
|
</html>
|