B2G/gecko/dom/system/gonk/tests/header_helpers.js
/**
 * Test whether specified function throws exception with expected
 * result.
 *
 * @param func
 *        Function to be tested.
 * @param message
 *        Message of expected exception. <code>null</code> for no throws.
 * @param stack
 *        Optional stack object to be printed. <code>null</code> for
 *        Components#stack#caller.
 */
Test whether specified function throws exception with expected
result.

@param func
Function to be tested.
@param message
Message of expected exception. null for no throws.
@param stack
Optional stack object to be printed. null for
Components#stack#caller.
Test whether specified function throws exception with expected result . @param func Function to be tested . @param message Message of expected exception . null for no throws . @param stack Optional stack object to be printed . null for Components#stack#caller .
function do_check_throws(func, message, stack)
{
  if (!stack)
    stack = Components.stack.caller;
  try {
    func();
  } catch (exc) {
    if (exc.message === message) {
      return;
    }
    do_throw("expecting exception '" + message
             + "', caught '" + exc.message + "'", stack);
  }
  if (message) {
    do_throw("expecting exception '" + message + "', none thrown", stack);
  }
}
function do_check_throws ( func , message , stack ) { if ( ! stack ) stack = Components . stack . caller ; try { func ( ) ; } catch ( exc ) { if ( exc . message === message ) { return ; } do_throw ( "expecting exception '" + message + "', caught '" + exc . message + "'" , stack ) ; } if ( message ) { do_throw ( "expecting exception '" + message + "', none thrown" , stack ) ; } }
Test whether specified function throws exception with expected
 result.
Test whether specified function throws exception with expected result .