function testExecuteScriptIsAbortedWhenWebViewSourceIsInvalid() {
  var webview = document.createElement('webview');
  var abortCount = 0;

  webview.addEventListener('loadstop', loadDone);
  webview.addEventListener('loadabort', loadAbort);
  webview.addEventListener('exit', function(e) {
    // We should not crash.
    embedder.test.fail();
  });

  function loadDone() {
    window.console.log(
        '2. WebView loaded \'about:blank\'.  Now call \'executeScript()\'');
    webview.executeScript( {code: '/* no op */'}, webviewStop);
  }

  function webviewStop() {
    window.console.log(
        '3. Executing the script.  Set webview.src to ' +
        '\'http:\' (which is invalid and should cause an abort)');
    webview.src = 'http:';
  }

  function loadAbort() {
    abortCount++;
    if (abortCount == 1) {
      window.console.log(
          '4. In \'loadabort\' handler.  Execute the script again, ' +
          'which should cause the \'loadabort\' handler to be called again ' +
          '(the browser should NOT crash)');
      webview.executeScript( {code: '/* no op */'}, webviewStop);
    } else {
      window.console.log('5. In \'loadabort\' handler for 2nd time. Success!!');
      embedder.test.succeed();
    }
  }

  window.console.log('1. Set webview.src to \'about:blank\'');
  webview.src = 'about:blank';
  document.body.appendChild(webview);
}
// that the browser does not crash during the second call to executeScript()).
that the browser does not crash during the second call to executeScript()).
that the browser does not crash during the second call to executeScript () ) .
function testExecuteScriptIsAbortedWhenWebViewSourceIsInvalid() {
  var webview = document.createElement('webview');
  var abortCount = 0;
  webview.addEventListener('loadstop', loadDone);
  webview.addEventListener('loadabort', loadAbort);
  webview.addEventListener('exit', function(e) {
    embedder.test.fail();
  });
  function loadDone() {
    window.console.log(
        '2. WebView loaded \'about:blank\'.  Now call \'executeScript()\'');
    webview.executeScript( {code: '/* no op */'}, webviewStop);
  }
  function webviewStop() {
    window.console.log(
        '3. Executing the script.  Set webview.src to ' +
        '\'http:\' (which is invalid and should cause an abort)');
    webview.src = 'http:';
  }
  function loadAbort() {
    abortCount++;
    if (abortCount == 1) {
      window.console.log(
          '4. In \'loadabort\' handler.  Execute the script again, ' +
          'which should cause the \'loadabort\' handler to be called again ' +
          '(the browser should NOT crash)');
      webview.executeScript( {code: '/* no op */'}, webviewStop);
    } else {
      window.console.log('5. In \'loadabort\' handler for 2nd time. Success!!');
      embedder.test.succeed();
    }
  }
  window.console.log('1. Set webview.src to \'about:blank\'');
  webview.src = 'about:blank';
  document.body.appendChild(webview);
}
function testExecuteScriptIsAbortedWhenWebViewSourceIsInvalid ( ) { var webview = document . createElement ( 'webview' ) ; var abortCount = 0 ; webview . addEventListener ( 'loadstop' , loadDone ) ; webview . addEventListener ( 'loadabort' , loadAbort ) ; webview . addEventListener ( 'exit' , function ( e ) { embedder . test . fail ( ) ; } ) ; function loadDone ( ) { window . console . log ( '2. WebView loaded \'about:blank\'.  Now call \'executeScript()\'' ) ; webview . executeScript ( { code : '/* no op */' } , webviewStop ) ; } function webviewStop ( ) { window . console . log ( '3. Executing the script.  Set webview.src to ' + '\'http:\' (which is invalid and should cause an abort)' ) ; webview . src = 'http:' ; } function loadAbort ( ) { abortCount ++ ; if ( abortCount == 1 ) { window . console . log ( '4. In \'loadabort\' handler.  Execute the script again, ' + 'which should cause the \'loadabort\' handler to be called again ' + '(the browser should NOT crash)' ) ; webview . executeScript ( { code : '/* no op */' } , webviewStop ) ; } else { window . console . log ( '5. In \'loadabort\' handler for 2nd time. Success!!' ) ; embedder . test . succeed ( ) ; } } window . console . log ( '1. Set webview.src to \'about:blank\'' ) ; webview . src = 'about:blank' ; document . body . appendChild ( webview ) ; }
that the browser does not crash during the second call to executeScript()).
that the browser does not crash during the second call to executeScript () ) .
// We should not crash.