function postMessageFromTab() {
      listenOnce(chrome.runtime.onConnect, function(port) {
        let expectedSender = {
          tab: testTab,
          frameId: 0, // Main frame
          url: testTab.url,
          id: chrome.runtime.id,
        };
        compareSenders(expectedSender, port.sender);
        listenOnce(port.onMessage, function(msg) {
          chrome.test.assertTrue(msg.testPostMessageFromTab);
          port.postMessage({success: true, portName: port.name});
          chrome.test.log("postMessageFromTab: got message from tab");
        });
      });

      var port = chrome.tabs.connect(testTab.id);
      port.postMessage({testPostMessageFromTab: true});
      chrome.test.log("postMessageFromTab: sent first message to tab");
      listenOnce(port.onMessage, function(msg) {
        port.disconnect();
      });
    }
// Tests that postMessage from the tab and its response works.
Tests that postMessage from the tab and its response works.
Tests that postMessage from the tab and its response works .
function postMessageFromTab() {
      listenOnce(chrome.runtime.onConnect, function(port) {
        let expectedSender = {
          tab: testTab,
          frameId: 0, 
          url: testTab.url,
          id: chrome.runtime.id,
        };
        compareSenders(expectedSender, port.sender);
        listenOnce(port.onMessage, function(msg) {
          chrome.test.assertTrue(msg.testPostMessageFromTab);
          port.postMessage({success: true, portName: port.name});
          chrome.test.log("postMessageFromTab: got message from tab");
        });
      });
      var port = chrome.tabs.connect(testTab.id);
      port.postMessage({testPostMessageFromTab: true});
      chrome.test.log("postMessageFromTab: sent first message to tab");
      listenOnce(port.onMessage, function(msg) {
        port.disconnect();
      });
    }
function postMessageFromTab ( ) { listenOnce ( chrome . runtime . onConnect , function ( port ) { let expectedSender = { tab : testTab , frameId : 0 , url : testTab . url , id : chrome . runtime . id , } ; compareSenders ( expectedSender , port . sender ) ; listenOnce ( port . onMessage , function ( msg ) { chrome . test . assertTrue ( msg . testPostMessageFromTab ) ; port . postMessage ( { success : true , portName : port . name } ) ; chrome . test . log ( "postMessageFromTab: got message from tab" ) ; } ) ; } ) ; var port = chrome . tabs . connect ( testTab . id ) ; port . postMessage ( { testPostMessageFromTab : true } ) ; chrome . test . log ( "postMessageFromTab: sent first message to tab" ) ; listenOnce ( port . onMessage , function ( msg ) { port . disconnect ( ) ; } ) ; }
Tests that postMessage from the tab and its response works.
Tests that postMessage from the tab and its response works .
// Main frame