1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 22:07:58 +01:00
Files
pentadactyl-pm/common/tests/functional/utils.jsm
Kris Maglione f3e510837d Manually run Ex completers rather than pushing them through the
command line machinery. It's orders of magnitude faster, on the one
hand, but also runs the display machinery for all results, which may
catch more errors. Errors in the command line completion machinery
should be tested elsewhere.

Fix some sidebar test bugs.

Move dactyl.js and utils.js files out of sandboxes and into modules
so we can pass XML objects in and out of them.

--HG--
rename : common/tests/functional/dactyl.js => common/tests/functional/dactyl.jsm
rename : common/tests/functional/utils.js => common/tests/functional/utils.jsm
2011-02-02 22:01:49 -05:00

49 lines
1.3 KiB
JavaScript

var EXPORTED_SYMBOLS = ["NS", "assert", "assertEqual", "module", "test", "toJSON"];
const Ci = Components.interfaces;
function module(uri) {
if (!/^[a-z-]+:/.exec(uri))
uri = /([^ ]+\/)[^\/]+$/.exec(Components.stack.filename)[1] + uri + ".jsm";
let obj = {};
Components.utils.import(uri, obj);
return obj;
}
var elementslib = module("resource://mozmill/modules/elementslib.js");
var frame = module("resource://mozmill/modules/frame.js");
var jumlib = module("resource://mozmill/modules/jum.js");
function toJSON(val) {
if (typeof val == "function")
return val.toSource();
if (val instanceof Ci.nsIDOMNode || val instanceof Ci.nsIDOMWindow)
return { DOMNode: String(val) };
return val;
}
function test(val, params) {
frame.events[val ? "pass" : "fail"](params);
return val;
}
var NS = Namespace("dactyl", "http://vimperator.org/namespaces/liberator");
function assert(funcName, value, comment)
test(value, {
function: funcName,
value: toJSON(value),
comment: toJSON(comment)
});
function assertEqual(funcName, want, got, comment)
test(want == got, {
function: funcName,
want: toJSON(want), got: toJSON(got),
comment: toJSON(comment)
});
// vim: sw=4 ts=8 et ft=javascript: