From 163539ab29b918536e55c66f220876b705383405 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 27 Dec 2010 01:49:10 -0500 Subject: [PATCH] Fix error trapping in events.feedkeys. --HG-- branch : bootstrapped --- common/content/dactyl.js | 4 ++++ common/content/events.js | 16 ++++++++-------- common/modules/util.jsm | 12 +++++++----- 3 files changed, 19 insertions(+), 13 deletions(-) diff --git a/common/content/dactyl.js b/common/content/dactyl.js index 36ce66f7..b1628e9a 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -410,6 +410,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { util.dump(elem); util.reportError(e); } + if (services.focus.focusedWindow == null) + util.dumpStack("focusedWindow == null"); }, /** @@ -455,6 +457,8 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (elem && elem != dactyl.focusedElement) dactyl.focus(elem); + if (services.focus.focusedWindow == null) + util.dumpStack("focusedWindow == null"); }, /** @property {Element} The currently focused element. */ diff --git a/common/content/events.js b/common/content/events.js index b3aaf6c0..bb6cb901 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -255,15 +255,15 @@ var Events = Module("events", { * @returns {boolean} */ feedkeys: function (keys, noremap, quiet, mode) { - - let wasFeeding = this.feedingKeys; - this.feedingKeys = true; - this.duringFeed = this.duringFeed || []; - let wasQuiet = commandline.quiet; - if (quiet) - commandline.quiet = quiet; - try { + var wasFeeding = this.feedingKeys; + this.feedingKeys = true; + this.duringFeed = this.duringFeed || []; + + var wasQuiet = commandline.quiet; + if (quiet) + commandline.quiet = quiet; + util.threadYield(1, true); for (let [, evt_obj] in Iterator(events.fromString(keys))) { diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 8c79e8cd..518c2f44 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -355,13 +355,15 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), while (!(node instanceof Ci.nsIDOMElement) && node.parentNode) node = node.parentNode; try { - return node.ownerDocument.defaultView.getComputedStyle(node, null); + var res = node.ownerDocument.defaultView.getComputedStyle(node, null); } - catch (e) { - util.reportError(e); - util.dump(String(node)); + catch (e) {} + if (res == null) { + util.dumpStack("Computed style is null: " + node); + Cu.reportError(Error("Computed style is null: " + node)); return {}; } + return res; }, /** @@ -484,7 +486,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), */ dumpStack: function dumpStack(msg, frames) { let stack = util.stackLines(Error().stack); - stack = stack.slice(2, 2 + (frames || 0)).join("\n"); + stack = stack.slice(2, 2 + (frames || stack.length)).join("\n"); util.dump((arguments.length == 0 ? "Stack" : msg) + "\n" + stack + "\n"); },