dom/workers/test/test_location.html

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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">
    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"
    44   };
    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;
    57     }
    58     ok(event.data.string in strings, event.data.string);
    59     is(event.data.value, strings[event.data.string], event.data.string);
    60   };
    62   worker.onerror = function(event) {
    63     ok(false, "Worker had an error: " + event.message);
    64     SimpleTest.finish();
    65   }
    67   SimpleTest.waitForExplicitFinish();
    69 </script>
    70 </pre>
    71 </body>
    72 </html>

mercurial