runtime.connect problems

Hi, I've been trying out with the new Web Extensions but I've bumped into a problem while trying to create a port between the content script and the background script (with runtime.connect).
For some reason the listener in the onConnect event is never called.
As they're both marked as supported on MDN I imagine this is a bug. Is anyone aware of any problem in this? (BTW, runtime.sendMessage and onMessage work)
Yes, ports are supported, so this could be a bug.

Would you be able to share more code on what your extension is trying to do with the connection? Either code snippets or attach the extension to a feedback request.

You can share snippets here or the extension project via Feedback Assistant. Thanks!
Hi! I could reproduce this with a simple call to connect on the content script (browser.runtime.connect({ name: 'test' })) with just the listener on the background side:

Code Block js
browser.runtime.onConnect.addListener((p) => {
console.log('port connected', p);
});


The listener is never triggered.

The rest of the code (including the manifest) is just the boilerplate created by xcode. I change a few things in the manifest like adding the content script to every page and added "<all_urls>" permission but nothing more (it happens with or without these manifest changes).

Thanks a lot!
Have you made sure that your extension has access to the webpage the script is injected into? You can check this in Safari Websites Preferences.

Can you post a snippet of the content script? Did you verify it was running by setting a breakpoint in the content script?
Hi, thanks for the answer.
Yes, I did all that. Breakpoint, console.log etc. The content script is injected, it runs everything.
The content script is what I posted before, I think it was not clear from the previous message:
Code Block js
browser.runtime.connect({ name: 'test' })

I did try also sending a message afterwards with the port that returns from the connect fn in the content script (it does return a port in the content script, it just doesn't trigger the listener in the background).
I forgot to mention I ran the exact same thing in Firefox and it worked, to test if I was possibly doing something wrong.
runtime.connect problems
 
 
Q