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