Closed
Bug 1386820
Opened 8 years ago
Closed 8 years ago
browser.runtime.sendNativeMessage is not a function
Categories
(WebExtensions :: General, defect)
WebExtensions
General
Tracking
(Not tracked)
RESOLVED
WORKSFORME
People
(Reporter: Manuel.Spam, Unassigned)
Details
Attachments
(1 file)
691 bytes,
application/x-xpinstall
|
Details |
I try to use the "sendNativeMessage" function:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/API/runtime/sendNativeMessage
According to the documentation this should be available since Firefox 50.
I have the "nativeMessaging" permission in my Addon and I could use "connectNative" (this is defined).
For "sendNativeMessage", I get the message in the summary. For some reason it doesn't end in the browser console. I had to use "try catch" to get it...
Comment 1•8 years ago
|
||
Can you please attach a complete extension that exhibits this problem?
Flags: needinfo?(Manuel.Spam)
Reporter | ||
Comment 2•8 years ago
|
||
The extension, I try to create, is still in development and only consists of alerts and debug messages.
I would have to create a simple testcase.
I have the following in my extension:
for (a in browser.runtime)
alert(a);
And "sendNativeMessage" is not listed with this, so it doesn't get defined.
This is my "permission block":
"permissions": [
"nativeMessaging", "<all_urls>"
]
I can wrap both (permissions and the two lines code) into a small test extension if this helps.
Reporter | ||
Comment 3•8 years ago
|
||
OK... I can limit this to the "exportFunction" feature.
What I tried was to get some info from page javascript.
So I exported one function using "exportFunction" to page javascript and this function is meant to use the external native application.
I could use "sendNativeMessage" from outside of my exported function but not in it.
Is this expected behaviour?
Reporter | ||
Comment 4•8 years ago
|
||
Very simple test addon.
I now finally give up.
Sorry guys, but the error messages, created by the whole "Web Extensions" stuff, are total bu**sh*t. Not fun at all to track down such errors!
If there already is a bug about the error message situation with WebExtensions (just undefined functions, no clear errors in browser console if permission is missing, ...) please tell me or directly add me to the CC list. Thanks.
Flags: needinfo?(Manuel.Spam)
Reporter | ||
Comment 5•8 years ago
|
||
Forgot to mention: This also affects "connectNative".
I do not know what I'm doing wrong, but my Addon is not able to use the "nativeMessaging" stuff.
Comment 6•8 years ago
|
||
You are trying to use nativeMessaging inside a content script. What is available in a content script is documented here:
https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts
Try moving your calls into a background page.
Reporter | ||
Comment 7•8 years ago
|
||
Thanks.
What I need is communication from the page javascript itself to the external native application.
I tried exporting functions from the content script, but this doesn't seem to work now.
Do I really have to communicate from background script to content script and from there to page javascript or is there any chance for a more direct way?
Comment 8•8 years ago
|
||
Yes, that's documented here: https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Content_scripts#Communicating_with_background_scripts
Closing this bug based on the use case presented in the test.xpi.
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → WORKSFORME
Updated•7 years ago
|
Product: Toolkit → WebExtensions
You need to log in
before you can comment on or make changes to this bug.
Description
•