function testTerminateAfterExit() {
  var webview = document.createElement('webview');
  webview.setAttribute('partition', arguments.callee.name);
  var loadstopSucceedsTest = false;
  webview.addEventListener('loadstop', function(evt) {
    embedder.test.assertEq('loadstop', evt.type);
    if (loadstopSucceedsTest) {
      embedder.test.succeed();
      return;
    }

    webview.terminate();
  });

  webview.addEventListener('exit', function(evt) {
    embedder.test.assertEq('exit', evt.type);
    // Call terminate again.
    webview.terminate();
    // Load another page. The test would pass when loadstop is called on
    // this second page. This would hopefully catch if call to
    // webview.terminate() caused a browser crash.
    setTimeout(function() {
      loadstopSucceedsTest = true;
      webview.setAttribute('src', 'data:text/html,test second page');
    }, 0);
  });

  webview.setAttribute('src', 'data:text/html,test terminate() crash.');
  document.body.appendChild(webview);
}
// terminated. This makes sure we ignore the call gracefully.
terminated. This makes sure we ignore the call gracefully.
terminated . This makes sure we ignore the call gracefully .
function testTerminateAfterExit() {
  var webview = document.createElement('webview');
  webview.setAttribute('partition', arguments.callee.name);
  var loadstopSucceedsTest = false;
  webview.addEventListener('loadstop', function(evt) {
    embedder.test.assertEq('loadstop', evt.type);
    if (loadstopSucceedsTest) {
      embedder.test.succeed();
      return;
    }
    webview.terminate();
  });
  webview.addEventListener('exit', function(evt) {
    embedder.test.assertEq('exit', evt.type);
    webview.terminate();
    setTimeout(function() {
      loadstopSucceedsTest = true;
      webview.setAttribute('src', 'data:text/html,test second page');
    }, 0);
  });
  webview.setAttribute('src', 'data:text/html,test terminate() crash.');
  document.body.appendChild(webview);
}
function testTerminateAfterExit ( ) { var webview = document . createElement ( 'webview' ) ; webview . setAttribute ( 'partition' , arguments . callee . name ) ; var loadstopSucceedsTest = false ; webview . addEventListener ( 'loadstop' , function ( evt ) { embedder . test . assertEq ( 'loadstop' , evt . type ) ; if ( loadstopSucceedsTest ) { embedder . test . succeed ( ) ; return ; } webview . terminate ( ) ; } ) ; webview . addEventListener ( 'exit' , function ( evt ) { embedder . test . assertEq ( 'exit' , evt . type ) ; webview . terminate ( ) ; setTimeout ( function ( ) { loadstopSucceedsTest = true ; webview . setAttribute ( 'src' , 'data:text/html,test second page' ) ; } , 0 ) ; } ) ; webview . setAttribute ( 'src' , 'data:text/html,test terminate() crash.' ) ; document . body . appendChild ( webview ) ; }
terminated.
terminated .
// Call terminate again. // Load another page. The test would pass when loadstop is called on // this second page. This would hopefully catch if call to // webview.terminate() caused a browser crash.