开发者

Firefox unloads modules loaded with Components.utils.import()?

When leaving Firefox running for some time the strange thing begin to happen with my extension. Here's some code, that I need to describe the problem:开发者_StackOverflow中文版

extension.js

var My = {};

overlay.js

Components.utils.import("resource://myextension/extension.js");

My.extension = (function() {
  var someFunc = function() {
    // more code
    My.module.otherFunc();
  };

  // more code
})();

At some point we start getting the strange error: 'My' is undefined in overlay.js:6

My guess is that Firefox unloads extension.js module silently, otherwise I couldn't find any hint why this may happen. Do you?

Firefox version: 3.x

Thanks!


While you can pass functions to modules as temporary callbacks, you should take steps to ensure that they are not used after the window is closed, because then all its global variables, including My, are deleted. If the module subsequently tries to call the function then you will get the error as described.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜