1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/base/test/test_websocket_hello.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,49 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +--> 1.8 +<head> 1.9 + <title>Basic websocket test</title> 1.10 + <script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.11 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> 1.12 +</head> 1.13 +<body onload="testWebSocket()"> 1.14 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=472529">Mozilla Bug </a> 1.15 +<p id="display"></p> 1.16 +<div id="content" style="display: none"> 1.17 +</div> 1.18 +<pre id="test"> 1.19 +<script class="testbody" type="text/javascript"> 1.20 + 1.21 +var ws; 1.22 + 1.23 +function testWebSocket () { 1.24 + ws = new WebSocket("ws://mochi.test:8888/tests/content/base/test/file_websocket_hello"); 1.25 + ws.onopen = function(e) { 1.26 + ws.send("data"); 1.27 + } 1.28 + ws.onclose = function(e) { 1.29 + } 1.30 + ws.onerror = function(e) { 1.31 + ok(false, "onerror called!"); 1.32 + SimpleTest.finish(); 1.33 + } 1.34 + ws.onmessage = function(e) { 1.35 + is(e.data, "Hello world!", "Wrong data"); 1.36 + ws.close(); 1.37 + SimpleTest.finish(); 1.38 + } 1.39 +} 1.40 + 1.41 +SimpleTest.waitForExplicitFinish(); 1.42 + 1.43 +</script> 1.44 +</pre> 1.45 +<div> 1.46 + 1.47 + 1.48 +</div> 1.49 + 1.50 + 1.51 +</body> 1.52 +</html>