browserHelpers.js 995 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /**
  2. * Any copyright is dedicated to the Public Domain.
  3. * http://creativecommons.org/publicdomain/zero/1.0/
  4. */
  5. var testGenerator = testSteps();
  6. var testResult;
  7. var testException;
  8. function runTest()
  9. {
  10. testGenerator.next();
  11. }
  12. function finishTestNow()
  13. {
  14. if (testGenerator) {
  15. testGenerator.close();
  16. testGenerator = undefined;
  17. }
  18. }
  19. function finishTest()
  20. {
  21. setTimeout(finishTestNow, 0);
  22. setTimeout(() => {
  23. if (window.testFinishedCallback)
  24. window.testFinishedCallback(testResult, testException);
  25. else {
  26. let message;
  27. if (testResult)
  28. message = "ok";
  29. else
  30. message = testException;
  31. window.parent.postMessage(message, "*");
  32. }
  33. }, 0);
  34. }
  35. function grabEventAndContinueHandler(event)
  36. {
  37. testGenerator.send(event);
  38. }
  39. function errorHandler(event)
  40. {
  41. throw new Error("indexedDB error, code " + event.target.error.name);
  42. }
  43. function continueToNextStep()
  44. {
  45. SimpleTest.executeSoon(function() {
  46. testGenerator.next();
  47. });
  48. }