B2G/gecko/dom/network/tests/unit/test_tcpsocket.js
/**
 * Test that sending a large amount of data works, that buffering
 * takes place (send returns true), and that ondrain is called once
 * the data has been sent.
 */
Test that sending a large amount of data works, that buffering
takes place (send returns true), and that ondrain is called once
the data has been sent.
Test that sending a large amount of data works that buffering takes place ( send returns true ) and that ondrain is called once the data has been sent .
function sendBig() {
  var yays = makeJointSuccess(['serverdata', 'clientdrain']),
      amount = 0;
  server.ondata = function (data) {
    amount += data.length;
    if (amount === BIG_TYPED_ARRAY.length) {
      yays.serverdata();
    }
  };
  sock.ondrain = function(evt) {
    if (sock.bufferedAmount) {
      do_throw("sock.bufferedAmount was > 0 in ondrain");
    }
    yays.clientdrain(evt);
  }
  if (sock.send(BIG_ARRAY_BUFFER)) {
    do_throw("expected sock.send to return false on large buffer send");
  }
}
function sendBig ( ) { var yays = makeJointSuccess ( [ 'serverdata' , 'clientdrain' ] ) , amount = 0 ; server . ondata = function ( data ) { amount += data . length ; if ( amount === BIG_TYPED_ARRAY . length ) { yays . serverdata ( ) ; } } ; sock . ondrain = function ( evt ) { if ( sock . bufferedAmount ) { do_throw ( "sock.bufferedAmount was > 0 in ondrain" ) ; } yays . clientdrain ( evt ) ; } if ( sock . send ( BIG_ARRAY_BUFFER ) ) { do_throw ( "expected sock.send to return false on large buffer send" ) ; } }
Test that sending a large amount of data works, that buffering
 takes place (send returns true), and that ondrain is called once
 the data has been sent.
Test that sending a large amount of data works that buffering takes place ( send returns true ) and that ondrain is called once the data has been sent .