Skip to content

FB18755809 - Disabling and re-enabling a Safari extension creates duplicate content scripts in open Safari tabs #65

@lapcat

Description

@lapcat

If you disable a Safari extension, the extension's content script remains loaded and functional in open Safari tabs. If you then re-enable the Safari extension, an additional duplicate content script is loaded into open Safari tabs. The duplicate content scripts keep accumulating in open Safari tabs every time you disable and re-enable an extension.

Steps to reproduce:

  1. Enable the extension StopTheMadness Pro (App ID 6471380298) in Safari
  2. Open https://example.org
  3. Disable StopTheMadness Pro in Safari Extensions Settings
  4. Enable StopTheMadness Pro in Safari Extensions Settings
  5. Open the web inspector in the example.org tab
  6. Select the Sources tab
  7. Look under Extension Scripts

Expected results: One instance of script.js is enabled

Actual results: Two instances of script.js are enabled

In some recent version of macOS, between 15.3 and 15.5, the Mac App Store started to allow Safari app extensions to be updated without quitting Safari first. Updating the extension app causes the extension to automatically disable and re-enable in Safari, thereby triggering this bug too.

To compare with other web browsers, Firefox disables the extension's content script when you disable the extension, so the bug does not occur there. Chrome fails to disable the extension's content script when you disable the extension, but Chrome does not inject the content script into open browser tabs when you enable the extension, so the problem of duplicates never occurs. Safari both fails to disable the content script and injects a new copy of the content script, leading to duplicates.

Also, there's the issue of keeping a disabled extension's content scripts in the page cache.

For more details and discussion, see the blog post https://lapcatsoftware.com/articles/2023/11/7.html

This issue appears to affect mobile Safari on iOS too.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions