1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2026-02-15 20:05:45 +01:00

Add a half slew of generic command execution/completion/code coverage tests. Add unhandled exception checking to tests. Fix some detected merge artifacts.

This commit is contained in:
Kris Maglione
2011-01-28 21:59:48 -05:00
parent 5cba6cbc77
commit 199604041b
14 changed files with 422 additions and 64 deletions

View File

@@ -204,7 +204,9 @@ var CommandWidgets = Class("CommandWidgets", {
[this.commandbar, this.statusbar].forEach(function (nodeSet) {
let elem = nodeSet[obj.name];
if (val != null) {
if (val == null)
elem.value = "";
else {
highlight.highlightNode(elem,
(val[0] != null ? val[0] : obj.defaultGroup)
.split(/\s/).filter(util.identity)

View File

@@ -155,7 +155,18 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
if (type in this._observers)
this._observers[type] = this._observers[type].filter(function (callback) {
if (callback.get()) {
callback.get().apply(null, args);
try {
try {
callback.get().apply(null, args);
}
catch (e if e.message == "can't wrap XML objects") {
// Horrible kludge.
callback.get().apply(null, [String(args[0])].concat(args.slice(1)))
}
}
catch (e) {
dactyl.reportError(e);
}
return true;
}
});
@@ -207,6 +218,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
* 'visualbell' option.
*/
beep: function () {
this.triggerObserver("beep");
if (options["visualbell"]) {
let elems = {
bell: document.getElementById("dactyl-bell"),
@@ -1087,6 +1099,12 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}
},
onExecute: function onExecute(event) {
let cmd = event.originalTarget.getAttribute("dactyl-execute");
commands.execute(cmd, null, false, null,
{ file: "[Command Line]", line: 1 });
},
/**
* Opens one or more URLs. Returns true when load was initiated, or
* false on error.
@@ -1331,9 +1349,13 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
*/
reportError: function reportError(error, echo) {
if (error instanceof FailedAssertion || error.message === "Interrupted") {
let prefix = io.sourcing ? io.sourcing.file + ":" + io.sourcing.line + ": " : "";
if (error.message && error.message.indexOf(prefix) !== 0)
error.message = prefix + error.message;
if (error.message)
dactyl.echoerr(template.linkifyHelp(prefix + error.message));
dactyl.echoerr(template.linkifyHelp(error.message));
else
dactyl.beep();
return;
@@ -1428,6 +1450,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
}, {
events: function () {
events.addSessionListener(window, "click", dactyl.closure.onClick, true);
events.addSessionListener(window, "dactyl.execute", dactyl.closure.onExecute, true);
},
// Only general options are added here, which are valid for all Dactyl extensions
options: function () {
@@ -1670,7 +1693,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
function (args) {
try {
let cmd = dactyl.userEval(args[0] || "");
dactyl.execute(cmd, null, true);
dactyl.execute(cmd || "", null, true);
}
catch (e) {
dactyl.echoerr(e);