Communication between bundled ressources and Safari App extension

Hi,

I work for Dashlane and we currently have a legacy webextz extension with ~85k users. We are trying to port our legacy webextz extension into a Safari App Extension app.


However, we are facing a blocker.

Our issue:

1 - Our extension injects a content script that creates an iframe in the page

2 - The source of the iframe is an HTML resource embedded in the extension (safari-extension://com....i/index.html) that requires a javascript file (also bundled in the extension).

3 - With the new api, we don’t have access to the safari object inside the iframe.


ReferenceError: Can't find variable: safari


It means that we are not able to communicate safely with the background of our extension with the following function:


safari.extension.dispatchMessage



Without this feature that was present in the legacy extension, we cannot ensure that the user’s data is safe, thus migrate to the new safari app extension.


I am available to help you move forward with this issue (mail, screen share, phone call, anything), this issue is critical for the company I work for, and our Safari users.


Best regards,

Replies

What kind of message are you hoping to dispatch from your iframe to the Safari App Extension?


If Safari added the `safari.extension` object to iframes from your Safari App Extension, would that fill your need?


The best way forward would be to file a radar (at https://bugreport.apple.com) describing the behavior you'd like to see, and explaining the behavior that you are trying to implement but you are currently blocked.


Thanks, hope this helps!

I'm now running into this issue myself. Any luck or workarounds?

There currently isn't a workaround for this, but it is something we are investigating adding in a future Safari release.

Safari technology Preview 77 made the window.safari object available in frames opened to safari-extension://resources.

See https://webkit.org/blog/8658/release-notes-for-safari-technology-preview-77/
I didn't test it yet, but this is great news for us.

Yes it does! I'm happy you noticed.


Please try it out and let me know if there are any issues!