mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2025-12-20 22:07:58 +01:00
Make :addons marginally functional on FF36.
This commit is contained in:
@@ -314,13 +314,14 @@ var Buffer = Module("buffer", {
|
|||||||
|
|
||||||
statusline.updateUrl();
|
statusline.updateUrl();
|
||||||
|
|
||||||
if (webProgress.DOMWindow && uri) {
|
let win = webProgress.DOMWindow;
|
||||||
statusline.updateProgress(webProgress.DOMWindow);
|
if (win && uri) {
|
||||||
|
statusline.updateProgress(win);
|
||||||
|
|
||||||
let oldURI = webProgress.document.dactylURI;
|
let oldURI = webProgress.document.dactylURI;
|
||||||
if (webProgress.document.dactylLoadIdx === webProgress.loadedTransIndex
|
if (webProgress.document.dactylLoadIdx === webProgress.loadedTransIndex
|
||||||
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
|
|| !oldURI || uri.spec.replace(/#.*/, "") !== oldURI.replace(/#.*/, ""))
|
||||||
for (let frame in values(buffer.allFrames(webProgress.DOMWindow)))
|
for (let frame in values(buffer.allFrames(win)))
|
||||||
frame.document.dactylFocusAllowed = false;
|
frame.document.dactylFocusAllowed = false;
|
||||||
webProgress.document.dactylURI = uri.spec;
|
webProgress.document.dactylURI = uri.spec;
|
||||||
webProgress.document.dactylLoadIdx = webProgress.loadedTransIndex;
|
webProgress.document.dactylLoadIdx = webProgress.loadedTransIndex;
|
||||||
@@ -334,7 +335,7 @@ var Buffer = Module("buffer", {
|
|||||||
|
|
||||||
util.timeout(function () {
|
util.timeout(function () {
|
||||||
buffer._triggerLoadAutocmd("LocationChange",
|
buffer._triggerLoadAutocmd("LocationChange",
|
||||||
(webProgress.DOMWindow || content).document,
|
(win || content).document,
|
||||||
uri);
|
uri);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -588,7 +588,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), {
|
|||||||
* Initialize the help system.
|
* Initialize the help system.
|
||||||
*/
|
*/
|
||||||
initHelp: function (force) {
|
initHelp: function (force) {
|
||||||
if (!force && !this.helpInitialized) {
|
if (force || !this.helpInitialized) {
|
||||||
if ("noscriptOverlay" in window) {
|
if ("noscriptOverlay" in window) {
|
||||||
noscriptOverlay.safeAllow("chrome-data:", true, false);
|
noscriptOverlay.safeAllow("chrome-data:", true, false);
|
||||||
noscriptOverlay.safeAllow("dactyl:", true, false);
|
noscriptOverlay.safeAllow("dactyl:", true, false);
|
||||||
|
|||||||
@@ -703,7 +703,7 @@ var Mappings = Module("mappings", {
|
|||||||
keepQuotes: true,
|
keepQuotes: true,
|
||||||
options: [
|
options: [
|
||||||
{
|
{
|
||||||
names: ["-description", "-d"],
|
names: ["-description", "-desc", "-d"],
|
||||||
description: "A description of this mapping group",
|
description: "A description of this mapping group",
|
||||||
type: CommandOption.STRING
|
type: CommandOption.STRING
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -348,12 +348,15 @@ var Tabs = Module("tabs", {
|
|||||||
* reloading.
|
* reloading.
|
||||||
*/
|
*/
|
||||||
reload: function (tab, bypassCache) {
|
reload: function (tab, bypassCache) {
|
||||||
|
try {
|
||||||
if (bypassCache) {
|
if (bypassCache) {
|
||||||
const flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
|
const flags = Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | Ci.nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
|
||||||
config.tabbrowser.getBrowserForTab(tab).reloadWithFlags(flags);
|
config.tabbrowser.getBrowserForTab(tab).reloadWithFlags(flags);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
config.tabbrowser.reloadTab(tab);
|
config.tabbrowser.reloadTab(tab);
|
||||||
|
}
|
||||||
|
catch (e if !(e instanceof Error)) {}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -436,18 +436,24 @@ var Addons = Module("addons", {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!Ci.nsIExtensionManager || !services.extensionManager)
|
if (!("nsIExtensionManager" in Ci) || !services.extensionManager)
|
||||||
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
Components.utils.import("resource://gre/modules/AddonManager.jsm");
|
||||||
else
|
else
|
||||||
var AddonManager = {
|
var AddonManager = {
|
||||||
|
PERM_CAN_UNINSTALL: 1,
|
||||||
|
PERM_CAN_ENABLE: 2,
|
||||||
|
PERM_CAN_DISABLE: 4,
|
||||||
|
PERM_CAN_UPGRADE: 8,
|
||||||
|
|
||||||
getAddonByID: function (id, callback) {
|
getAddonByID: function (id, callback) {
|
||||||
callback = callback || util.identity;
|
callback = callback || util.identity;
|
||||||
let addon = id;
|
|
||||||
if (!isObject(addon))
|
|
||||||
addon = services.extensionManager.getItemForID(id);
|
addon = services.extensionManager.getItemForID(id);
|
||||||
if (!addon)
|
if (addon)
|
||||||
return callback(null);
|
addon = this.wrapAddon(addon);
|
||||||
addon = Object.create(addon);
|
return callback(addon);
|
||||||
|
},
|
||||||
|
wrapAddon: function wrapAddon(addon) {
|
||||||
|
addon = Object.create(addon.QueryInterface(Ci.nsIUpdateItem));
|
||||||
|
|
||||||
function getRdfProperty(item, property) {
|
function getRdfProperty(item, property) {
|
||||||
let resource = services.rdf.GetResource("urn:mozilla:item:" + item.id);
|
let resource = services.rdf.GetResource("urn:mozilla:item:" + item.id);
|
||||||
@@ -471,6 +477,8 @@ else
|
|||||||
|
|
||||||
update(addon, {
|
update(addon, {
|
||||||
|
|
||||||
|
get permissions() 1 | (this.userDisabled ? 2 : 4),
|
||||||
|
|
||||||
appDisabled: false,
|
appDisabled: false,
|
||||||
|
|
||||||
installLocation: Class.memoize(function () services.extensionManager.getInstallLocation(this.id)),
|
installLocation: Class.memoize(function () services.extensionManager.getInstallLocation(this.id)),
|
||||||
@@ -491,15 +499,18 @@ else
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
return callback(addon);
|
return addon;
|
||||||
},
|
},
|
||||||
getAddonsByTypes: function (types, callback) {
|
getAddonsByTypes: function (types, callback) {
|
||||||
let res = [];
|
let res = [];
|
||||||
for (let [, type] in Iterator(types))
|
for (let [, type] in Iterator(types))
|
||||||
for (let [, item] in Iterator(services.extensionManager
|
for (let [, item] in Iterator(services.extensionManager
|
||||||
.getItemList(Ci.nsIUpdateItem["TYPE_" + type.toUpperCase()], {})))
|
.getItemList(Ci.nsIUpdateItem["TYPE_" + type.toUpperCase()], {})))
|
||||||
res.push(this.getAddonByID(item));
|
res.push(this.wrapAddon(item));
|
||||||
return (callback || util.identity)(res);
|
|
||||||
|
if (callback)
|
||||||
|
util.timeout(function () { callback(res); });
|
||||||
|
return res;
|
||||||
},
|
},
|
||||||
getInstallForFile: function (file, callback, mimetype) {
|
getInstallForFile: function (file, callback, mimetype) {
|
||||||
callback({
|
callback({
|
||||||
@@ -512,6 +523,34 @@ else
|
|||||||
getInstallForURL: function (url, callback, mimetype) {
|
getInstallForURL: function (url, callback, mimetype) {
|
||||||
dactyl.assert(false, "Install by URL not implemented");
|
dactyl.assert(false, "Install by URL not implemented");
|
||||||
},
|
},
|
||||||
|
observers: [],
|
||||||
|
addAddonListener: function (listener) {
|
||||||
|
observer.listener = listener;
|
||||||
|
function observer(subject, topic, data) {
|
||||||
|
if (subject instanceof Ci.nsIUpdateItem)
|
||||||
|
subject = AddonManager.wrapAddon(subject);
|
||||||
|
|
||||||
|
if (data === "item-installed")
|
||||||
|
listener.onInstalling(subject, true);
|
||||||
|
else if (data === "item-uninstalled")
|
||||||
|
listener.onUnistalling(subject, true);
|
||||||
|
else if (data === "item-upgraded")
|
||||||
|
listener.onInstalling(subject, true);
|
||||||
|
else if (data === "item-enabled")
|
||||||
|
listener.onEnabling(subject, true);
|
||||||
|
else if (data === "item-disabled")
|
||||||
|
listener.onDisabling(subject, true);
|
||||||
|
}
|
||||||
|
services.observer.addObserver(observer, "em-action-requested", false);
|
||||||
|
this.observers.push(observer);
|
||||||
|
},
|
||||||
|
removeAddonListener: function (listener) {
|
||||||
|
this.observers = this.observers.filter(function (observer) {
|
||||||
|
if (observer.listener !== listener)
|
||||||
|
return true;
|
||||||
|
services.observer.removeObserver(observer, "em-action-requested");
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var addonErrors = array.toObject([
|
var addonErrors = array.toObject([
|
||||||
@@ -522,8 +561,15 @@ var addonErrors = array.toObject([
|
|||||||
|
|
||||||
endModule();
|
endModule();
|
||||||
|
|
||||||
iter.forEach(properties(config.addon), function (prop) {
|
let iterator = properties(config.addon);
|
||||||
let desc = Object.getOwnPropertyDescriptor(config.addon, prop);
|
if ("nsIUpdateItem" in Ci)
|
||||||
|
iterator = iter(iterator, properties(config.addon.__proto__));
|
||||||
|
|
||||||
|
iter.forEach(iterator, function (prop) {
|
||||||
|
let desc = Object.getOwnPropertyDescriptor(config.addon, prop) ||
|
||||||
|
Object.getOwnPropertyDescriptor(config.addon.__proto__, prop);
|
||||||
|
|
||||||
|
if (!set.has(Addon.prototype, prop))
|
||||||
if (callable(desc.value))
|
if (callable(desc.value))
|
||||||
Addon.prototype[prop] = function proxy() this.addon[prop].apply(this.addon, arguments);
|
Addon.prototype[prop] = function proxy() this.addon[prop].apply(this.addon, arguments);
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ function Controller(controller) {
|
|||||||
}
|
}
|
||||||
this._countError = function countError(message, highlight) {
|
this._countError = function countError(message, highlight) {
|
||||||
if (/\bErrorMsg\b/.test(highlight))
|
if (/\bErrorMsg\b/.test(highlight))
|
||||||
self.errorCount++;
|
self.errorMessageCount++;
|
||||||
}
|
}
|
||||||
this.dactyl.dactyl.registerObserver("beep", this._countBeep);
|
this.dactyl.dactyl.registerObserver("beep", this._countBeep);
|
||||||
this.dactyl.dactyl.registerObserver("echoLine", this._countError);
|
this.dactyl.dactyl.registerObserver("echoLine", this._countError);
|
||||||
@@ -69,6 +69,7 @@ Controller.prototype = {
|
|||||||
|
|
||||||
beepCount: 0,
|
beepCount: 0,
|
||||||
errorCount: 0,
|
errorCount: 0,
|
||||||
|
errorMessageCount: 0,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that an error message is displayed during the execution
|
* Asserts that an error message is displayed during the execution
|
||||||
@@ -82,10 +83,10 @@ Controller.prototype = {
|
|||||||
* @param {string} message The message to display upon assertion failure. @optional
|
* @param {string} message The message to display upon assertion failure. @optional
|
||||||
*/
|
*/
|
||||||
assertMessageError: function (func, self, args, message) {
|
assertMessageError: function (func, self, args, message) {
|
||||||
let errorCount = this.errorCount;
|
let errorCount = this.errorMessageCount;
|
||||||
this.assertNoErrors(func, self, args, message);
|
this.assertNoErrors(func, self, args, message);
|
||||||
// dump("assertMessageError " + errorCount + " " + this.errorCount + "\n");
|
// dump("assertMessageError " + errorCount + " " + this.errorMessageCount + "\n");
|
||||||
return utils.assert('dactyl.assertMessageError', this.errorCount > errorCount,
|
return utils.assert('dactyl.assertMessageError', this.errorMessageCount > errorCount,
|
||||||
"Expected error but got none" + (message ? ": " + message : ""));
|
"Expected error but got none" + (message ? ": " + message : ""));
|
||||||
},
|
},
|
||||||
|
|
||||||
@@ -164,13 +165,12 @@ Controller.prototype = {
|
|||||||
* of *func*. @optional
|
* of *func*. @optional
|
||||||
* @param {Array} args Arguments to be passed to *func*. @optional
|
* @param {Array} args Arguments to be passed to *func*. @optional
|
||||||
* @param {string} message The message to display upon assertion failure. @optional
|
* @param {string} message The message to display upon assertion failure. @optional
|
||||||
* @param {string} message The message to display upon assertion failure. @optional
|
|
||||||
*/
|
*/
|
||||||
assertNoErrors: function (func, self, args, message) {
|
assertNoErrors: function (func, self, args, message) {
|
||||||
let msg = message ? ": " + message : "";
|
let msg = message ? ": " + message : "";
|
||||||
|
|
||||||
let beepCount = this.beepCount;
|
let beepCount = this.beepCount;
|
||||||
let errorCount = this.errorCount;
|
let errorCount = this.errorCount;
|
||||||
|
|
||||||
if (func) {
|
if (func) {
|
||||||
errorCount = this.dactyl.util.errorCount;
|
errorCount = this.dactyl.util.errorCount;
|
||||||
|
|
||||||
@@ -198,6 +198,34 @@ Controller.prototype = {
|
|||||||
"Errors were reported during the execution of this test" + msg + "\n" + errors);
|
"Errors were reported during the execution of this test" + msg + "\n" + errors);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that the no error messages are reported during the call
|
||||||
|
* of *func*.
|
||||||
|
*
|
||||||
|
* @param {function} func A function to call during before the
|
||||||
|
* assertion takes place. When present, the current error count
|
||||||
|
* is reset before execution.
|
||||||
|
* @optional
|
||||||
|
* @param {object} self The 'this' object to be used during the call
|
||||||
|
* of *func*. @optional
|
||||||
|
* @param {Array} args Arguments to be passed to *func*. @optional
|
||||||
|
* @param {string} message The message to display upon assertion failure. @optional
|
||||||
|
*/
|
||||||
|
assertNoErrorMessages: function (func, self, args, message) {
|
||||||
|
let msg = message ? ": " + message : "";
|
||||||
|
let count = this.errorMessageCount;
|
||||||
|
|
||||||
|
try {
|
||||||
|
func.apply(self || this, args || []);
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
this.dactyl.util.reportError(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return utils.assertEqual('dactyl.assertNoErrorMessages', count, this.errorMessageCount,
|
||||||
|
"Error messsages were reported" + msg);
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the error count used to determine whether new errors were
|
* Resets the error count used to determine whether new errors were
|
||||||
* reported during the execution of a test.
|
* reported during the execution of a test.
|
||||||
@@ -352,7 +380,7 @@ Controller.prototype = {
|
|||||||
runExCompletion: wrapAssertNoErrors(function (cmd) {
|
runExCompletion: wrapAssertNoErrors(function (cmd) {
|
||||||
this.setExMode();
|
this.setExMode();
|
||||||
|
|
||||||
utils.assertEqual("dactyl.runExCompletion",
|
utils.assertEqual("dactyl.assertCommandLineFocused",
|
||||||
this.elements.commandInput,
|
this.elements.commandInput,
|
||||||
this.elements.focused,
|
this.elements.focused,
|
||||||
"Running Ex Completion: The command line is not focused");
|
"Running Ex Completion: The command line is not focused");
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ var tests = {
|
|||||||
anyOutput: ["about:pentadactyl"]
|
anyOutput: ["about:pentadactyl"]
|
||||||
},
|
},
|
||||||
bmark: {
|
bmark: {
|
||||||
anyOutput: ["bmark", "bmark -tags=foo -titlt=bar -keyword=baz -charset=UTF-8 -post=quux about:pentadactyl"],
|
someOutput: ["bmark", "bmark -tags=foo -titlt=bar -keyword=baz -charset=UTF-8 -post=quux about:pentadactyl"],
|
||||||
error: ["bmark -tags=foo -titlt=bar -keyword=baz -charset=nonExistentCharset -post=quux about:pentadactyl"],
|
error: ["bmark -tags=foo -titlt=bar -keyword=baz -charset=nonExistentCharset -post=quux about:pentadactyl"],
|
||||||
completions: [
|
completions: [
|
||||||
"-max=1 -keyword=",
|
"-max=1 -keyword=",
|
||||||
@@ -71,14 +71,16 @@ var tests = {
|
|||||||
completions: ["", "1"]
|
completions: ["", "1"]
|
||||||
},
|
},
|
||||||
cd: {
|
cd: {
|
||||||
anyOutput: ["", "~/"],
|
lineOutput: ["", "~/"],
|
||||||
completions: ["", "~/"]
|
completions: ["", "~/"]
|
||||||
},
|
},
|
||||||
colorscheme: {
|
colorscheme: {
|
||||||
error: ["", "some-non-existent-scheme"]
|
error: ["", "some-non-existent-scheme"]
|
||||||
},
|
},
|
||||||
command: {
|
command: {
|
||||||
anyOutput: ["", "foo", "foo bar", "-js bar baz"],
|
multiOutput: [""],
|
||||||
|
someOutput: ["foo"],
|
||||||
|
noOutput: ["foo bar", "-js bar baz"],
|
||||||
error: ["foo bar", "-js bar baz"]
|
error: ["foo bar", "-js bar baz"]
|
||||||
},
|
},
|
||||||
comclear: {
|
comclear: {
|
||||||
@@ -103,9 +105,7 @@ var tests = {
|
|||||||
get delmarks() this.delmacros,
|
get delmarks() this.delmacros,
|
||||||
get delqmarks() this.delmacros,
|
get delqmarks() this.delmacros,
|
||||||
delstyle: {
|
delstyle: {
|
||||||
completions: [
|
completions: ["", "-name=", "-name=foo ", "-index=", "-index="]
|
||||||
"", "-name=", "-name=foo ", "-index=", "-index="
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
dialog: {
|
dialog: {
|
||||||
// Skip implementation for now
|
// Skip implementation for now
|
||||||
@@ -114,7 +114,7 @@ var tests = {
|
|||||||
doautoall: {}, // Skip for now
|
doautoall: {}, // Skip for now
|
||||||
doautocmd: {}, // Skip for now
|
doautocmd: {}, // Skip for now
|
||||||
downloads: {
|
downloads: {
|
||||||
multiOutput: ["", "dactyl", "-type=extension", "-type=extension dactyl"]
|
multiOutput: ["", "dactyl", "dactyl"]
|
||||||
},
|
},
|
||||||
echo: {
|
echo: {
|
||||||
singleOutput: ["' - '"],
|
singleOutput: ["' - '"],
|
||||||
@@ -127,7 +127,10 @@ var tests = {
|
|||||||
"commands.get('"
|
"commands.get('"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
get echoerr() this.echo,
|
get echoerr() ({
|
||||||
|
errorsOk: true,
|
||||||
|
__proto__: this.echo,
|
||||||
|
}),
|
||||||
get echomsg() this.echo,
|
get echomsg() this.echo,
|
||||||
else: {}, // Skip for now
|
else: {}, // Skip for now
|
||||||
elseif: {}, // Skip for now
|
elseif: {}, // Skip for now
|
||||||
@@ -218,50 +221,180 @@ var tests = {
|
|||||||
get listoptions() this.listcommands,
|
get listoptions() this.listcommands,
|
||||||
loadplugins: {},
|
loadplugins: {},
|
||||||
macros: {
|
macros: {
|
||||||
multiOutput: [""]
|
multiOutput: [""],
|
||||||
|
complete: [""]
|
||||||
},
|
},
|
||||||
map: {
|
map: {
|
||||||
multiOutput: ["", "i"],
|
multiOutput: ["", "i"],
|
||||||
noOutput: ["i j", "-b i j", "-js i j()", "-ex i :j"]
|
noOutput: [
|
||||||
|
"i j",
|
||||||
|
"-builtin i j",
|
||||||
|
"-group=user -b i j",
|
||||||
|
"-js i j()",
|
||||||
|
"-ex i :j",
|
||||||
|
"-silent i :j",
|
||||||
|
"-mode=ex -b <C-a> <C-a>"
|
||||||
|
],
|
||||||
|
error: [
|
||||||
|
"-mode=some-nonexistent-mode <C-a> <C-a>",
|
||||||
|
"-gtroup=some-nonexistent-group <C-a> <C-a>"
|
||||||
|
],
|
||||||
|
complete: [
|
||||||
|
"",
|
||||||
|
"-",
|
||||||
|
"-mode=ex ",
|
||||||
|
"-mode=",
|
||||||
|
"-group=",
|
||||||
|
"-builtin i ",
|
||||||
|
"-ex i ",
|
||||||
|
"-javascript i ",
|
||||||
|
]
|
||||||
},
|
},
|
||||||
mapclear: {
|
mapclear: {
|
||||||
|
noOutput: [""],
|
||||||
|
complete: [""]
|
||||||
|
},
|
||||||
|
mapgroup: {
|
||||||
|
multiOutput: [""],
|
||||||
|
noOutput: [
|
||||||
|
"foo -d='foo group' -nopersist 'bar.com,http://bar/*,http://bar,^http:'",
|
||||||
|
"! foo -d='foo group' -nopersist 'bar.com,http://bar/*,http://bar,^http:'",
|
||||||
|
"foo",
|
||||||
|
"user"
|
||||||
|
],
|
||||||
|
error: [
|
||||||
|
"some-nonexistent-group",
|
||||||
|
"foo -d='foo group' -nopersist 'bar.com,http://bar/*,http://bar,^http:'"
|
||||||
|
],
|
||||||
|
complete: [
|
||||||
|
"",
|
||||||
|
"foo "
|
||||||
|
],
|
||||||
|
cleanup: ["delmapgroup foo"]
|
||||||
|
},
|
||||||
|
mark: {
|
||||||
|
error: ["", "#", "xy"],
|
||||||
|
noOutput: ["y"],
|
||||||
|
complete: [""]
|
||||||
|
},
|
||||||
|
marks: {
|
||||||
|
init: ["delmarks q"],
|
||||||
|
multiOutput: ["", "y"],
|
||||||
|
error: ["q", "#"],
|
||||||
|
complete: [""]
|
||||||
|
},
|
||||||
|
messages: {
|
||||||
|
anyOutput: ["messages"]
|
||||||
|
},
|
||||||
|
messclear: {
|
||||||
|
error: ["q"],
|
||||||
noOutput: [""]
|
noOutput: [""]
|
||||||
},
|
},
|
||||||
mapgroup: {},
|
mkpentadactylrc: {
|
||||||
mark: {},
|
noOutput: [
|
||||||
marks: {},
|
"some-nonexistent-rc.penta",
|
||||||
messages: {},
|
"! some-nonexistent-rc.penta"
|
||||||
messclear: {},
|
],
|
||||||
mkpentadactylrc: {},
|
error: ["some-nonexistent-rc.penta"],
|
||||||
mksyntax: {},
|
complete: [""],
|
||||||
mlistkeys: {},
|
cleanup: ["silent !rm some-nonexistent-rc.penta"]
|
||||||
mmap: {},
|
},
|
||||||
mmapclear: {},
|
mksyntax: {
|
||||||
mnoremap: {},
|
noOutput: [
|
||||||
munmap: {},
|
"some-nonexistent-pentadactyl-dir/",
|
||||||
nlistkeys: {},
|
"! some-nonexistent-pentadactyl-dir/",
|
||||||
nmap: {},
|
"some-nonexistent-pentadactyl-dir/foo.vim",
|
||||||
nmapclear: {},
|
"! some-nonexistent-pentadactyl-dir/foo.vim",
|
||||||
nnoremap: {},
|
],
|
||||||
nohlfind: {},
|
error: [
|
||||||
noremap: {},
|
"some-nonexistent-pentadactyl-dir/",
|
||||||
normal: {},
|
"some-nonexistent-pentadactyl-dir/foo.vim"
|
||||||
nunmap: {},
|
],
|
||||||
open: {},
|
complete: [""],
|
||||||
pageinfo: {},
|
cleanup: ["silent !rm -r some-nonexistent-pentadactyl-dir/"]
|
||||||
pagestyle: {},
|
},
|
||||||
preferences: {},
|
normal: {
|
||||||
pwd: {},
|
noOutput: ["<Nop>"],
|
||||||
qmark: {},
|
lineOutput: ["<C-g>"],
|
||||||
qmarks: {},
|
multiOutput: ["g<C-g>"]
|
||||||
quit: {},
|
},
|
||||||
quitall: {},
|
open: {
|
||||||
redraw: {},
|
noOutput: ["about:blank | about:home"],
|
||||||
rehash: {},
|
complete: [
|
||||||
reload: {},
|
"",
|
||||||
reloadall: {},
|
"./",
|
||||||
restart: {},
|
"./ | ",
|
||||||
runtime: {},
|
"chrome://",
|
||||||
|
"chrome://browser/",
|
||||||
|
"chrome://browser/content/",
|
||||||
|
"about:",
|
||||||
|
"resource://",
|
||||||
|
"resource://dactyl/"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
pageinfo: {
|
||||||
|
multiOutput: ["", "fgm"],
|
||||||
|
complete: [""],
|
||||||
|
error: ["abcdefghijklmnopqrstuvwxyz", "f g m"]
|
||||||
|
},
|
||||||
|
pagestyle: {
|
||||||
|
complete: [""]
|
||||||
|
},
|
||||||
|
preferences: {}, // Skip for now
|
||||||
|
pwd: {
|
||||||
|
singleOutput: [""]
|
||||||
|
},
|
||||||
|
qmark: {
|
||||||
|
lineOutput: [
|
||||||
|
"m",
|
||||||
|
"m foo bar"
|
||||||
|
],
|
||||||
|
error: ["", "#"],
|
||||||
|
complete: ["", "m "]
|
||||||
|
},
|
||||||
|
qmarks: {
|
||||||
|
init: ["delqmarks x"],
|
||||||
|
multiOutput: ["", "m", "x"],
|
||||||
|
complete: [""]
|
||||||
|
},
|
||||||
|
quit: {}, // Skip for now
|
||||||
|
quitall: {}, // Skip for now
|
||||||
|
redraw: {
|
||||||
|
noOutput: [""]
|
||||||
|
},
|
||||||
|
rehash: {}, // Skip for now
|
||||||
|
reload: {
|
||||||
|
noOutput: [""]
|
||||||
|
},
|
||||||
|
reloadall: {
|
||||||
|
noOutput: [""]
|
||||||
|
},
|
||||||
|
restart: {}, // Skip
|
||||||
|
runtime: {
|
||||||
|
init: [
|
||||||
|
"js File('~/.pentadactyl/some-nonexistent/good.css').write('')",
|
||||||
|
"js File('~/.pentadactyl/some-nonexistent/good.js').write('')",
|
||||||
|
"js File('~/.pentadactyl/some-nonexistent/bad.js').write('dactyl.echoerr(\"error\")')",
|
||||||
|
"js File('~/.pentadactyl/some-nonexistent/good.penta').write('')",
|
||||||
|
"js File('~/.pentadactyl/some-nonexistent/bad.penta').write('echoerr \"error\"')",
|
||||||
|
],
|
||||||
|
cleanup: ["js File('~/.pentadactyl/some-nonexistent').remove(true)"],
|
||||||
|
noOutput: [
|
||||||
|
"some-nonexistent/good.css",
|
||||||
|
"some-nonexistent/good.js",
|
||||||
|
"some-nonexistent/good.penta"
|
||||||
|
],
|
||||||
|
errors: [
|
||||||
|
"some-nonexistent/bad.js",
|
||||||
|
"some-nonexistent/bad.penta"
|
||||||
|
],
|
||||||
|
singleOutput: ["some-nonexistent-file.js"],
|
||||||
|
complete: [
|
||||||
|
"",
|
||||||
|
"plugins/",
|
||||||
|
"info/"
|
||||||
|
]
|
||||||
|
},
|
||||||
sanitize: {},
|
sanitize: {},
|
||||||
saveas: {},
|
saveas: {},
|
||||||
sbclose: {},
|
sbclose: {},
|
||||||
@@ -326,22 +459,37 @@ function addTest(cmdName, testName, func) {
|
|||||||
global["testCommand_" + cmdName + "_" + testName] = func;
|
global["testCommand_" + cmdName + "_" + testName] = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
function runCommands(cmdName, testName, commands, test) {
|
function runCommands(cmdName, testName, commands, test, forbidErrors) {
|
||||||
addTest(cmdName, testName, function () {
|
addTest(cmdName, testName, function () {
|
||||||
commands.forEach(function (cmd) {
|
commands.forEach(function (cmd) {
|
||||||
// dump("CMD: " + cmdName + " " + cmd + "\n");
|
// dump("CMD: " + cmdName + " " + cmd + "\n");
|
||||||
dactyl.clearMessage();
|
dactyl.clearMessage();
|
||||||
dactyl.closeMessageWindow();
|
dactyl.closeMessageWindow();
|
||||||
|
|
||||||
cmd = cmdName + cmd.replace(/^(!?) ?/, "$1 ");
|
cmd = cmdName + cmd.replace(/^(!?) ?/, "$1 ");
|
||||||
|
if (forbidErrors)
|
||||||
|
dactyl.assertNoErrorMessages(function () { dactyl.runExCommand(cmd) },
|
||||||
|
null, [], cmd);
|
||||||
|
else
|
||||||
dactyl.runExCommand(cmd);
|
dactyl.runExCommand(cmd);
|
||||||
|
controller.waitForPageLoad(controller.tabs.activeTab);
|
||||||
|
|
||||||
test(cmd);
|
test(cmd);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function _runCommands(cmdName, testName, commands) {
|
||||||
|
addTest(cmdName, testName, function () {
|
||||||
|
commands.forEach(function (cmd) {
|
||||||
|
dactyl.runExCommand(cmd);
|
||||||
|
controller.waitForPageLoad(controller.tabs.activeTab);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
for (var val in Iterator(tests)) (function ([command, params]) {
|
for (var val in Iterator(tests)) (function ([command, params]) {
|
||||||
if (params.init)
|
if (params.init)
|
||||||
runCommands(command, "init", params.init, function () {});
|
_runCommands(command, "init", params.init, function () {});
|
||||||
|
|
||||||
// Goddamn stupid fucking MozMill and its stupid fucking sandboxes with their ancient fucking JS versions.
|
// Goddamn stupid fucking MozMill and its stupid fucking sandboxes with their ancient fucking JS versions.
|
||||||
for (var val in Iterator(params)) (function ([testName, commands]) {
|
for (var val in Iterator(params)) (function ([testName, commands]) {
|
||||||
@@ -362,12 +510,12 @@ for (var val in Iterator(tests)) (function ([command, params]) {
|
|||||||
case "singleOutput":
|
case "singleOutput":
|
||||||
runCommands(command, testName, commands, function (cmd) {
|
runCommands(command, testName, commands, function (cmd) {
|
||||||
dactyl.assertMessageLine(/./, "Expected command output: " + cmd);
|
dactyl.assertMessageLine(/./, "Expected command output: " + cmd);
|
||||||
});
|
}, true);
|
||||||
break;
|
break;
|
||||||
case "multiOutput":
|
case "multiOutput":
|
||||||
runCommands(command, testName, commands, function (cmd) {
|
runCommands(command, testName, commands, function (cmd) {
|
||||||
dactyl.assertMessageWindowOpen(true, "Expected command output: " + cmd);
|
dactyl.assertMessageWindowOpen(true, "Expected command output: " + cmd);
|
||||||
});
|
}, true && !params.errorsOk);
|
||||||
break;
|
break;
|
||||||
case "error":
|
case "error":
|
||||||
addTest(command, testName, function () {
|
addTest(command, testName, function () {
|
||||||
@@ -375,6 +523,7 @@ for (var val in Iterator(tests)) (function ([command, params]) {
|
|||||||
cmd = command + cmd.replace(/^(!?) ?/, "$1 ");
|
cmd = command + cmd.replace(/^(!?) ?/, "$1 ");
|
||||||
dactyl.assertMessageError(function () {
|
dactyl.assertMessageError(function () {
|
||||||
dactyl.runExCommand(cmd);
|
dactyl.runExCommand(cmd);
|
||||||
|
controller.waitForPageLoad(controller.tabs.activeTab);
|
||||||
}, null, [], cmd);
|
}, null, [], cmd);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@@ -382,7 +531,10 @@ for (var val in Iterator(tests)) (function ([command, params]) {
|
|||||||
case "completions":
|
case "completions":
|
||||||
addTest(command, testName, function () {
|
addTest(command, testName, function () {
|
||||||
commands.forEach(function (cmd) {
|
commands.forEach(function (cmd) {
|
||||||
|
dactyl.assertNoErrorMessages(function () {
|
||||||
dactyl.runExCompletion(command + cmd.replace(/^(!?) ?/, "$1 "));
|
dactyl.runExCompletion(command + cmd.replace(/^(!?) ?/, "$1 "));
|
||||||
|
controller.waitForPageLoad(controller.tabs.activeTab);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
@@ -390,7 +542,7 @@ for (var val in Iterator(tests)) (function ([command, params]) {
|
|||||||
})(val);
|
})(val);
|
||||||
|
|
||||||
if (params.cleanup)
|
if (params.cleanup)
|
||||||
runCommands(command, "cleanup", params.cleanup, function () {});
|
_runCommands(command, "cleanup", params.cleanup, function () {});
|
||||||
})(val);
|
})(val);
|
||||||
|
|
||||||
// vim: sw=4 ts=8 et:
|
// vim: sw=4 ts=8 et:
|
||||||
|
|||||||
Reference in New Issue
Block a user