After porting my Chrome extension to Safari Web Extension, I'm left with one final mystery. My toolbar icon has a popup, and that popup has an X button in the top right for the user to be able to close it. When clicked, this works on Chrome/Firefox/Edge to close it:
window.close()
On Safari, however, I get an uncatchable warning:
⚠️ Can't close the window since it was not opened by JavaScript.
In the old days, we had to do this on Safari:
safari.extension.popovers[0].hide();
But that doesn't seem to be an option now. I'm assuming I need to delegate to the native app portion of the extension to close the popup, but I can't find any documentation on how to get a handle to the popup from NSExtensionRequestHandling. I can get a message to it using the nativeMessaging permissions and:
browser.runtime.sendNativeMessage("ignored", {
	message: "CLOSE_POPUP"
})
...but once in the native app handler, I'm not sure what to do next. Any ideas?
8
0
3.7k