diff --git a/common/content/dactyl.js b/common/content/dactyl.js index bda77542..3c262fcc 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -418,7 +418,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { if (isObject(str) && "echoerr" in str) str = str.echoerr; else if (isinstance(str, ["Error", FailedAssertion]) && str.fileName) - str = <>{str.fileName.replace(/^.* -> /, "")}: {str.lineNumber}: {str}; + str = util.Magic([str.fileName.replace(/^.* -> /, ""), ": ", str.lineNumber, ": ", str].join("")); if (options["errorbells"]) dactyl.beep(); diff --git a/common/modules/addons.jsm b/common/modules/addons.jsm index 8ff78dc7..2d5d3728 100644 --- a/common/modules/addons.jsm +++ b/common/modules/addons.jsm @@ -279,8 +279,6 @@ var AddonList = Class("AddonList", { }, message: Class.Memoize(function () { - - XML.ignoreWhitespace = true; DOM.fromJSON(["table", { highlight: "Addons", key: "list" }, ["tr", { highlight: "AddonHead" }, ["td", {}, _("title.Name")], diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 8be0bf0a..9f3f19ba 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -159,6 +159,9 @@ this.lazyRequire("util", ["FailedAssertion", "util"]); function literal(/* comment */) { let { caller } = Components.stack; + while (caller && caller.language != 2) + caller = caller.caller; + let file = caller.filename.replace(/.* -> /, ""); let key = "literal:" + file + ":" + caller.line; diff --git a/common/modules/dom.jsm b/common/modules/dom.jsm index dc364868..47fca1ba 100644 --- a/common/modules/dom.jsm +++ b/common/modules/dom.jsm @@ -17,7 +17,6 @@ var XBL = Namespace("xbl", "http://www.mozilla.org/xbl"); var XHTML = Namespace("html", "http://www.w3.org/1999/xhtml"); var XUL = Namespace("xul", "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"); var NS = Namespace("dactyl", "http://vimperator.org/namespaces/liberator"); -default xml namespace = XHTML; function BooleanAttribute(attr) ({ get: function (elem) elem.getAttribute(attr) == "true", @@ -117,7 +116,6 @@ var DOM = Class("DOM", { }, eachDOM: function eachDOM(val, fn, self) { - XML.prettyPrinting = XML.ignoreWhitespace = false; if (isString(val)) val = XML(val); diff --git a/common/modules/downloads.jsm b/common/modules/downloads.jsm index 15db1bc3..5d12d8bd 100644 --- a/common/modules/downloads.jsm +++ b/common/modules/downloads.jsm @@ -223,8 +223,6 @@ var DownloadList = Class("DownloadList", message: Class.Memoize(function () { - XML.ignoreWhitespace = true; - XML.prettyPrinting = false; DOM.fromJSON(["table", { highlight: "Downloads", key: "list" }, ["tr", { highlight: "DownloadHead", key: "head" }, ["span", {}, _("title.Title")], diff --git a/common/modules/javascript.jsm b/common/modules/javascript.jsm index 10b3cfbe..02fa1bc1 100644 --- a/common/modules/javascript.jsm +++ b/common/modules/javascript.jsm @@ -119,7 +119,8 @@ var JavaScript = Module("javascript", { context[JavaScript.EVAL_TMP] = tmp; try { - cache[key] = this.modules.dactyl.userEval(arg, context, /*L*/"[Command Line Completion]", 1); + cache[key] = this.modules.dactyl.userEval(arg, context, + /*L*/"[Command Line Completion]", 1); return cache[key]; } diff --git a/common/modules/main.jsm b/common/modules/main.jsm index da124441..26f1524a 100644 --- a/common/modules/main.jsm +++ b/common/modules/main.jsm @@ -90,20 +90,13 @@ var Modules = function Modules(window) { Module.list = []; Module.constructors = {}; - const create = window.Object.create || (function () { - window.__dactyl_eval_string = "(function (proto) ({ __proto__: proto }))"; - JSMLoader.loadSubScript(BASE + "eval.js", window); - - let res = window.__dactyl_eval_result; - delete window.__dactyl_eval_string; - delete window.__dactyl_eval_result; - return res; - })(); + const create = window.Object.create.bind(window.Object); const BASES = [BASE, "resource://dactyl-local-content/"]; - const jsmodules = { NAME: "jsmodules" }; + jsmodules = Cu.createObjectIn(window); + jsmodules.NAME = "jsmodules"; const modules = update(create(jsmodules), { yes_i_know_i_should_not_report_errors_in_these_branches_thanks: [], diff --git a/common/modules/options.jsm b/common/modules/options.jsm index aaef95b7..fda3cd47 100644 --- a/common/modules/options.jsm +++ b/common/modules/options.jsm @@ -1295,24 +1295,7 @@ var Options = Module("options", { function fmt(value) (typeof value == "number" ? "#" : typeof value == "function" ? "*" : " ") + value; - if (!args || args == "g:") { - let str = - - { - template.map(globalVariables, function ([i, value]) { - return - - - ; - }) - } -
{i}{fmt(value)}
; - if (str.text().length() == str.*.length()) - dactyl.echomsg(_("variable.none")); - else - dactyl.echo(str, modules.commandline.FORCE_MULTILINE); - return; - } + util.assert(!(!args || args == "g:")); let matches = args.match(/^([a-z]:)?([\w]+)(?:\s*([-+.])?=\s*(.*)?)?$/); if (matches) { diff --git a/common/modules/overlay.jsm b/common/modules/overlay.jsm index 44c5a2ee..43b8b07a 100644 --- a/common/modules/overlay.jsm +++ b/common/modules/overlay.jsm @@ -157,9 +157,20 @@ var Overlay = Module("Overlay", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReferen getData: function getData(obj, key, constructor) { if (!this.weakMap.has(obj)) - this.weakMap.set(obj, {}); + try { + this.weakMap.set(obj, {}); + } + catch (e if e instanceof TypeError) { + // util.dump("Bad WeakMap key: " + obj + " " + Components.stack.caller); + let { id } = this; - let data = this.weakMap.get(obj); + if (!(id in obj && obj[id])) + obj[id] = {}; + + var data = obj[id]; + } + + data = data || this.weakMap.get(obj); if (arguments.length == 1) return data; diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index 2b20ada7..20706767 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -359,6 +359,8 @@ var File = Class("File", { return File.DoesNotExist(path, e); } } + this.file = file; + let self = XPCSafeJSObjectWrapper(file.QueryInterface(Ci.nsILocalFile)); self.__proto__ = this; return self; diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index 741e729e..01e4e468 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -35,9 +35,9 @@ Sheet.liveProperty("css"); Sheet.liveProperty("sites"); update(Sheet.prototype, { formatSites: function (uris) - template.map(this.sites, - function (filter) {filter}, - <>,), + template_.map(this.sites, + function (filter) ["span", { highlight: uris.some(Styles.matchFilter(filter)) ? "Filter" : "" }, filter], + ","), remove: function () { this.hive.remove(this); }, diff --git a/common/modules/template.jsm b/common/modules/template.jsm index 914e993e..aa4503cc 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -317,6 +317,8 @@ var Template = Module("Template", { case "object": if (arg instanceof Ci.nsIDOMElement) return util.objectToString(arg, !bw); + if (arg instanceof util.Magic) + return <>{arg}; // for java packages value.toString() would crash so badly // that we cannot even try/catch it @@ -718,6 +720,8 @@ var Template_ = Module("Template_", { case "object": if (arg instanceof Ci.nsIDOMElement) return util.objectToString(arg, !bw); + if (arg instanceof Magic) + return String(arg); if (processStrings && false) str = template._highlightFilter(str, "\n", diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 58d62e04..8c66f5c0 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -17,6 +17,14 @@ lazyRequire("overlay", ["overlay"]); lazyRequire("storage", ["File", "storage"]); lazyRequire("template", ["template"]); +var Magic = Class("Magic", { + init: function init(str) { + this.str = str; + }, + + toString: function () this.str +}); + var FailedAssertion = Class("FailedAssertion", ErrorBase, { init: function init(message, level, noTrace) { if (noTrace !== undefined) @@ -52,6 +60,8 @@ var wrapCallback = function wrapCallback(fn, isEvent) { } var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), { + Magic: Magic, + init: function () { this.Array = array; @@ -997,7 +1007,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), keyIter = keys(object) for (let i in keyIter) { - let value = ]]>; + let value = Magic(""); try { value = object[i]; } @@ -1204,7 +1214,11 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), // Replace replacement . if (tokens) - expr = String.replace(expr, /(\(?P)?<(\w+)>/g, function (m, n1, n2) !n1 && Set.has(tokens, n2) ? tokens[n2].dactylSource || tokens[n2].source || tokens[n2] : m); + expr = String.replace(expr, /(\(?P)?<(\w+)>/g, + function (m, n1, n2) !n1 && Set.has(tokens, n2) ? tokens[n2].dactylSource + || tokens[n2].source + || tokens[n2] + : m); // Strip comments and white space. if (/x/.test(flags)) @@ -1322,7 +1336,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), let obj = update({}, error, { toString: function () String(error), - stack: <>{util.stackLines(String(error.stack || Error().stack)).join("\n").replace(/^/mg, "\t")} + stack: Magic(util.stackLines(String(error.stack || Error().stack)).join("\n").replace(/^/mg, "\t")) }); services.console.logStringMessage(obj.stack); diff --git a/pentadactyl/install.rdf b/pentadactyl/install.rdf index 6073c976..cb05ecfe 100644 --- a/pentadactyl/install.rdf +++ b/pentadactyl/install.rdf @@ -31,8 +31,8 @@ + em:minVersion="8.0" + em:maxVersion="17.*"/>