Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
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 (Bug 437152) |
michael@0 | 9 | --> |
michael@0 | 10 | <head> |
michael@0 | 11 | <title>Test for DOM Worker Threads (Bug 437152)</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 | <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=437152">DOM Worker Threads Bug 437152</a> |
michael@0 | 17 | <p id="display"></p> |
michael@0 | 18 | <div id="content" style="display: none"> |
michael@0 | 19 | |
michael@0 | 20 | </div> |
michael@0 | 21 | <pre id="test"> |
michael@0 | 22 | <script class="testbody" type="text/javascript"> |
michael@0 | 23 | |
michael@0 | 24 | var worker = new Worker("simpleThread_worker.js"); |
michael@0 | 25 | |
michael@0 | 26 | worker.addEventListener("message",function(event) { |
michael@0 | 27 | is(event.target, worker); |
michael@0 | 28 | switch (event.data) { |
michael@0 | 29 | case "no-op": |
michael@0 | 30 | break; |
michael@0 | 31 | case "started": |
michael@0 | 32 | is(gotErrors, true); |
michael@0 | 33 | worker.postMessage("no-op"); |
michael@0 | 34 | worker.postMessage("stop"); |
michael@0 | 35 | break; |
michael@0 | 36 | case "stopped": |
michael@0 | 37 | worker.postMessage("no-op"); |
michael@0 | 38 | SimpleTest.finish(); |
michael@0 | 39 | break; |
michael@0 | 40 | default: |
michael@0 | 41 | ok(false, "Unexpected message:" + event.data); |
michael@0 | 42 | SimpleTest.finish(); |
michael@0 | 43 | } |
michael@0 | 44 | }, false); |
michael@0 | 45 | |
michael@0 | 46 | var gotErrors = false; |
michael@0 | 47 | worker.onerror = function(event) { |
michael@0 | 48 | event.preventDefault(); |
michael@0 | 49 | is(event.target, worker); |
michael@0 | 50 | is(event.message, "InternalError: uncaught exception: Bad message: asdf"); |
michael@0 | 51 | |
michael@0 | 52 | worker.onerror = function(otherEvent) { |
michael@0 | 53 | otherEvent.preventDefault(); |
michael@0 | 54 | is(otherEvent.target, worker); |
michael@0 | 55 | is(otherEvent.message, "ReferenceError: Components is not defined"); |
michael@0 | 56 | gotErrors = true; |
michael@0 | 57 | |
michael@0 | 58 | worker.onerror = function(oneMoreEvent) { |
michael@0 | 59 | ok(false, "Worker had an error:" + oneMoreEvent.message); |
michael@0 | 60 | SimpleTest.finish(); |
michael@0 | 61 | }; |
michael@0 | 62 | }; |
michael@0 | 63 | }; |
michael@0 | 64 | |
michael@0 | 65 | worker.postMessage("asdf"); |
michael@0 | 66 | worker.postMessage("components"); |
michael@0 | 67 | worker.postMessage("start"); |
michael@0 | 68 | |
michael@0 | 69 | SimpleTest.waitForExplicitFinish(); |
michael@0 | 70 | |
michael@0 | 71 | </script> |
michael@0 | 72 | </pre> |
michael@0 | 73 | </body> |
michael@0 | 74 | </html> |
michael@0 | 75 |