diff --git a/native-messaging/README.md b/native-messaging/README.md index e2bf293..d732937 100644 --- a/native-messaging/README.md +++ b/native-messaging/README.md @@ -4,9 +4,28 @@ The WebExtension, which can be found under "add-on", connects to the native appl The native application, which can be found under "app", listens for messages from the WebExtension. When it receives a message, the native application sends a response message whose payload is just "pong". The native application is written in Python. -To get this working, there's a little setup to do: +## Setup ## -* edit the "path" property of "app/ping_pong.json" to point to the location of "app/ping_pong.py" on your computer -* copy "app/ping_pong.json" to the correct location on your computer. See [host manifest locations]() to find the correct location for your OS. +To get this working, there's a little setup to do. + +### Mac OS/Linux setup ### + +* Check that the [file permissions](https://en.wikipedia.org/wiki/File_system_permissions) for "ping_pong.py" include the `execute` permission. +* Edit the "path" property of "ping_pong.json" to point to the location of "ping_pong.py" on your computer. +* copy "ping_pong.json" to the correct location on your computer. See [Host Manifests ](https://wiki.mozilla.org/WebExtensions/Native_Messaging#Host_Manifests) to find the correct location for your OS. + +### Windows setup ### + +* Check you have Python installed. +* Edit "ping_pong_win.bat" so it contains the path to "ping_pong.py" on your computer. +* Edit the "path" property of "ping_pong_win.json" to point to the location of "ping_pong_win.bat" on your computer. +* Add a registry key containing the path to "ping_pong_win.json" on your computer. See [Host Manifests ](https://wiki.mozilla.org/WebExtensions/Native_Messaging#Host_Manifests) to find details of the registry key to add. + +## Testing the example ## Then just install the add-on as usual, by visiting about:debugging, clicking "Load Temporary Add-on", and selecting the add-on's "manifest.json". + +You should see a new browser action icon in the toolbar. Open the console ("Tools/Web Developer/Browser Console" in Firefox), and click the browser action icon. You should see output like this in the console: + + Sending: ping + Received: pong diff --git a/native-messaging/app/ping_pong_win.bat b/native-messaging/app/ping_pong_win.bat new file mode 100644 index 0000000..a4f78df --- /dev/null +++ b/native-messaging/app/ping_pong_win.bat @@ -0,0 +1,3 @@ +@echo off + +python "path\to\your\ping_pong.py" diff --git a/native-messaging/app/ping_pong_win.json b/native-messaging/app/ping_pong_win.json new file mode 100644 index 0000000..1920baa --- /dev/null +++ b/native-messaging/app/ping_pong_win.json @@ -0,0 +1,7 @@ +{ + "name": "ping_pong", + "description": "Example host for native messaging", + "path": "ping_pong_win.bat", + "type": "stdio", + "allowed_extensions": [ "ping_pong@example.org" ] +}