content/base/test/test_websocket_hello.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 <!DOCTYPE HTML>
     2 <html>
     3 <!--
     4 -->
     5 <head>
     6   <title>Basic websocket test</title>
     7   <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
     8   <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
     9 </head>
    10 <body onload="testWebSocket()">
    11 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=472529">Mozilla Bug </a>
    12 <p id="display"></p>
    13 <div id="content" style="display: none">
    14 </div>
    15 <pre id="test">
    16 <script class="testbody" type="text/javascript">
    18 var ws;
    20 function testWebSocket () {
    21   ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket_hello");
    22   ws.onopen = function(e) {
    23     ws.send("data");
    24   }
    25   ws.onclose = function(e) {
    26   }
    27   ws.onerror = function(e) {
    28     ok(false, "onerror called!");
    29     SimpleTest.finish();
    30   }
    31   ws.onmessage = function(e) {
    32     is(e.data, "Hello world!", "Wrong data");
    33     ws.close();
    34     SimpleTest.finish();
    35   }
    36 }
    38 SimpleTest.waitForExplicitFinish();
    40 </script>
    41 </pre>
    42 <div>
    45 </div>
    48 </body>
    49 </html>

mercurial