OLD | NEW |
| (Empty) |
1 <!-- | |
2 /* | |
3 --> | |
4 <!doctype html> | |
5 <title>same-origin checks</title> | |
6 <link rel=help href="http://www.whatwg.org/html/#dom-sharedworker"> | |
7 <script src="/resources/testharness.js"></script> | |
8 <script src="/resources/testharnessreport.js"></script> | |
9 <div id="log"></div> | |
10 <script> | |
11 // Needed to prevent a race condition if a worker throws an exception that may o
r may | |
12 // not propogate to the window before the tests finish | |
13 setup({allow_uncaught_exception: true}); | |
14 | |
15 function testSharedWorkerHelper(t, script) { | |
16 try { | |
17 var worker = new SharedWorker(script, ''); | |
18 worker.onerror = t.step_func_done(function(e) { | |
19 assert_true(e instanceof ErrorEvent); | |
20 }); | |
21 } catch (e) { | |
22 t.step_func_done(function(e) { assert_true(true); }); | |
23 } | |
24 } | |
25 | |
26 test(function() { | |
27 assert_throws("SecurityError", function() { new SharedWorker('unsupported:', '
'); }); | |
28 }, "unsupported_scheme"); | |
29 | |
30 async_test(function() { | |
31 var worker = new SharedWorker('data:,onconnect = function(e) { e.ports[0].post
Message(1); }', ''); | |
32 worker.port.onmessage = this.step_func_done(function(e) { | |
33 assert_equals(e.data, 1); | |
34 }); | |
35 }, "data_url"); | |
36 | |
37 async_test(function(t) { | |
38 testSharedWorkerHelper(this, 'javascript:""'); | |
39 }, "javascript_url"); | |
40 | |
41 async_test(function(t) { | |
42 testSharedWorkerHelper(this, 'about:blank'); | |
43 }, "about_blank"); | |
44 | |
45 async_test(function(t) { | |
46 testSharedWorkerHelper(this, 'http://www.opera.com/'); | |
47 }, "opera_com"); | |
48 | |
49 async_test(function(t) { | |
50 testSharedWorkerHelper(this, location.protocol+'//'+location.hostname+':81/'); | |
51 }, "port_81"); | |
52 | |
53 async_test(function(t) { | |
54 testSharedWorkerHelper(this, 'https://'+location.hostname+':80/'); | |
55 }, "https_port_80"); | |
56 | |
57 async_test(function(t) { | |
58 testSharedWorkerHelper(this, 'https://'+location.hostname+':8000/'); | |
59 }, "https_port_8000"); | |
60 | |
61 async_test(function(t) { | |
62 testSharedWorkerHelper(this, 'http://'+location.hostname+':8012/'); | |
63 }, "http_port_8012"); | |
64 </script> | |
65 <!-- | |
66 */ | |
67 //--> | |
OLD | NEW |