Listen to message from different tab

I have addon which creates new tab when I click on element. In the new tab I load html page inspector.html which loads page script inspector.js:

chrome.runtime.onMessage.addListener(
function (package){
  if (package.command !== "add" )
    return false;
  $("div#content").append(package.innerhtml);     
}
);

So when I clicked in the original tab, message has been send:

if (make_it_easy.tabOpened)
browser.runtime.sendMessage(
{ message:“add”,
subject: “innerhtml”,
innerhtml: innnerhtml,
target: { tab: { id: make_it_easy.tabID } }
// sender:{id:tabs[0].id }
});

Which sends message with innerHTML. However I cannot intercept the message in the page script in the tab. Where is problem? Is the message sent to all existing tabs or to tabs of the addon? I added breakpoint to the line with if (package.command !== "add" ) but the code is not paused on the line when I click element. Notice: when I click the element, the new tab exists but is not selected nor active.

Messages need to go through the background script, I think.

If you have access to chrome.runntime.getBackgroundPage() then you should also be able to send messages to content tabs (you may have to use the chrome object of the background page).

I also encountered a Firefox bug that the chrome object of an embedded iframe was less capable than that of it’s window.top

I have managed it some how.

What I do is that I click on a web page element, and I open new tab where I sent the content of the element - innerHTML. Now I found that I got the element listed 4 times instead once only. I’ll need to make some diagram to think about it how this can happen.