function testExecuteScriptIsAbortedWhenWebViewSourceIsChanged() {
  var webview = document.createElement('webview');
  webview.addEventListener('loadstop', function onLoadStop(e) {
    window.console.log('2. Inject script to trigger a guest-initiated ' +
        'navigation.');
    var navUrl = 'data:text/html,trigger nav';
    webview.executeScript({
      code: 'window.location.href = "' + navUrl + '";'
    });

    window.console.log('3. Listening for the load that will be started as a ' +
        'result of 2.');
    webview.addEventListener('loadstart', function onLoadStart(e) {
      embedder.test.assertEq('about:blank', webview.src);
      window.console.log('4. Attempting to inject script into about:blank. ' +
          'This is expected to fail.');
      webview.executeScript(
        { code: 'document.body.style.backgroundColor = "red";' },
        function(results) {
          window.console.log(
              '5. Verify that executeScript has, indeed, failed.');
          embedder.test.assertEq(null, results);
          embedder.test.assertEq(navUrl, webview.src);
          embedder.test.succeed();
        }
      );
      webview.removeEventListener('loadstart', onLoadStart);
    });
    webview.removeEventListener('loadstop', onLoadStop);
  });

  window.console.log('1. Performing initial navigation.');
  webview.setAttribute('src', 'about:blank');
  document.body.appendChild(webview);
}
// time it arrives in the guest process.
time it arrives in the guest process.
time it arrives in the guest process .
function testExecuteScriptIsAbortedWhenWebViewSourceIsChanged() {
  var webview = document.createElement('webview');
  webview.addEventListener('loadstop', function onLoadStop(e) {
    window.console.log('2. Inject script to trigger a guest-initiated ' +
        'navigation.');
    var navUrl = 'data:text/html,trigger nav';
    webview.executeScript({
      code: 'window.location.href = "' + navUrl + '";'
    });
    window.console.log('3. Listening for the load that will be started as a ' +
        'result of 2.');
    webview.addEventListener('loadstart', function onLoadStart(e) {
      embedder.test.assertEq('about:blank', webview.src);
      window.console.log('4. Attempting to inject script into about:blank. ' +
          'This is expected to fail.');
      webview.executeScript(
        { code: 'document.body.style.backgroundColor = "red";' },
        function(results) {
          window.console.log(
              '5. Verify that executeScript has, indeed, failed.');
          embedder.test.assertEq(null, results);
          embedder.test.assertEq(navUrl, webview.src);
          embedder.test.succeed();
        }
      );
      webview.removeEventListener('loadstart', onLoadStart);
    });
    webview.removeEventListener('loadstop', onLoadStop);
  });
  window.console.log('1. Performing initial navigation.');
  webview.setAttribute('src', 'about:blank');
  document.body.appendChild(webview);
}
function testExecuteScriptIsAbortedWhenWebViewSourceIsChanged ( ) { var webview = document . createElement ( 'webview' ) ; webview . addEventListener ( 'loadstop' , function onLoadStop ( e ) { window . console . log ( '2. Inject script to trigger a guest-initiated ' + 'navigation.' ) ; var navUrl = 'data:text/html,trigger nav' ; webview . executeScript ( { code : 'window.location.href = "' + navUrl + '";' } ) ; window . console . log ( '3. Listening for the load that will be started as a ' + 'result of 2.' ) ; webview . addEventListener ( 'loadstart' , function onLoadStart ( e ) { embedder . test . assertEq ( 'about:blank' , webview . src ) ; window . console . log ( '4. Attempting to inject script into about:blank. ' + 'This is expected to fail.' ) ; webview . executeScript ( { code : 'document.body.style.backgroundColor = "red";' } , function ( results ) { window . console . log ( '5. Verify that executeScript has, indeed, failed.' ) ; embedder . test . assertEq ( null , results ) ; embedder . test . assertEq ( navUrl , webview . src ) ; embedder . test . succeed ( ) ; } ) ; webview . removeEventListener ( 'loadstart' , onLoadStart ) ; } ) ; webview . removeEventListener ( 'loadstop' , onLoadStop ) ; } ) ; window . console . log ( '1. Performing initial navigation.' ) ; webview . setAttribute ( 'src' , 'about:blank' ) ; document . body . appendChild ( webview ) ; }
time it arrives in the guest process.
time it arrives in the guest process .