1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-14 16:05:47 +01:00

Fix some bugs.

This commit is contained in:
Kris Maglione
2011-01-05 18:54:17 -05:00
parent 663a398112
commit 841459e507
3 changed files with 21 additions and 10 deletions

View File

@@ -9,10 +9,17 @@ if (!JSMLoader)
builtin: Components.utils.Sandbox(this),
factories: [],
globals: {},
io: Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService),
manager: Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar),
stale: {},
getTarget: function getTarget(url) {
let chan = this.io.newChannel(url, null, null);
chan.cancel(Components.results.NS_BINDING_ABORTED);
return chan.name;
},
load: function load(url, target) {
if (this.stale[url]) {
let stale = this.stale[url];
if (stale) {
delete this.stale[url];
let global = this.globals[url];
@@ -28,9 +35,12 @@ if (!JSMLoader)
Components.utils.reportError(e);
}
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader)
.loadSubScript(url, global);
if (stale !== this.getTarget(url))
delete this.globals[url];
else
Components.classes["@mozilla.org/moz/jssubscript-loader;1"]
.getService(Components.interfaces.mozIJSSubScriptLoader)
.loadSubScript(url, global);
}
Components.utils.import(url, target);
},
@@ -40,7 +50,7 @@ if (!JSMLoader)
},
purge: function purge() {
for (let [url, global] in Iterator(this.globals))
this.stale[url] = true;
this.stale[url] = this.getTarget(url);
},
registerGlobal: function registerGlobal(uri, obj) {
if (Cu.getGlobalForObject)