gecko/dom/indexedDB/test/test_traffic_jam.html

100 lines
3.3 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">
function testSteps()
{
const name = window.location.pathname;
let requests = [];
function doOpen(version, errorCallback, upgradeNeededCallback, successCallback) {
let request = mozIndexedDB.open(name, version);
request.onerror = errorCallback;
request.onupgradeneeded = upgradeNeededCallback;
request.onsuccess = successCallback;
requests.push(request);
}
doOpen(1, errorHandler, grabEventAndContinueHandler, grabEventAndContinueHandler);
doOpen(2, errorHandler, unexpectedSuccessHandler, unexpectedSuccessHandler);
let event = yield;
is(event.type, "upgradeneeded", "expect an upgradeneeded event");
is(event.target, requests[0], "fired at the right request");
let db = event.target.result;
db.createObjectStore("foo");
doOpen(3, errorHandler, unexpectedSuccessHandler, unexpectedSuccessHandler);
doOpen(2, errorHandler, unexpectedSuccessHandler, unexpectedSuccessHandler);
doOpen(3, errorHandler, unexpectedSuccessHandler, unexpectedSuccessHandler);
event.target.transaction.oncomplete = grabEventAndContinueHandler;
event = yield;
is(event.type, "complete", "expect a complete event");
is(event.target, requests[0].transaction, "expect it to be fired at the transaction");
event = yield;
is(event.type, "success", "expect a success event");
is(event.target, requests[0], "fired at the right request");
event.target.result.close();
requests[1].onupgradeneeded = grabEventAndContinueHandler;
event = yield;
is(event.type, "upgradeneeded", "expect an upgradeneeded event");
is(event.target, requests[1], "fired at the right request");
requests[1].onsuccess = grabEventAndContinueHandler;
event = yield;
is(event.type, "success", "expect a success event");
is(event.target, requests[1], "fired at the right request");
event.target.result.close();
requests[2].onupgradeneeded = grabEventAndContinueHandler;
event = yield;
is(event.type, "upgradeneeded", "expect an upgradeneeded event");
is(event.target, requests[2], "fired at the right request");
requests[2].onsuccess = grabEventAndContinueHandler;
event = yield;
is(event.type, "success", "expect a success event");
is(event.target, requests[2], "fired at the right request");
event.target.result.close();
requests[3].onerror = new ExpectError(IDBDatabaseException.VERSION_ERR);
event = yield;
requests[4].onsuccess = grabEventAndContinueHandler;
event = yield;
is(event.type, "success", "expect a success event");
is(event.target, requests[4], "fired at the right request");
event.target.result.close();
finishTest();
yield;
}
</script>
<script type="text/javascript;version=1.7" src="helpers.js"></script>
</head>
<body onload="runTest();"></body>
</html>