blob: f95797e0e054cc4a0064733455abb004ebea2c99 [file] [log] [blame]
<html>
<head>
<script src="../../resources/js-test.js"></script>
<script src="resources/shared.js"></script>
</head>
<body>
<script>
var transaction;
var store;
var db;
var body = document.getElementsByTagName("body")[0];
description("Test that pending transactions are not completed during recursive JS calls until all JS is finished.");
indexedDBTest(prepareDatabase, click);
function prepareDatabase()
{
db = event.target.result;
store = db.createObjectStore('objectStore', null);
}
function click()
{
body.onclick = test;
var pendingTransaction = evalAndLog("pendingTransaction = db.transaction(['objectStore'], 'readwrite')");
pendingTransaction.onsuccess = unexpectedErrorCallback;
pendingTransaction.onerror = unexpectedErrorCallback;
pendingTransaction.oncomplete = completeCallback;
var event = document.createEvent("MouseEvent");
event.initMouseEvent("click", true, true, document.defaultView, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
body.dispatchEvent(event);
var store = evalAndLog("store = pendingTransaction.objectStore('objectStore')");
shouldBeTrue("store !== undefined");
body.onclick = undefined;
}
function test()
{
debug("Start re-entrant JS");
transaction = evalAndLog("transaction = db.transaction(['objectStore'], 'readwrite')");
debug("End re-entrant JS");
}
function completeCallback()
{
testPassed("Pending transaction completed");
finishJSTest();
}
</script>
</body>
</html>