summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
Diffstat (limited to 'common')
-rwxr-xr-xcommon/bootstrap.js12
-rw-r--r--common/components/protocols.js3
-rw-r--r--common/content/dactyl.js7
-rw-r--r--common/modules/base.jsm22
-rw-r--r--common/modules/bootstrap.jsm33
-rw-r--r--common/modules/overlay.jsm4
-rw-r--r--common/modules/storage.jsm8
7 files changed, 59 insertions, 30 deletions
diff --git a/common/bootstrap.js b/common/bootstrap.js
index e9c2a066..779c5e88 100755
--- a/common/bootstrap.js
+++ b/common/bootstrap.js
@@ -65,8 +65,7 @@ function startup(data, reason) {
init();
}
catch (e) {
- dump("dactyl: bootstrap: " + e + "\n" + e.stack);
- Cu.reportError(e);
+ reportError(e);
}
}
}
@@ -130,10 +129,15 @@ function init() {
}
}
- dump("JSMLoader " + (typeof JSMLoader !== "undefined" && JSMLoader.bump) + "\n");
- if (typeof JSMLoader === "undefined" || JSMLoader.bump != 2)
+ if (JSMLoader && JSMLoader.bump != 3) // Temporary hack
+ Services.scriptloader.loadSubScript("resource://dactyl" + suffix + "/bootstrap.jsm",
+ Cu.import("resource://dactyl/bootstrap.jsm", global));
+
+ if (!JSMLoader || JSMLoader.bump != 3)
Cu.import("resource://dactyl/bootstrap.jsm", global);
+ JSMLoader.load("resource://dactyl/bootstrap.jsm", global);
+
JSMLoader.init(suffix);
JSMLoader.load("base.jsm", global);
diff --git a/common/components/protocols.js b/common/components/protocols.js
index f22d11e4..14d504a4 100644
--- a/common/components/protocols.js
+++ b/common/components/protocols.js
@@ -115,8 +115,6 @@ function Dactyl() {
this.pages = {};
- Cu.import("resource://dactyl/bootstrap.jsm");
- JSMLoader.init();
JSMLoader.load("base.jsm", global);
require(global, "config");
require(global, "services");
@@ -194,6 +192,7 @@ Dactyl.prototype = {
observe: function observe(subject, topic, data) {
if (topic === "profile-after-change") {
Cu.import("resource://dactyl/bootstrap.jsm");
+ JSMLoader.init();
require(global, "overlay");
}
}
diff --git a/common/content/dactyl.js b/common/content/dactyl.js
index cc469477..4f4a9717 100644
--- a/common/content/dactyl.js
+++ b/common/content/dactyl.js
@@ -1575,9 +1575,10 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
function listener(action, event)
function addonListener(install) {
- dactyl[install.error ? "echoerr" : "echomsg"](
- "Add-on " + action + " " + event + ": " + (install.name || install.sourceURI.spec) +
- (install.error ? ": " + addonErrors[install.error] : ""));
+ if (typeof dactyl !== "undefined")
+ dactyl[install.error ? "echoerr" : "echomsg"](
+ "Add-on " + action + " " + event + ": " + (install.name || install.sourceURI.spec) +
+ (install.error ? ": " + addonErrors[install.error] : ""));
}
const addonListener = {
onNewInstall: function (install) {},
diff --git a/common/modules/base.jsm b/common/modules/base.jsm
index 20874c8f..59c761e7 100644
--- a/common/modules/base.jsm
+++ b/common/modules/base.jsm
@@ -964,16 +964,22 @@ var Timer = Class("Timer", {
},
notify: function (timer) {
- if (util.rehashing)
- return;
+ try {
+ if (util.rehashing || typeof util === "undefined")
+ return;
- this._timer.cancel();
- this.latest = 0;
- // minInterval is the time between the completion of the command and the next firing
- this.doneAt = Date.now() + this.minInterval;
+ this._timer.cancel();
+ this.latest = 0;
+ // minInterval is the time between the completion of the command and the next firing
+ this.doneAt = Date.now() + this.minInterval;
- try {
- this.callback(this.arg);
+ this.callback(this.arg);
+ }
+ catch (e) {
+ if (typeof util === "undefined")
+ dump("dactyl: " + e + "\n" + (e.stack || Error().stack));
+ else
+ util.reportError(e);
}
finally {
this.doneAt = Date.now() + this.minInterval;
diff --git a/common/modules/bootstrap.jsm b/common/modules/bootstrap.jsm
index 658fbafa..b890dff1 100644
--- a/common/modules/bootstrap.jsm
+++ b/common/modules/bootstrap.jsm
@@ -4,29 +4,33 @@
// given in the LICENSE.txt file included with this file.
"use strict";
+try {
+
var EXPORTED_SYMBOLS = ["JSMLoader"];
-let global = this;
+var global = this;
+var storage = Components.classes["@mozilla.org/fuel/application;1"]
+ .getService(Components.interfaces.fuelIApplication)
+ .storage;
-try {
+var JSMLoader = storage.get("dactyl.JSMLoader", undefined);
-if (!JSMLoader || JSMLoader.bump != 2)
- var JSMLoader = {
- bump: 2,
+if (!JSMLoader || JSMLoader.bump != 3)
+ JSMLoader = {
+ bump: 3,
builtin: Components.utils.Sandbox(this),
canonical: {},
factories: [],
- globals: {},
+ globals: JSMLoader ? JSMLoader.globals : {},
io: Components.classes["@mozilla.org/network/io-service;1"].getService(Components.interfaces.nsIIOService),
loader: Components.classes["@mozilla.org/moz/jssubscript-loader;1"].getService(Components.interfaces.mozIJSSubScriptLoader),
manager: Components.manager.QueryInterface(Components.interfaces.nsIComponentRegistrar),
- stale: {},
+ stale: JSMLoader ? JSMLoader.stale : {},
+ storage: storage,
suffix: "",
init: function init(suffix) {
this.suffix = suffix || "";
- Components.classes["@mozilla.org/fuel/application;1"]
- .getService(Components.interfaces.fuelIApplication)
- .storage.set("dactyl.JSMLoader", this);
+ this.storage.set("dactyl.JSMLoader", this);
let base = JSMLoader.load("base.jsm", global);
global.EXPORTED_SYMBOLS = base.EXPORTED_SYMBOLS;
@@ -52,9 +56,11 @@ if (!JSMLoader || JSMLoader.bump != 2)
delete this.stale[name];
delete this.stale[targetURL];
+ let loadURL = url.replace(RegExp("^(resource://dactyl)/"), "$1" + this.suffix + "/");
+
let global = this.globals[name];
if (stale === targetURL)
- this.loadSubScript(url, global.global || global);
+ this.loadSubScript(loadURL, global.global || global);
}
try {
@@ -72,7 +78,12 @@ if (!JSMLoader || JSMLoader.bump != 2)
this.manager.unregisterFactory(factory.classID, factory);
},
purge: function purge() {
+ dump("dactyl: JSMLoader: purge\n");
+
for (let [url, global] in Iterator(this.globals)) {
+ if (url === "bootstrap.jsm" || url === "resource://dactyl/bootstrap.jsm")
+ continue;
+
let target = this.getTarget(url);
this.stale[url] = target;
this.stale[target] = target;
diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm
index 7da5e57f..8af99d25 100644
--- a/common/modules/overlay.jsm
+++ b/common/modules/overlay.jsm
@@ -4,6 +4,8 @@
// given in the LICENSE.txt file included with this file.
"use strict";
+try {
+
Components.utils.import("resource://dactyl/bootstrap.jsm");
defineModule("overlay", {
exports: ["ModuleBase"],
@@ -276,4 +278,6 @@ var Overlay = Module("Overlay", {
}
});
+} catch(e){ if (!e.stack) e = Error(e); dump(e.fileName+":"+e.lineNumber+": "+e+"\n" + e.stack); }
+
// vim: set fdm=marker sw=4 ts=4 et ft=javascript:
diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm
index 03ecd413..a97eb519 100644
--- a/common/modules/storage.jsm
+++ b/common/modules/storage.jsm
@@ -152,8 +152,11 @@ var Storage = Module("Storage", {
},
cleanup: function () {
- for (let key in keys(this.keys))
+ for (let key in keys(this.keys)) {
+ if (this[key].timer)
+ this[key].timer.flush();
delete this[key];
+ }
for (let ary in values(this.observers))
for (let obj in values(ary))
if (obj.ref && obj.ref.get())
@@ -239,7 +242,8 @@ var Storage = Module("Storage", {
},
save: function save(key) {
- saveData(this.keys[key]);
+ if (this[key])
+ saveData(this.keys[key]);
},
saveAll: function storeAll() {