I have 2 question

(Mobigohieu) #1

I need to create a frame in a toolbar in SDK. Reference to MDN
The toolbar is positioned between the address bar and the content window. It occupies the whole width of the browser window and is 18 pixels high on a normal-resolution display or 36 pixels high on a high-resolution (HiDPI) display
Can I change the height? I have a two-rows table to display. It only displays one. I could not find any way to change the height of the toolbar.

I’m trying to write an WebExtension that sends a message to the native app. Unfortunately, something strange is going on. Things just do not work!

The app is very simple, it just gives back what it gets, here’s the code for Node.JS:

let fs = require('fs');
let message = fs.readFileSync('/dev/stdin').toString();
fs.writeFileSync('/tmp/out', message);
It works when run from shell, and /tmp/out is just for debugging.

The native app manifest at /Library/Application Support/Mozilla/NativeMessagingHosts/com.letterprinter.json:

  "name": "com.letterprinter",
  "description": "LetterPrinter",
  "path": "/Users/iliakan/bin/letterPrinter",
  "type": "stdio",
  "allowed_extensions": [ "letterPrinter@javascript.ru" ]
Sometimes the app works, so it seems that the manifest is not broken.

And now the extension:

browser.browserAction.onClicked.addListener(() => {
  let message = { data: Date.now() };

  console.log("Sending message", message);
  browser.runtime.sendNativeMessage('com.letterprinter', message).then(
    response => console.log("response", response),
    error => console.log("error", error)

The manifest for the extension:

  "applications": {
    "gecko": {
      "id": "letterPrinter@javascript.ru",
      "strict_min_version": "50.0"
  "background": {
    "scripts": ["background.js"]
  "permissions": [

The problem is: sometimes that does not work: I see in console smth like “Sending message Object { data: 1496769055091 }”, but the app doesn’t run.

What’s wrong here?

I tried to run it in Chrome, but it fails too, so probably there’s something I miss.

P.S. I feel it should run the app, send it the message to stdin, get back the output and close the app – every time when browser_action runs. Is it correct?

P.P.S. The console doesn’t show neither “error” nor “response”, don’t know why. The promise does not settle? Ugh.

Thanks a lot!

(Michel Gutierrez) #2

Regarding the native app part:

The data exchange between the add-on and the native app consists of first sending a 4 bytes binary word (big endian encoded) that codes the length of the message, then the message itself as a JSON compliant format encoded in utf-8.

If you forget that initial length word, the system tries to decode it from the first characters of your message, leading to some crazy length as you experienced.

(Niklas Gollenstede) #3

There are quite a number of things that can go wrong with native messaging. I have written a node.js based helper framework that takes care of all the messaging itself and simply lets you write normal node.js modules:

You should be able to change the Toolbar height with CSS attached to every window, see e.g.: