Addon-sdk-1.7 "toolbar-api" example not working on computer

RESOLVED INCOMPLETE

Status

RESOLVED INCOMPLETE
3 years ago
11 months ago

People

(Reporter: jgreen, Unassigned)

Tracking

Firefox Tracking Flags

(Not tracked)

Details

(Reporter)

Description

3 years ago
User Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Firefox/38.0
Build ID: 20150525141253

Steps to reproduce:

I don't get this error on all computers, but my addon has similar functionality to this example and I have received complaints from a few people that my addon doesn't work on their computer. I have had limited access to their computers in the past, so I could see the error, but I couldn't spend much time trying to debug it. I have tried to create a new profiles and reinstall firefox with no luck. 

I have finally found a computer that I have access to so I was able to pinpont the code that is causing the error. The pc that I found to reproduce the error on is a HP Envy 27 x86_64 running Windows 8.1 (I have the same platform on my pc and do not have this error). It is a community pc that will let you install pretty much anything you want, but it reverts back (removes all installations and files) on a nightly basis. I have seen this error on users personal pc's though. 

I reproduced the error by downloading latest version of firefox (38.0.5 at the time), python 2.7, and Addon-sdk-1.7 onto the pc. Ran "bin\activate" from the addon-sdk directory, changed directory to "examples/toobar-api" within the Addon-sdk-1.7 folder. Ran "cfx run".

The code for the addon is as follows:
main.js
"
"use strict";
const { Toolbar } = require("sdk/ui/toolbar");
const { Frame } = require("sdk/ui/frame");
const { ActionButton } = require("sdk/ui/button/action");
let button = new ActionButton({
  id: "button",
  label: "send!",
  icon: "./favicon.ico",
  onClick: () => {
    frame.postMessage({
      hello: "content"
    });
  }
});
let frame = new Frame({
    url: "./index.html",
    onAttach: () => {
      console.log("frame was attached");
    },
    onReady: () => {
      console.log("frame document was loaded");
    },
    onLoad: () => {
      console.log("frame load complete");
    },
    onMessage: (event) => {
      console.log("got message from frame content", event);
      if (event.data === "ping!")
        event.source.postMessage("pong!", event.source.origin);
    }
});
let toolbar = new Toolbar({
  items: [frame],
  title: "Addon Demo",
  hidden: false,
  onShow: () => {
    console.log("toolbar was shown");
  },
  onHide: () => {
    console.log("toolbar was hidden");
  }
});"

index.html
"<html>
  <body>
    <button id=post>post!</button>
  </body>
  <script>
    window.addEventListener("message", event => {
      console.log("Document message", event, event.data, event.source !== window && event.source === window.parent);
    });
    window.addEventListener("click", event => {
      if (event.target.id === "post") {
          console.log("click!")
          window.parent.postMessage("ping!", "*");
      }
    });
    console.log(window.parent === window)
  </script>
</html>"

The error seems to stem from the use of "sdk/ui/frame" inside a toolbar, as the example works if i modify the code to not include the frame. 


Actual results:

Firefox opened with the toolbar and button attached, but the button had no functionality. The following error was in the console:

"console.error: toolbar-api:
  Message: TypeError: can't convert null to object
  Stack:
    calculate@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gr
e/modules/commonjs/diffpatcher/diff.js:24:3
calculate/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/diffpatcher/diff.js:36:17
calculate@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mo
dules/commonjs/diffpatcher/diff.js:29:3
calculate/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/diffpatcher/diff.js:36:17
calculate@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mo
dules/commonjs/diffpatcher/diff.js:29:3
calculate/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/diffpatcher/diff.js:36:17
calculate@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mo
dules/commonjs/diffpatcher/diff.js:29:3
@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/com
monjs/diffpatcher/diff.js:18:10
dispatch@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mod
ules/commonjs/method/core.js:119:12
reactor<.onStep@resource://gre/modules/commonjs/toolkit/loader.js -> resource://
gre/modules/commonjs/sdk/ui/frame/view.js:130:19
Reactor.prototype.onNext@resource://gre/modules/commonjs/toolkit/loader.js -> re
source://gre/modules/commonjs/sdk/event/utils.js:248:3
Reactor.prototype.run/<@resource://gre/modules/commonjs/toolkit/loader.js -> res
ource://gre/modules/commonjs/sdk/event/utils.js:251:32
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
transform/next@resource://gre/modules/commonjs/toolkit/loader.js -> resource://g
re/modules/commonjs/sdk/event/utils.js:36:24
map/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/module
s/commonjs/sdk/event/utils.js:60:60
transform/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/sdk/event/utils.js:43:29
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
merges/</<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/m
odules/commonjs/sdk/event/utils.js:187:31
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
lift/</<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mod
ules/commonjs/sdk/event/utils.js:163:7
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
transform/next@resource://gre/modules/commonjs/toolkit/loader.js -> resource://g
re/modules/commonjs/sdk/event/utils.js:36:24
filter/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mod
ules/commonjs/sdk/event/utils.js:53:7
transform/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/sdk/event/utils.js:43:29
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
lift/</<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mod
ules/commonjs/sdk/event/utils.js:163:7
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
InputPort.prototype.observe@resource://gre/modules/commonjs/toolkit/loader.js ->
 resource://gre/modules/commonjs/sdk/input/system.js:100:5

console.error: toolbar-api:
  Message: TypeError: can't convert null to object
  Stack:
    calculate@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gr
e/modules/commonjs/diffpatcher/diff.js:24:3
calculate/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/diffpatcher/diff.js:36:17
calculate@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mo
dules/commonjs/diffpatcher/diff.js:29:3
calculate/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/diffpatcher/diff.js:36:17
calculate@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mo
dules/commonjs/diffpatcher/diff.js:29:3
calculate/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/diffpatcher/diff.js:36:17
calculate@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mo
dules/commonjs/diffpatcher/diff.js:29:3
@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/com
monjs/diffpatcher/diff.js:18:10
dispatch@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mod
ules/commonjs/method/core.js:119:12
reactor<.onStep@resource://gre/modules/commonjs/toolkit/loader.js -> resource://
gre/modules/commonjs/sdk/ui/frame/model.js:127:19
Reactor.prototype.onNext@resource://gre/modules/commonjs/toolkit/loader.js -> re
source://gre/modules/commonjs/sdk/event/utils.js:248:3
Reactor.prototype.run/<@resource://gre/modules/commonjs/toolkit/loader.js -> res
ource://gre/modules/commonjs/sdk/event/utils.js:251:32
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
transform/next@resource://gre/modules/commonjs/toolkit/loader.js -> resource://g
re/modules/commonjs/sdk/event/utils.js:36:24
map/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/module
s/commonjs/sdk/event/utils.js:60:60
transform/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/sdk/event/utils.js:43:29
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
merges/</<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/m
odules/commonjs/sdk/event/utils.js:187:31
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
lift/</<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mod
ules/commonjs/sdk/event/utils.js:163:7
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
transform/next@resource://gre/modules/commonjs/toolkit/loader.js -> resource://g
re/modules/commonjs/sdk/event/utils.js:36:24
filter/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mod
ules/commonjs/sdk/event/utils.js:53:7
transform/<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/
modules/commonjs/sdk/event/utils.js:43:29
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
lift/</<@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/mod
ules/commonjs/sdk/event/utils.js:163:7
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules
/commonjs/sdk/event/core.js:97:9
receive@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modu
les/commonjs/sdk/event/utils.js:115:5
InputPort.prototype.observe@resource://gre/modules/commonjs/toolkit/loader.js ->
 resource://gre/modules/commonjs/sdk/input/system.js:100:5"


Expected results:

Firefox should open with the toolbar installed and when the button on the toolbar is clicked the console should display "got message from frame content" and the console should not have any errors.

Comment 1

3 years ago
If this OS has touch enabled, can you disable touch screen from Device manager and re-try?

We ran into the same issue and disabling touch screen fixed this issue.
(Reporter)

Comment 2

3 years ago
Disabling touch seemed to correct the problem on the computer that I have access to. The first couple of computers that I encountered this bug were touchscreen computers, but I know we have had this issue on at least two non touchscreen computers as well. Although maybe the OS had touch enabled somehow (I do not have access to these anymore). This is still a bug in my opinion if the work-around is to disable a major functionality of a computer, especially with more and more laptops coming out with this functionality.
https://bugzilla.mozilla.org/show_bug.cgi?id=1399562
Status: UNCONFIRMED → RESOLVED
Last Resolved: 11 months ago
Resolution: --- → INCOMPLETE
You need to log in before you can comment on or make changes to this bug.