dom/workers/test/test_errorwarning.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

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 Test javascript.options.strict in Workers
michael@0 9 -->
michael@0 10 <head>
michael@0 11 <title>Test javascript.options.strict in Workers</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" language="javascript">
michael@0 22
michael@0 23 var errors = 0;
michael@0 24 function errorHandler(e) {
michael@0 25 ok(true, "An error has been received!");
michael@0 26 errors++;
michael@0 27 }
michael@0 28
michael@0 29 function test_noErrors() {
michael@0 30 errors = 0;
michael@0 31
michael@0 32 var worker = new Worker('errorwarning_worker.js');
michael@0 33 worker.onerror = errorHandler;
michael@0 34 worker.onmessage = function(e) {
michael@0 35 if (e.data.type == 'ignore')
michael@0 36 return;
michael@0 37
michael@0 38 if (e.data.type == 'error') {
michael@0 39 errorHandler();
michael@0 40 return;
michael@0 41 }
michael@0 42
michael@0 43 if (e.data.type == 'finish') {
michael@0 44 ok(errors == 0, "Here we are with 0 errors!");
michael@0 45 runTests();
michael@0 46 return;
michael@0 47 }
michael@0 48 }
michael@0 49
michael@0 50 onerror = errorHandler;
michael@0 51 worker.postMessage({ loop: 5, errors: false });
michael@0 52 }
michael@0 53
michael@0 54 function test_errors() {
michael@0 55 errors = 0;
michael@0 56
michael@0 57 var worker = new Worker('errorwarning_worker.js');
michael@0 58 worker.onerror = errorHandler;
michael@0 59 worker.onmessage = function(e) {
michael@0 60 if (e.data.type == 'ignore')
michael@0 61 return;
michael@0 62
michael@0 63 if (e.data.type == 'error') {
michael@0 64 errorHandler();
michael@0 65 return;
michael@0 66 }
michael@0 67
michael@0 68 if (e.data.type == 'finish') {
michael@0 69 ok(errors != 0, "Here we are with errors!");
michael@0 70 runTests();
michael@0 71 return;
michael@0 72 }
michael@0 73 }
michael@0 74
michael@0 75 onerror = errorHandler;
michael@0 76 worker.postMessage({ loop: 5, errors: true });
michael@0 77 }
michael@0 78
michael@0 79 var tests = [ test_noErrors, test_errors ];
michael@0 80 function runTests() {
michael@0 81 var test = tests.shift();
michael@0 82 if (test) {
michael@0 83 test();
michael@0 84 } else {
michael@0 85 SimpleTest.finish();
michael@0 86 }
michael@0 87 }
michael@0 88
michael@0 89 runTests();
michael@0 90 SimpleTest.waitForExplicitFinish();
michael@0 91
michael@0 92 </script>
michael@0 93 </pre>
michael@0 94 </body>
michael@0 95 </html>

mercurial