Safari MV3 - How to debug the service worker

108 views
Skip to first unread message

Ottis

unread,
Nov 11, 2024, 4:01:35 PMNov 11
to Chromium Extensions

Hi all,

Has anyone had success with MV3 extensions in Safari 18.1?

I'm trying to convert my MV2 Safari extension to MV3.

When I use MV2, I can debug the background script by going to this menu: Develop -> Web Extension Background Content. It works as expected.

However, when I switch the manifest to V3 (including specifying a background service_worker instead of a background script), there is only a single grayed-out option named "No Web Extension Background Content".

Occasionally, the contents of that menu does include an entry for the Safari profile I'm not currently in, and indicates it there is a service worker for my extension in that profile which is "not loaded" (my extension is installed and works in both profiles). However, this service worker menu option only appears rarely, and I can't figure out why it only appears sometimes.

I know the background service worker must be available and can be run, since the extension has an internal web page that can successfully pass messages to the service worker and get a response from it (using chrome.runtime.sendMessage).

Has anyone else had any success debugging MV3 service workers in Safari 18.1?

Thanks

Juraj M.

unread,
Nov 11, 2024, 4:34:17 PMNov 11
to Chromium Extensions, Ottis
I'm just gonna leave this link here for people with high hopes migrating their extensions to Safari:
Consider yourself warned :D

Ottis

unread,
Nov 11, 2024, 4:48:02 PMNov 11
to Juraj M., Chromium Extensions
Thanks Juraj, interesting blog post! I didn't even know it was possible to do in-app subscription purchases with Safari extensions - I assume that's actually not possible with a Safari Web Extension and there needs to be a Safari "App Extension" instead with the payment stuff written in Swift? I assume this is all so complicated that no one tries :)

Juraj M.

unread,
Nov 11, 2024, 5:00:40 PMNov 11
to Chromium Extensions, Ottis, Chromium Extensions, Juraj M.
Yes, you'll need to communicate with the "parent app" that bundles your extension. 
But never got to that "boss" level... I've only read docs for that I knew it's impossible :D.
Oh, I'm so happy that part of my life is over :D
Reply all
Reply to author
Forward
0 new messages