Create a new TAB and inject script

Hi, I have tried everything but i can’t do it.

I keep getting the errors:
Could not establish connection. Receiving end does not exist.
No matching window

I create a new tab this way:
browser.tabs.create({ url: “http://www.mysite.com/page.php”, active: true }, f);

then through
browser.tabs.onUpdated.addListener(myfunc)
I check the tabId and his status to be “complete” before injecting my content script with:
browser.tabs.executeScript(tabId, {file: “/content_scripts/myscript.js”}); (I also tried to use runAt: “document_start” in the extensionTypes.InjectDetails)
chrome.tabs.sendMessage(tabId, null);

If I open the tab manually without using browser.tabs.create everything works fine.

Can you show all of the code? Are you adding the event listener after you create the tab?

Thank you for your answer. At the end I gave up and used the old sdk and everything went fine.
Anyway I added the event listener before opening the new tab, I could see when the tab was “loading” and when it was “completed”, maybe Im wrong but it looks like a bug

1 Like

It’d be great if you can create a minimal test case and submit a bug report here. Thanks!