lapcat / SafariExtensions

Resources for the development of Safari extensions
43 stars 3 forks source link

SFSafariTab getContainingWindowWithCompletionHandler nil on page load #49

Closed lapcat closed 3 weeks ago

lapcat commented 5 months ago

If a Safari app extension content script calls safari.extension.dispatchMessage on page load, and -[SFSafariExtensionHandler messageReceivedWithName:fromPage:userInfo:] calls -[SFSafariTab getContainingWindowWithCompletionHandler:], the window is nil.

On the other hand, if it is called a second later, the window is non-nil.

Attached is a sample Xcode project demonstrating the bug. Just enable the extension in Safari and open any URL in a new window. WindowNilBug.zip

lapcat commented 3 weeks ago

This issue appears to be fixed in Safari 18.