2010-09-10 02:15:44 +04:00
|
|
|
/**
|
|
|
|
* Any copyright is dedicated to the Public Domain.
|
|
|
|
* http://creativecommons.org/publicdomain/zero/1.0/
|
|
|
|
*/
|
|
|
|
|
2017-05-10 19:05:18 +03:00
|
|
|
// testSteps is expected to be defined by the file including this file.
|
|
|
|
/* global testSteps */
|
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var testGenerator = testSteps();
|
2010-09-10 02:15:44 +04:00
|
|
|
|
2015-09-15 21:19:45 +03:00
|
|
|
var testResult;
|
|
|
|
var testException;
|
2010-09-10 02:15:44 +04:00
|
|
|
|
|
|
|
function runTest()
|
|
|
|
{
|
|
|
|
testGenerator.next();
|
|
|
|
}
|
|
|
|
|
|
|
|
function finishTestNow()
|
|
|
|
{
|
|
|
|
if (testGenerator) {
|
2016-12-01 12:11:32 +03:00
|
|
|
testGenerator.return();
|
2011-01-11 03:09:56 +03:00
|
|
|
testGenerator = undefined;
|
2010-09-10 02:15:44 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function finishTest()
|
|
|
|
{
|
|
|
|
setTimeout(finishTestNow, 0);
|
2016-02-29 13:44:49 +03:00
|
|
|
setTimeout(() => {
|
|
|
|
if (window.testFinishedCallback)
|
|
|
|
window.testFinishedCallback(testResult, testException);
|
|
|
|
else {
|
|
|
|
let message;
|
|
|
|
if (testResult)
|
|
|
|
message = "ok";
|
|
|
|
else
|
|
|
|
message = testException;
|
|
|
|
window.parent.postMessage(message, "*");
|
|
|
|
}
|
|
|
|
}, 0);
|
2010-09-10 02:15:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function grabEventAndContinueHandler(event)
|
|
|
|
{
|
2016-12-01 12:11:32 +03:00
|
|
|
testGenerator.next(event);
|
2010-09-10 02:15:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function errorHandler(event)
|
|
|
|
{
|
2013-09-28 15:25:46 +04:00
|
|
|
throw new Error("indexedDB error, code " + event.target.error.name);
|
2010-09-10 02:15:44 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
function continueToNextStep()
|
|
|
|
{
|
|
|
|
SimpleTest.executeSoon(function() {
|
|
|
|
testGenerator.next();
|
|
|
|
});
|
|
|
|
}
|