Bug 271868 - REGRESSION (iOS 17.4): Safari extension content scripts not loaded in link previews
Summary: REGRESSION (iOS 17.4): Safari extension content scripts not loaded in link pr...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Extensions (show other bugs)
Version: Safari 17
Hardware: iPhone / iPad iOS 17
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2024-03-28 18:00 PDT by Jeff Johnson
Modified: 2024-03-29 12:59 PDT (History)
2 users (show)

See Also:


Attachments
Sample Xcode project (325.32 KB, application/zip)
2024-03-28 18:00 PDT, Jeff Johnson
no flags Details
Working (531.08 KB, image/png)
2024-03-29 11:51 PDT, Timothy Hatcher
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeff Johnson 2024-03-28 18:00:59 PDT
Created attachment 470653 [details]
Sample Xcode project

Steps to reproduce:
1. Run the attached sample Safari extension Xcode project PreviewBug
2. Enable PreviewBug in Safari
3. Open https://example.org
4. Press down the More Information link and show the preview

Expected results: You see a window alert saying "content script"

Actual results: No window alert

This bug occurs on device with iOS 17.4.1 and in the iOS 17.4 Xcode simulator. It does not occur on device in earlier version of iOS or in the iOS 17.2 simulator. For some reason, there's no iOS 17.3 simulator available for download, so I couldn't test when exactly the bug was introduced.

In the sample project, the extension content script calls setTimeout(() => { alert("content script"); }, 2000);

As you can see, unlike the content script, the extension style sheet does get injected: * { background-color: red !important; }

This bug breaks my Safari extension in the App Store. For example, it breaks the feature that stops videos from autoplaying. I was alerted to the issue by a customer who previews links before opening them in a new tab.

Incidentally, it was difficult to debug this issue, because the link preview web context doesn't appear in the Safari Developer menu, which is why I had to use the primitive window alert method of debugging.
Comment 1 Radar WebKit Bug Importer 2024-03-28 18:01:09 PDT
<rdar://problem/125589211>
Comment 2 Timothy Hatcher 2024-03-29 11:51:20 PDT
Created attachment 470665 [details]
Working
Comment 3 Timothy Hatcher 2024-03-29 11:51:32 PDT
I am seeing the content script alert on 17.4.1 (21E237).
Comment 4 Timothy Hatcher 2024-03-29 12:03:25 PDT
I was able to reproduce on 21E237 after all.
Comment 5 Timothy Hatcher 2024-03-29 12:59:37 PDT
This has been resolved in Safari.