function testExtension(messageToPost) {
  var onPostMessageReceived = function(e) {
    var data = JSON.parse(e.data);
    if (data.result === 'SUCCESS') {
      window.guestProcessId = data.guestProcessId;
      window.guestRenderFrameRoutingId = data.guestRenderFrameRoutingId;
      chrome.test.sendMessage('TEST_PASSED');
    } else {
      chrome.test.sendMessage('TEST_FAILED');
    }
  };

  var loaded = false;
  document.querySelector('#webview-tag-container').innerHTML =
      '<webview style="width: 100px; height: 100px;"' +
      ' src="' + embedder.guestURL + '"' +
      '></webview>';
  var webview = document.querySelector('webview');

  if (!webview) {
    chrome.test.fail('No <webview> element created');
    return null;
  }

  webview.addEventListener('loadstop', function(e) {
    if (!loaded) {
      loaded = true;
      window.addEventListener('message', onPostMessageReceived);
      webview.contentWindow.postMessage(messageToPost, '*');
    }
  });
}
// to the webview's content window.
to the webview's content window.
to the webview ' s content window .
function testExtension(messageToPost) {
  var onPostMessageReceived = function(e) {
    var data = JSON.parse(e.data);
    if (data.result === 'SUCCESS') {
      window.guestProcessId = data.guestProcessId;
      window.guestRenderFrameRoutingId = data.guestRenderFrameRoutingId;
      chrome.test.sendMessage('TEST_PASSED');
    } else {
      chrome.test.sendMessage('TEST_FAILED');
    }
  };
  var loaded = false;
  document.querySelector('#webview-tag-container').innerHTML =
      '<webview style="width: 100px; height: 100px;"' +
      ' src="' + embedder.guestURL + '"' +
      '></webview>';
  var webview = document.querySelector('webview');
  if (!webview) {
    chrome.test.fail('No <webview> element created');
    return null;
  }
  webview.addEventListener('loadstop', function(e) {
    if (!loaded) {
      loaded = true;
      window.addEventListener('message', onPostMessageReceived);
      webview.contentWindow.postMessage(messageToPost, '*');
    }
  });
}
function testExtension ( messageToPost ) { var onPostMessageReceived = function ( e ) { var data = JSON . parse ( e . data ) ; if ( data . result === 'SUCCESS' ) { window . guestProcessId = data . guestProcessId ; window . guestRenderFrameRoutingId = data . guestRenderFrameRoutingId ; chrome . test . sendMessage ( 'TEST_PASSED' ) ; } else { chrome . test . sendMessage ( 'TEST_FAILED' ) ; } } ; var loaded = false ; document . querySelector ( '#webview-tag-container' ) . innerHTML = '<webview style="width: 100px; height: 100px;"' + ' src="' + embedder . guestURL + '"' + '></webview>' ; var webview = document . querySelector ( 'webview' ) ; if ( ! webview ) { chrome . test . fail ( 'No <webview> element created' ) ; return null ; } webview . addEventListener ( 'loadstop' , function ( e ) { if ( ! loaded ) { loaded = true ; window . addEventListener ( 'message' , onPostMessageReceived ) ; webview . contentWindow . postMessage ( messageToPost , '*' ) ; } } ) ; }
to the webview's content window.
to the webview ' s content window .