OLD | NEW |
1 <html> | 1 <html> |
2 <body> | 2 <body> |
3 <p>Test worker invalid url exceptions. Should print two "PASS" statements.</p> | 3 <p>Test worker invalid url exceptions. Should print two "PASS" statements.</p> |
4 <div id=result></div> | 4 <div id=result></div> |
5 <script> | 5 <script> |
6 if (window.testRunner) | 6 if (window.testRunner) |
7 testRunner.dumpAsText(); | 7 testRunner.dumpAsText(); |
8 | 8 |
9 function log(message) | 9 function log(message) |
10 { | 10 { |
11 document.getElementById("result").innerHTML += message + "<br>"; | 11 document.getElementById("result").innerHTML += message + "<br>"; |
12 } | 12 } |
13 | 13 |
14 try { | 14 try { |
15 new SharedWorker("http://example.com/worker.js"); | 15 new SharedWorker("http://example.com/worker.js"); |
16 log("FAIL: No exception thrown when accessing a worker from another domain."
); | 16 log("FAIL: No exception thrown when accessing a worker from another domain."
); |
17 } catch (error) { | 17 } catch (error) { |
18 if (error.code == 18) | 18 if (error.code == 18) |
19 log("PASS: Got security error."); | 19 log("PASS: Got security error."); |
20 else | 20 else |
21 log("FAIL: Got error code " + error.code + ". Expected error code 18."); | 21 log("FAIL: Got error code " + error.code + ". Expected error code 18."); |
22 } | 22 } |
23 | 23 |
24 try { | 24 try { |
25 new SharedWorker(""); | 25 new SharedWorker("http://invalid:123$"); |
26 log("FAIL: No exception throw when accessing an invalid url."); | 26 log("FAIL: No exception throw when accessing an invalid url."); |
27 } catch (error) { | 27 } catch (error) { |
28 if (error.code == 12) | 28 if (error.code == 12) |
29 log("PASS: Got syntax error."); | 29 log("PASS: Got syntax error."); |
30 else | 30 else |
31 log("FAIL: Got error code " + error.code + ". Expected error code 12."); | 31 log("FAIL: Got error code " + error.code + ". Expected error code 12."); |
32 } | 32 } |
33 </script> | 33 </script> |
34 </body> | 34 </body> |
35 </html> | 35 </html> |
OLD | NEW |