function testConnect() {
  var port = chrome.runtime.connect(targetAppId);
  var gotResponse = false;

  port.onMessage.addListener(function(response) {
    if (response == 'ack_connect_message') {
      chrome.test.succeed();
      gotResponse = true;
    } else {
      chrome.test.fail();
    }

    port.disconnect();
  });

  port.onDisconnect.addListener(function() {
    if (gotResponse)
      chrome.test.succeed();
    else
      chrome.test.fail();
  });

  port.postMessage('hello');
}
// Open a port to the ephemeral app, send a message and expect a response.
Open a port to the ephemeral app, send a message and expect a response.
Open a port to the ephemeral app send a message and expect a response .
function testConnect() {
  var port = chrome.runtime.connect(targetAppId);
  var gotResponse = false;
  port.onMessage.addListener(function(response) {
    if (response == 'ack_connect_message') {
      chrome.test.succeed();
      gotResponse = true;
    } else {
      chrome.test.fail();
    }
    port.disconnect();
  });
  port.onDisconnect.addListener(function() {
    if (gotResponse)
      chrome.test.succeed();
    else
      chrome.test.fail();
  });
  port.postMessage('hello');
}
function testConnect ( ) { var port = chrome . runtime . connect ( targetAppId ) ; var gotResponse = false ; port . onMessage . addListener ( function ( response ) { if ( response == 'ack_connect_message' ) { chrome . test . succeed ( ) ; gotResponse = true ; } else { chrome . test . fail ( ) ; } port . disconnect ( ) ; } ) ; port . onDisconnect . addListener ( function ( ) { if ( gotResponse ) chrome . test . succeed ( ) ; else chrome . test . fail ( ) ; } ) ; port . postMessage ( 'hello' ) ; }
Open a port to the ephemeral app, send a message and expect a response.
Open a port to the ephemeral app send a message and expect a response .