B2G/gecko/dom/network/tests/unit/test_tcpsocket.js
/**
 * Test that calling send with enough data to buffer twice in a row without
 * waiting for ondrain still results in ondrain being invoked at least once.
 */
Test that calling send with enough data to buffer twice in a row without
waiting for ondrain still results in ondrain being invoked at least once.
Test that calling send with enough data to buffer twice in a row without waiting for ondrain still results in ondrain being invoked at least once .
function bufferTwice() {
  let yays = makeJointSuccess(
    ['ondata', 'ondrain', 'serverclose', 'clientclose']);
  let double_array = new Uint8Array(BIG_ARRAY.concat(BIG_ARRAY_2));
  server.ondata = makeExpectData(
    "ondata", double_array, false, yays.ondata);
  server.onclose = yays.serverclose;
  sock.onclose = yays.clientclose;
  sock.ondrain = function () {
    sock.close();
    yays.ondrain();
  }
  if (sock.send(BIG_ARRAY_BUFFER)) {
    throw new Error("sock.send(BIG_TYPED_ARRAY) did not return false to indicate buffering");
  }
  if (sock.send(BIG_ARRAY_BUFFER_2)) {
    throw new Error("sock.send(BIG_TYPED_ARRAY_2) did not return false to indicate buffering on second synchronous call to send");
  }
}
function bufferTwice ( ) { let yays = makeJointSuccess ( [ 'ondata' , 'ondrain' , 'serverclose' , 'clientclose' ] ) ; let double_array = new Uint8Array ( BIG_ARRAY . concat ( BIG_ARRAY_2 ) ) ; server . ondata = makeExpectData ( "ondata" , double_array , false , yays . ondata ) ; server . onclose = yays . serverclose ; sock . onclose = yays . clientclose ; sock . ondrain = function ( ) { sock . close ( ) ; yays . ondrain ( ) ; } if ( sock . send ( BIG_ARRAY_BUFFER ) ) { throw new Error ( "sock.send(BIG_TYPED_ARRAY) did not return false to indicate buffering" ) ; } if ( sock . send ( BIG_ARRAY_BUFFER_2 ) ) { throw new Error ( "sock.send(BIG_TYPED_ARRAY_2) did not return false to indicate buffering on second synchronous call to send" ) ; } }
Test that calling send with enough data to buffer twice in a row without
 waiting for ondrain still results in ondrain being invoked at least once.
Test that calling send with enough data to buffer twice in a row without waiting for ondrain still results in ondrain being invoked at least once .