Firefox add-on SDK -- "TypeError: can't convert null to object" Only on some computers

449 Views Asked by At

My addon works on most computers, but not all. I recently discovered that it doesn't work on a computer in my apartment building so I am trying to get to the bottom of it (this isn't the only computer that I have had this same issue with, but its the first one that I can actually do some troubleshooting with).

The error seems to stem from the use of "sdk/ui/frame" inside a toolbar. The error is reproduced in the example provided by mozilla as well. If I do a "cfx run" on the "addon-sdk-1.17/examples/toolbar-api" I get the following error:

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>

console error:

 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

The toolbar with the frame will show up, but no communication between the frame and the main.js will work. Again, this doesn't occur on all computers, just some.

This computer has the latest version of firefox, 38.0.5, and doesn't have any other extensions installed. There aren't any plugins that are not on my computer either. It is running windows 8 as does my computer.

0

There are 0 best solutions below