test_errorPropagation.html 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <!--
  2. Any copyright is dedicated to the Public Domain.
  3. http://creativecommons.org/publicdomain/zero/1.0/
  4. -->
  5. <!DOCTYPE HTML>
  6. <html>
  7. <head>
  8. <meta charset="utf-8">
  9. <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js">
  10. </script>
  11. <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  12. </head>
  13. <body>
  14. <iframe id="workerFrame" src="errorPropagation_iframe.html"
  15. onload="workerFrameLoaded();"></iframe>
  16. <script type="text/javascript">
  17. const workerCount = 3;
  18. const errorMessage = "Error: expectedError";
  19. const errorFilename = "http://mochi.test:8888/tests/dom/workers/test/" +
  20. "errorPropagation_worker.js";
  21. const errorLineno = 48;
  22. var workerFrame;
  23. scopeErrorCount = 0;
  24. workerErrorCount = 0;
  25. windowErrorCount = 0;
  26. function messageListener(event) {
  27. if (event.type == "scope") {
  28. scopeErrorCount++;
  29. }
  30. else if (event.type == "worker") {
  31. workerErrorCount++;
  32. }
  33. else if (event.type == "window") {
  34. windowErrorCount++;
  35. }
  36. else {
  37. ok(false, "Bad event type: " + event.type);
  38. }
  39. is(event.data.message, errorMessage, "Correct message event.message");
  40. is(event.data.filename, errorFilename,
  41. "Correct message event.filename");
  42. is(event.data.lineno, errorLineno, "Correct message event.lineno");
  43. if (windowErrorCount == 1) {
  44. is(scopeErrorCount, workerCount, "Good number of scope errors");
  45. is(workerErrorCount, workerCount, "Good number of worker errors");
  46. workerFrame.stop();
  47. SimpleTest.finish();
  48. }
  49. }
  50. function workerFrameLoaded() {
  51. workerFrame = document.getElementById("workerFrame").contentWindow;
  52. workerFrame.start(workerCount, messageListener);
  53. }
  54. SimpleTest.waitForExplicitFinish();
  55. </script>
  56. </body>
  57. </html>