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
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