B2G/gecko/dom/network/tests/unit/test_tcpsocket.js
/**
 * Connect to a port we know is not listening so an error is assured,
 * and make sure that onerror and onclose are fired on the client side.
 */
Connect to a port we know is not listening so an error is assured,
and make sure that onerror and onclose are fired on the client side.
Connect to a port we know is not listening so an error is assured and make sure that onerror and onclose are fired on the client side .
function badConnect() {
  sock = TCPSocket.open('127.0.0.1', 2);
  sock.onopen = makeFailureCase('open');
  sock.ondata = makeFailureCase('data');
  let success = makeSuccessCase('error');
  let gotError = false;
  sock.onerror = function(event) {
    do_check_eq(event.data.name, 'ConnectionRefusedError');
    gotError = true;
  };
  sock.onclose = function() {
    if (!gotError)
      do_throw('got close without error!');
    else
      success();
  };
}
function badConnect ( ) { sock = TCPSocket . open ( '127.0.0.1' , 2 ) ; sock . onopen = makeFailureCase ( 'open' ) ; sock . ondata = makeFailureCase ( 'data' ) ; let success = makeSuccessCase ( 'error' ) ; let gotError = false ; sock . onerror = function ( event ) { do_check_eq ( event . data . name , 'ConnectionRefusedError' ) ; gotError = true ; } ; sock . onclose = function ( ) { if ( ! gotError ) do_throw ( 'got close without error!' ) ; else success ( ) ; } ; }
Connect to a port we know is not listening so an error is assured,
 and make sure that onerror and onclose are fired on the client side.
Connect to a port we know is not listening so an error is assured and make sure that onerror and onclose are fired on the client side .
// There's probably nothing listening on tcp port 2.