1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/workers/test/test_location.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,72 @@ 1.4 +<!-- 1.5 + Any copyright is dedicated to the Public Domain. 1.6 + http://creativecommons.org/publicdomain/zero/1.0/ 1.7 +--> 1.8 +<!DOCTYPE HTML> 1.9 +<html> 1.10 +<!-- 1.11 +Tests of DOM Worker Location 1.12 +--> 1.13 +<head> 1.14 + <title>Test for DOM Worker Location</title> 1.15 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.16 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.17 +</head> 1.18 +<body> 1.19 +<p id="display"></p> 1.20 +<div id="content" style="display: none"> 1.21 + 1.22 +</div> 1.23 +<pre id="test"> 1.24 +<script class="testbody" language="javascript"> 1.25 + 1.26 + var thisFilename = "test_location.html"; 1.27 + var workerFilename = "location_worker.js"; 1.28 + 1.29 + var href = window.location.href 1.30 + var queryPos = href.lastIndexOf(window.location.search); 1.31 + var baseHref = href.substr(0, href.substr(0, queryPos).lastIndexOf("/") + 1); 1.32 + 1.33 + var path = window.location.pathname; 1.34 + var basePath = path.substr(0, path.lastIndexOf("/") + 1); 1.35 + 1.36 + var strings = { 1.37 + "toString": baseHref + workerFilename, 1.38 + "href": baseHref + workerFilename, 1.39 + "protocol": window.location.protocol, 1.40 + "host": window.location.host, 1.41 + "hostname": window.location.hostname, 1.42 + "port": window.location.port, 1.43 + "pathname": basePath + workerFilename, 1.44 + "search": "", 1.45 + "hash": "", 1.46 + "origin": "http://mochi.test:8888" 1.47 + }; 1.48 + 1.49 + var lastSlash = href.substr(0, queryPos).lastIndexOf("/") + 1; 1.50 + is(thisFilename, 1.51 + href.substr(lastSlash, queryPos - lastSlash), 1.52 + "Correct filename "); 1.53 + 1.54 + var worker = new Worker(workerFilename); 1.55 + 1.56 + worker.onmessage = function(event) { 1.57 + if (event.data.string == "testfinished") { 1.58 + SimpleTest.finish(); 1.59 + return; 1.60 + } 1.61 + ok(event.data.string in strings, event.data.string); 1.62 + is(event.data.value, strings[event.data.string], event.data.string); 1.63 + }; 1.64 + 1.65 + worker.onerror = function(event) { 1.66 + ok(false, "Worker had an error: " + event.message); 1.67 + SimpleTest.finish(); 1.68 + } 1.69 + 1.70 + SimpleTest.waitForExplicitFinish(); 1.71 + 1.72 +</script> 1.73 +</pre> 1.74 +</body> 1.75 +</html>