test_tcpsocket_legacy.html (1923B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 Test of legacy navigator interface for opening TCPSocket/TCPServerSocket. 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 885982</title> 9 <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 10 <link rel="stylesheet" type="text/css" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> 11 </head> 12 <body> 13 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1084245">Mozilla Bug 1084245</a> 14 <p id="display"></p> 15 <div id="content" style="display: none"> 16 17 </div> 18 <pre id="test"> 19 </pre> 20 <script> 21 SimpleTest.waitForExplicitFinish(); 22 23 function runTest() { 24 // See bug 903830; in e10s mode we never get to find out the localPort if we 25 // let it pick a free port by choosing 0. This is the same port the xpcshell 26 // test was using. 27 var serverPort = 8085; 28 29 var listeningServer = navigator.mozTCPSocket.listen(serverPort, 30 { binaryType: 'arraybuffer' }, 31 -1); 32 listeningServer.onconnect = function(ev) { 33 ok(true, "got server connect"); 34 listeningServer.close(); 35 listeningServer = null; 36 ev.socket.close() 37 } 38 39 var clientSocket = navigator.mozTCPSocket.open('127.0.0.1', serverPort, 40 { binaryType: 'arraybuffer' }); 41 clientSocket.onopen = function() { ok(true, "got client open"); } 42 clientSocket.onclose = function() { 43 ok(true, "got client close"); 44 clientSocket.close(); 45 clientSocket = null; 46 setTimeout(function() { 47 // This just helps the test harness clean up quickly 48 SpecialPowers.forceCC(); 49 SpecialPowers.forceGC(); 50 SimpleTest.finish(); 51 }, 0); 52 } 53 } 54 runTest(); // we used to invoke this as part of a moot pref-setting callback 55 </script> 56 </body> 57 </html>