Is it possible to apply panel.resize in panel itself

firefox-addon, firefox-addon-sdk

Solution

No, the code running inside a panel doesn't have the necessary privileges to call any SDK modules. This is solved by using a content script that will send a message back to the extension. The extension can then resize the panel. Something along these lines (untested):

var panel = require("panel").Panel({
  contentURL: ...,
  contentScript: "self.port.emit('resize', " +
                   "{width: document.documentElement.clientWidth, " +
                   "height: document.documentElement.clientHeight});"
});
panel.port.on("resize", function({width, height})
{
  panel.resize(width, height);
});
panel.show();

Problem

Seems there no auto size option for Panels in Firefox Add-on SDK extensions, but `panel.resize` exist. Is it possible to call it on current panel?

Original source