Switch back to @mozilla.org/browser/clh;1 and fix tests

In Firefox 102, `-file` was being swallowed by `nsBrowserContentHandler`
in BrowserContentHandler.jsm, so ab7d916e0 overrode that by using the
same contract id for our main nsICommandLineHandler in
zotero-service.js. But `nsBrowserContentHandler` also handles `-chrome`,
which we were using in tests to pass runtests.html. There's no need to
pass in dynamically though -- we can just hard-code that and open the
window ourselves.
This commit is contained in:
Dan Stillman 2023-05-24 06:50:34 -04:00
parent 744e73bfdb
commit 722287b81a
6 changed files with 21 additions and 11 deletions

View file

@ -24,6 +24,7 @@
***** END LICENSE BLOCK *****
*/
Components.utils.import("resource://gre/modules/ComponentUtils.jsm");
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm");
function ZoteroUnit() {
this.wrappedJSObject = this;
@ -31,8 +32,8 @@ function ZoteroUnit() {
ZoteroUnit.prototype = {
/* nsICommandLineHandler */
handle:function(cmdLine) {
this.tests = cmdLine.handleFlagWithParam("test", false);
this.noquit = cmdLine.handleFlag("noquit", false);
this.tests = cmdLine.handleFlagWithParam("test", false);
this.noquit = cmdLine.handleFlag("noquit", false);
this.makeTestData = cmdLine.handleFlag("makeTestData", false);
this.noquit = !this.makeTestData && this.noquit;
this.runTests = !this.makeTestData;
@ -41,19 +42,27 @@ ZoteroUnit.prototype = {
this.stopAt = cmdLine.handleFlagWithParam("stopAtTestFile", false);
this.grep = cmdLine.handleFlagWithParam("grep", false);
this.timeout = cmdLine.handleFlagWithParam("ZoteroTestTimeout", false);
if (this.tests) {
Services.ww.openWindow(
null,
"chrome://zotero-unit/content/runtests.html",
"_blank",
"chrome,dialog=no,all",
Cc["@mozilla.org/array;1"].createInstance(Ci.nsIMutableArray)
);
cmdLine.preventDefault = true;
}
},
dump:function(x) {
dump(x);
},
contractID: "@mozilla.org/commandlinehandler/general-startup;1?type=zotero-unit",
classDescription: "Zotero Unit Command Line Handler",
classID: Components.ID("{b8570031-be5e-46e8-9785-38cd50a5d911}"),
service: true,
_xpcom_categories: [{category:"command-line-handler", entry:"m-zotero-unit"}],
QueryInterface: ChromeUtils.generateQI([Components.interfaces.nsICommandLineHandler])
};
var NSGetFactory = ComponentUtils.generateNSGetFactory([ZoteroUnit]);