dom/indexedDB/test/browserHelpers.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/indexedDB/test/browserHelpers.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,50 @@
     1.4 +/**
     1.5 + * Any copyright is dedicated to the Public Domain.
     1.6 + * http://creativecommons.org/publicdomain/zero/1.0/
     1.7 + */
     1.8 +
     1.9 +let testGenerator = testSteps();
    1.10 +
    1.11 +let testResult;
    1.12 +let testException;
    1.13 +
    1.14 +function testFinishedCallback(result, exception)
    1.15 +{
    1.16 +  throw new Error("Bad testFinishedCallback!");
    1.17 +}
    1.18 +
    1.19 +function runTest()
    1.20 +{
    1.21 +  testGenerator.next();
    1.22 +}
    1.23 +
    1.24 +function finishTestNow()
    1.25 +{
    1.26 +  if (testGenerator) {
    1.27 +    testGenerator.close();
    1.28 +    testGenerator = undefined;
    1.29 +  }
    1.30 +}
    1.31 +
    1.32 +function finishTest()
    1.33 +{
    1.34 +  setTimeout(finishTestNow, 0);
    1.35 +  setTimeout(testFinishedCallback, 0, testResult, testException);
    1.36 +}
    1.37 +
    1.38 +function grabEventAndContinueHandler(event)
    1.39 +{
    1.40 +  testGenerator.send(event);
    1.41 +}
    1.42 +
    1.43 +function errorHandler(event)
    1.44 +{
    1.45 +  throw new Error("indexedDB error, code " + event.target.error.name);
    1.46 +}
    1.47 +
    1.48 +function continueToNextStep()
    1.49 +{
    1.50 +  SimpleTest.executeSoon(function() {
    1.51 +    testGenerator.next();
    1.52 +  });
    1.53 +}

mercurial