dom/workers/test/test_errorPropagation.html

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/dom/workers/test/test_errorPropagation.html	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,66 @@
     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 +<!DOCTYPE HTML>
     1.9 +<html>
    1.10 +  <head>
    1.11 +    <meta charset="utf-8">
    1.12 +    <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js">
    1.13 +    </script>
    1.14 +    <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
    1.15 +  </head>
    1.16 +  <body>
    1.17 +    <iframe id="workerFrame" src="errorPropagation_iframe.html"
    1.18 +            onload="workerFrameLoaded();"></iframe>
    1.19 +    <script type="text/javascript">
    1.20 +      const workerCount = 3;
    1.21 +
    1.22 +      const errorMessage = "Error: expectedError";
    1.23 +      const errorFilename = "http://mochi.test:8888/tests/dom/workers/test/" +
    1.24 +                            "errorPropagation_worker.js";
    1.25 +      const errorLineno = 48;
    1.26 +
    1.27 +      var workerFrame;
    1.28 +
    1.29 +      scopeErrorCount = 0;
    1.30 +      workerErrorCount = 0;
    1.31 +      windowErrorCount = 0;
    1.32 +
    1.33 +      function messageListener(event) {
    1.34 +        if (event.type == "scope") {
    1.35 +          scopeErrorCount++;
    1.36 +        }
    1.37 +        else if (event.type == "worker") {
    1.38 +          workerErrorCount++;
    1.39 +        }
    1.40 +        else if (event.type == "window") {
    1.41 +          windowErrorCount++;
    1.42 +        }
    1.43 +        else {
    1.44 +          ok(false, "Bad event type: " + event.type);
    1.45 +        }
    1.46 +
    1.47 +        is(event.data.message, errorMessage, "Correct message event.message");
    1.48 +        is(event.data.filename, errorFilename,
    1.49 +           "Correct message event.filename");
    1.50 +        is(event.data.lineno, errorLineno, "Correct message event.lineno");
    1.51 +
    1.52 +        if (windowErrorCount == 1) {
    1.53 +          is(scopeErrorCount, workerCount, "Good number of scope errors");
    1.54 +          is(workerErrorCount, workerCount, "Good number of worker errors");
    1.55 +          workerFrame.stop();
    1.56 +          SimpleTest.finish();
    1.57 +        }
    1.58 +      }
    1.59 +
    1.60 +      function workerFrameLoaded() {
    1.61 +        workerFrame = document.getElementById("workerFrame").contentWindow;
    1.62 +        workerFrame.start(workerCount, messageListener);
    1.63 +      }
    1.64 +
    1.65 +      SimpleTest.waitForExplicitFinish();
    1.66 +    </script>
    1.67 +  </body>
    1.68 +</html>
    1.69 +

mercurial