Launch an application on desktop

Hi,
I am the author of MacDict extension.
The extension launches the Dictionary application to lookup the selected word on Mac desktop.

I believe that there is no equivalent way to achieve the same behavior in WebExtensions API.
I understand that this will compromise the security that WebExtensions aim to provide.
Could someone please confirm that such an API is indeed not available in WebExtensions.

Thanks.

You can have a standalone app that your Firefox WebExtension talks to. Look into Native messaging and at the native-messaging example WebExtension.

There is a list of sample web extensions and the APIs used. The Browser Support table is also very useful.

I missed mentioning that the application that I want to launch (Dictionary) is not developed by me.
It is developed by Apple and is a built-in app in Mac OS X.
So, I cannot communicate with it via Native messaging APIs.

Does it accept command line parameters? Does it talk to the outside world in any way? Make a standalone app that converts the native messanging API into the command line or whatever the Apple app knows.

From the documentation of Native messaging, I understand that the manifest file of native app needs to be copied to a specified path. For example “~/Library/Application Support/Mozilla/NativeMessagingHost/”.

Also, as per the documentation, “The native application is not installed or managed by the browser: it’s installed using the underlying operating system’s installation machinery.”

So, how is the manifest file of native app supposed to be copied to the right place? I don’t think it can be done during installation of the extension (although I might be wrong here).

The application manifest would have to be distributed and installed the same way as your native application. You can’t get around providing some sort of installer for your custom native application. People would have to download the installer from somewhere else than addons.mozilla.org.

I’m in the process of doing something similar and I’m really not looking forward to telling the users to download some shady installer to get the extension working, but there isn’t any other way right now.

Exactly! Telling users to install an application because Mozilla decided to make their add-ons more secure is just not going to work.

So, how is the manifest file of native app supposed to be copied to the right place?

You need to choose an installation location for your native app (in this case, a wrapper around dictionary) and use that location in your extension’s manifest.

Telling users to install an application because Mozilla decided to make their add-ons more secure is just not going to work.

There is no other choice. The issue is that Mozilla does not want the responsibility for binaries in an addon. Binaries can easily by p0wn a device. By getting the addon author to coax the user into installing components which have nothing to do with Firefox, and by the user doing this installation of his own accord, the user now takes responsibility upon himself for any potentially installed binary malware.

I think the point is that we didn’t have to deploy any binary components before to be able to talk to third-party applications already present on the user’s system (or at least launch them).

Due to the security restrictions in WebExtensions, we are not only forced to provide a custom binary for the same use case, but also talk the users into installing an installer from a source they don’t really know. Seems like a bad trade-off in terms of the user’s security.

So, the perfect thing for this use case would be not having to write and deploy any binary components at all and to be able to talk to normal third-party applications directly. I understand that this would put some responsibility back in Mozilla’s hands, but I think it would be a good thing for the user (and the extension developer). The user would still take most responsibility by accepting the “nativeMessaging” permission.

Maybe you can somehow reuse this native client, it’s also on GitHub.