Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
1 <!--
2 Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/
4 -->
5 <html>
6 <head>
7 <title>Test for DOM Worker Threads</title>
8 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
9 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
10 </head>
11 <body>
12 <pre id="test">
13 <script class="testbody" type="text/javascript">
14 "use strict";
16 try {
17 var worker = new Worker("about:blank");
18 ok(false, "Shouldn't success!");
20 worker.onmessage = function(event) {
21 ok(false, "Shouldn't get a message!");
22 SimpleTest.finish();
23 }
25 worker.onerror = function(event) {
26 ok(false, "Shouldn't get a error message!");
27 SimpleTest.finish();
28 }
29 } catch (e) {
30 ok(!worker, "worker should not be created");
31 is(e.name, "SecurityError", "SecurityError should be thrown");
32 is(e.code, DOMException.SECURITY_ERR, "SECURITY_ERR should be thrown");
33 }
35 (function(){
36 function workerfunc() {
37 try {
38 var subworker = new Worker("about:blank");
39 postMessage({});
40 } catch (e) {
41 postMessage({name: e.name, code: e.code});
42 }
43 }
44 var b = new Blob([workerfunc+'workerfunc();']);
45 var u = URL.createObjectURL(b);
46 function callworker(i) {
47 try {
48 var w = new Worker(u);
49 URL.revokeObjectURL(u);
50 is(i, 0, 'worker creation succeeded');
51 } catch (e) {
52 is(i, 1, 'worker creation failed');
53 SimpleTest.finish();
54 return;
55 }
56 w.onmessage = function(e) {
57 is(e.data.name, "SecurityError", "SecurityError should be thrown");
58 is(e.data.code, DOMException.SECURITY_ERR, "SECURITY_ERR should be thrown");
59 if (++i < 2) callworker(i);
60 else SimpleTest.finish();
61 };
62 }
63 callworker(0);
64 })();
66 SimpleTest.waitForExplicitFinish();
68 </script>
69 </pre>
70 </body>
71 </html>