Sending a Native Message to a Web Extension *activates* Safari :(

In some applications, a Safari Web Extension must receive a Native Message and process it in the background, without activating Safari.

For example, assuming that Safari Web Extensions will soon support the browser.bookmarks API, when a bookmarks syncing application needs to push a new bookmark from a source of truth into Safari's bookmarks, it will send a Native Message to the extension, and this may happen when Safari is not the active macOS application, for example if the user is writing email in Mail.

I am modifying Apple's Sea Creator sample code to establish a proof of concept for such an application. So far, pretty good. I am able to send over 150 MB of data – far more than will be needed – from the app, to the extension's background.js script, and vice versa. However, it seems when Safari receives the message from the app, it activates – that is, it becomes the frontmost macOS application. This will not be appreciated by the user who is writing email.

This activation seems to be triggered by something within Safari, because it occurs even if I comment out all of the JavaScript and HTML code in the extension. It occurs whether I send 150 bytes or 150 MB of data, although in the latter case it occurs about 5 seconds after the message is sent, indicating that Safari is apparently buffering the message or something before activating – even if the background script has no message handler because the call to addListener() is commented out.

Should I file a bug with my minimal project, or have I overlooked some way to prevent this activation of Safari?


Accepted Reply

Yes, you should file a bug report via Feedback Assistant. Thanks!

Replies

Yes, you should file a bug report via Feedback Assistant. Thanks!
Thank you, Timothy.

Done. Please refer to FB7829688.