tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

test_bug1081686.html (1604B)


      1 <!DOCTYPE HTML>
      2 <html>
      3 <!--
      4 -->
      5 <head>
      6  <title>bug 1081686</title>
      7  <script 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 <p id="display"></p>
     12 <div id="content" style="display: none">
     13 </div>
     14 <pre id="test">
     15 <script class="testbody" type="text/javascript">
     16 
     17 var ws;
     18 
     19 function forcegc()
     20 {
     21  SpecialPowers.forceGC();
     22  SpecialPowers.gc();
     23  setTimeout(function()
     24  {
     25    SpecialPowers.gc();
     26  }, 0);
     27 }
     28 
     29 function testWebSocket () {
     30  ws = new WebSocket("ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_hello");
     31  ws.onopen = function() {
     32    ws.send("data");
     33  }
     34  ws.onclose = function() {
     35    forcegc();
     36    setTimeout(function() {
     37      is(ws.readyState, 3, 'WebSocket is closed');
     38      is(ws.bufferedAmount, 0, 'WebSocket.bufferedAmount should be empty.');
     39      is(ws.binaryType, 'blob', 'WebSocket.binaryType is blob');
     40      ws.binaryType = 'arraybuffer';
     41      is(ws.binaryType, 'arraybuffer', 'WebSocket.binaryType is arraybuffer');
     42      is(ws.url, 'ws://mochi.test:8888/tests/dom/websocket/tests/file_websocket_hello', 'WebSocket.url is correct');
     43      ws.close();
     44      ws.send('foobar');
     45      SimpleTest.finish();
     46    }, 1000);
     47  }
     48 
     49  ws.onerror = function() {
     50    ok(false, "onerror called!");
     51    SimpleTest.finish();
     52  }
     53  ws.onmessage = function(e) {
     54    is(e.data, "Hello world!", "Wrong data");
     55    ws.close();
     56  }
     57 }
     58 
     59 SimpleTest.waitForExplicitFinish();
     60 SimpleTest.requestFlakyTimeout("untriaged");
     61 
     62 </script>
     63 </pre>
     64 <div>
     65 
     66 
     67 </div>
     68 
     69 
     70 </body>
     71 </html>