|
1 <!-- |
|
2 Any copyright is dedicated to the Public Domain. |
|
3 http://creativecommons.org/publicdomain/zero/1.0/ |
|
4 --> |
|
5 <!DOCTYPE HTML> |
|
6 <html> |
|
7 <!-- |
|
8 Tests of DOM Worker Location |
|
9 --> |
|
10 <head> |
|
11 <title>Test for DOM Worker Location</title> |
|
12 <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> |
|
13 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> |
|
14 </head> |
|
15 <body> |
|
16 <p id="display"></p> |
|
17 <div id="content" style="display: none"> |
|
18 |
|
19 </div> |
|
20 <pre id="test"> |
|
21 <script class="testbody" language="javascript"> |
|
22 |
|
23 var thisFilename = "test_location.html"; |
|
24 var workerFilename = "location_worker.js"; |
|
25 |
|
26 var href = window.location.href |
|
27 var queryPos = href.lastIndexOf(window.location.search); |
|
28 var baseHref = href.substr(0, href.substr(0, queryPos).lastIndexOf("/") + 1); |
|
29 |
|
30 var path = window.location.pathname; |
|
31 var basePath = path.substr(0, path.lastIndexOf("/") + 1); |
|
32 |
|
33 var strings = { |
|
34 "toString": baseHref + workerFilename, |
|
35 "href": baseHref + workerFilename, |
|
36 "protocol": window.location.protocol, |
|
37 "host": window.location.host, |
|
38 "hostname": window.location.hostname, |
|
39 "port": window.location.port, |
|
40 "pathname": basePath + workerFilename, |
|
41 "search": "", |
|
42 "hash": "", |
|
43 "origin": "http://mochi.test:8888" |
|
44 }; |
|
45 |
|
46 var lastSlash = href.substr(0, queryPos).lastIndexOf("/") + 1; |
|
47 is(thisFilename, |
|
48 href.substr(lastSlash, queryPos - lastSlash), |
|
49 "Correct filename "); |
|
50 |
|
51 var worker = new Worker(workerFilename); |
|
52 |
|
53 worker.onmessage = function(event) { |
|
54 if (event.data.string == "testfinished") { |
|
55 SimpleTest.finish(); |
|
56 return; |
|
57 } |
|
58 ok(event.data.string in strings, event.data.string); |
|
59 is(event.data.value, strings[event.data.string], event.data.string); |
|
60 }; |
|
61 |
|
62 worker.onerror = function(event) { |
|
63 ok(false, "Worker had an error: " + event.message); |
|
64 SimpleTest.finish(); |
|
65 } |
|
66 |
|
67 SimpleTest.waitForExplicitFinish(); |
|
68 |
|
69 </script> |
|
70 </pre> |
|
71 </body> |
|
72 </html> |