Hi. I'm trying to port my Safari app extension with an injected content script to a Safari web extension on iOS. Content scripts in a macOS Safari app extension always behave as if run_at document_start were specified in the manifest of a Chrome extension. This is crucial to my extension for several reasons: I need to load my JavaScript before any of the page scripts load, and I need to start fetching my site-specific preferences ASAP.
Unfortunately, document_start doesn't work right with Safari web extensions in Safari 14 or Safari 15 on macOS. This is made even worse if Preload Top Hit is enabled in Safari, but document_start is unreliable even with Preload Top Hit disabled.
I've been testing with Safari on the iOS 15 beta, and I've noticed that document_start does seem to work right (unlike Safari Mac) with Preload Top Hit disabled. However, enabling Preload Top Hit still causes it to be unreliable on iOS.
This is all in contrast to Safari app extensions, which just always load at the start, regardless of whether Preload Top Hit is enabled. Though of course Safari app extensions do not exist on iOS.
I'm wondering if Apple's Safari engineers could comment about this. Are there differences in web extension implementation between iOS and macOS? Can I depend on iOS document_start working right with Preload Top Hit disabled? Is there any way that you could fix the Preload Top Hit behavior? (In my testing, document_start seems to work with preload in Google Chrome.)
The developer forums don't see to allow me to attach a zip file (is this possible?) but I've got a sample Xcode project that can demonstrate this behavior.