Backed out changeset 06f41c22f3a6 (bug 1888460) for causing linux xpcshell failures...
[gecko.git] / dom / workers / test / test_location.html
blob55c94ae1cf1cd2416a2196d112c98ebf5b929e7b
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 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">
19 </div>
20 <pre id="test">
21 <script class="testbody" language="javascript">
23 var thisFilename = "test_location.html";
24 var workerFilename = "location_worker.js";
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);
30 var path = window.location.pathname;
31 var basePath = path.substr(0, path.lastIndexOf("/") + 1);
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"
46 var lastSlash = href.substr(0, queryPos).lastIndexOf("/") + 1;
47 is(thisFilename,
48 href.substr(lastSlash, queryPos - lastSlash),
49 "Correct filename ");
51 var worker = new Worker(workerFilename);
53 worker.onmessage = function(event) {
54 if (event.data.string == "testfinished") {
55 SimpleTest.finish();
56 return;
58 ok(event.data.string in strings, event.data.string);
59 is(event.data.value, strings[event.data.string], event.data.string);
62 worker.onerror = function(event) {
63 ok(false, "Worker had an error: " + event.message);
64 SimpleTest.finish();
67 SimpleTest.waitForExplicitFinish();
69 </script>
70 </pre>
71 </body>
72 </html>