diff --git a/common/content/completion.js b/common/content/completion.js index 179c77a9..a7a08c34 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -347,9 +347,15 @@ const CompletionContext = Class("CompletionContext", { this.lastActivated = this.top.runCount; } if (!this.itemCache[this.key]) { - let res = this._generate.call(this); - if (res != null) - this.itemCache[this.key] = res; + try { + let res = this._generate.call(this); + if (res != null) + this.itemCache[this.key] = res; + } + catch (e) { + dactyl.reportError(e); + this.message = "Error: " + e; + } } return this.itemCache[this.key]; }, diff --git a/common/content/dactyl-overlay.js b/common/content/dactyl-overlay.js index 04f0ddfa..4b661344 100644 --- a/common/content/dactyl-overlay.js +++ b/common/content/dactyl-overlay.js @@ -5,7 +5,8 @@ "use strict"; (function () { - const modules = {}; + const jsmodules = {} + const modules = { __proto__: jsmodules }; const BASE = "chrome://dactyl/content/"; modules.modules = modules; @@ -27,7 +28,7 @@ } } try { - Components.utils.import("resource://dactyl/" + script + ".jsm", modules); + Components.utils.import("resource://dactyl/" + script + ".jsm", jsmodules); } catch (e) { dump("dactyl: Loading script " + script + ": " + e.result + " " + e + "\n"); diff --git a/common/content/javascript.js b/common/content/javascript.js index 3626c42c..2a13e356 100644 --- a/common/content/javascript.js +++ b/common/content/javascript.js @@ -39,7 +39,8 @@ const JavaScript = Module("javascript", { return; let seen = {}; - for (let key in properties(obj, !toplevel)) { + let globals = values(toplevel && Class.objectGlobal(obj) === obj ? JavaScript.globalNames : []); + for (let key in iterAll(globals, properties(obj, !toplevel))) { set.add(seen, key); yield key; } @@ -587,6 +588,17 @@ const JavaScript = Module("javascript", { */ completers: {}, + /** + * A list of properties of the global object which are not + * enumerable by any standard method. + */ + globalNames: ["Array", "Boolean", "Date", "Error", "EvalError", + "Function", "Infinity", "Math", "NaN", "Number", "Object", + "RangeError", "ReferenceError", "RegExp", "String", + "SyntaxError", "TypeError", "URIError", "decodeURI", + "decodeURIComponent", "encodeURI", "encodeURIComponent", "eval", + "isFinite", "isNaN", "parseFloat", "parseInt", "undefined"], + /** * Installs argument string completers for a set of functions. * The second argument is an array of functions (or null diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 413df1a0..68d10ded 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -734,8 +734,9 @@ function Module(name, prototype) { defineModule.modules.push(instance); return module; } + if (Cu.getGlobalForObject) - Module.callerGlobal = function (caller) { + Class.objectGlobal = function (caller) { try { return Cu.getGlobalForObject(caller); } @@ -744,7 +745,7 @@ if (Cu.getGlobalForObject) } }; else - Module.callerGlobal = function (caller) { + Class.objectGlobal = function (caller) { while (caller.__parent__) caller = caller.__parent__; return caller; diff --git a/common/modules/sanitizer.jsm b/common/modules/sanitizer.jsm index cf0b131d..1dec97b9 100644 --- a/common/modules/sanitizer.jsm +++ b/common/modules/sanitizer.jsm @@ -103,7 +103,7 @@ const Sanitizer = Module("sanitizer", tmp.Sanitizer, { function (key, event, arg) { if (event == name) params.action.apply(params, arg); - }, Module.callerGlobal(params.action)); + }, Class.objectGlobal(params.action)); if (params.privateEnter || params.privateLeave) storage.addObserver("private-mode", @@ -111,7 +111,7 @@ const Sanitizer = Module("sanitizer", tmp.Sanitizer, { let meth = params[arg ? "privateEnter" : "privateLeave"]; if (meth) meth.call(params); - }, Module.callerGlobal(params.action)); + }, Class.objectGlobal(params.action)); }, observe: {