dom/workers/test/test_recursion.html

Fri, 16 Jan 2015 18:13:44 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Fri, 16 Jan 2015 18:13:44 +0100
branch
TOR_BUG_9701
changeset 14
925c144e1f1f
permissions
-rw-r--r--

Integrate suggestion from review to improve consistency with existing code.

michael@0 1 <!--
michael@0 2 Any copyright is dedicated to the Public Domain.
michael@0 3 http://creativecommons.org/publicdomain/zero/1.0/
michael@0 4 -->
michael@0 5 <!DOCTYPE HTML>
michael@0 6 <html>
michael@0 7 <!--
michael@0 8 Tests of DOM Worker Threads
michael@0 9 -->
michael@0 10 <head>
michael@0 11 <title>Test for DOM Worker Threads Recursion</title>
michael@0 12 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
michael@0 14 </head>
michael@0 15 <body>
michael@0 16 <p id="display"></p>
michael@0 17 <div id="content" style="display: none">
michael@0 18
michael@0 19 </div>
michael@0 20 <pre id="test">
michael@0 21 <script class="testbody" type="text/javascript">
michael@0 22
michael@0 23 // Intermittently triggers one assertion on Mac (bug 848098).
michael@0 24 if (navigator.platform.indexOf("Mac") == 0) {
michael@0 25 SimpleTest.expectAssertions(0, 1);
michael@0 26 }
michael@0 27
michael@0 28 const testCount = 2;
michael@0 29 var errorCount = 0;
michael@0 30
michael@0 31 var worker = new Worker("recursion_worker.js");
michael@0 32
michael@0 33 function done() {
michael@0 34 worker.terminate();
michael@0 35 SimpleTest.finish();
michael@0 36 }
michael@0 37
michael@0 38 worker.onmessage = function(event) {
michael@0 39 if (event.data == "Done") {
michael@0 40 ok(true, "correct message");
michael@0 41 }
michael@0 42 else {
michael@0 43 ok(false, "Bad message: " + event.data);
michael@0 44 }
michael@0 45 done();
michael@0 46 }
michael@0 47
michael@0 48 worker.onerror = function(event) {
michael@0 49 event.preventDefault();
michael@0 50 if (event.message == "InternalError: too much recursion") {
michael@0 51 ok(true, "got correct error message");
michael@0 52 ++errorCount;
michael@0 53 }
michael@0 54 else {
michael@0 55 ok(false, "got bad error message: " + event.message);
michael@0 56 done();
michael@0 57 }
michael@0 58 }
michael@0 59
michael@0 60 for (var i = 0; i < testCount; i++) {
michael@0 61 worker.postMessage("");
michael@0 62 }
michael@0 63
michael@0 64 SimpleTest.waitForExplicitFinish();
michael@0 65
michael@0 66 </script>
michael@0 67 </pre>
michael@0 68 </body>
michael@0 69 </html>

mercurial