This sample project illustrates a bug that we started noticing in Safari 15.4.
Under some circumstances, the tabs.onUpdated
event stops getting fired by Safari.
When the following conditions are true, then tabs.onUpdated
handlers will not be called:
- There is a content script defined in manifest.json.
- The user has navigated to an extension page, e.g.
safari-web-extension://<uuid>/index.html
(Firefox: Right-click -> "Save Link As...")
Demo video here: https://github.com/getchardy/safari-extension-bug/raw/main/demo.mov
Step 1: Using XCode 13.3, generate the Safari extension:
> scripts/generate.sh
Step 2: Build the Mac App target:
> scripts/build.sh
Alternatively, you can build it using XCode.
Step 3: Enable the Extension in Safari:
- Open Safari
- Allow Unsigned Extensions
- Enable the "Test App" Extension in "Safari Preferences" -> "Extensions"
- Click "Always Allow on Every Website..."
Step 4: Open background page console so you can monitor tabs.onUpdated
events:
- Open menu for "Web Extension Background Pages" -> "Test App - Background Page".
- Click on the "Console" tab
- Note the logged out value of the extension's index URI. You'll need this later. I.e.
safari-web-extension://<uuid>/index.html
Step 5: Demonstrate tabs.onUpdated
events are functioning
- Navigate to different websites, e.g.
apple.com
,anonyome.com
. - Notice that we're getting log message for
tabs.onUpdate
handler. This is normal and expected behavior.
Step 6: Demonstrate that tabs.onUpdated
events will stop working
- Navigate to the extension page, using the
safari-web-extension://
URL you noted in step 4. - => Notice there is no
tabs.onUpdated
event. - Navigate to different websites, e.g.
apple.com
,anonyome.com
. - => Notice there are no further
tabs.onUpdated
events. - => Also notice this issue now affects all tabs in the browser.