From 89a798b26f3f60ec862f1f7e59c9d8d5cdb5ed5f Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 31 Aug 2023 11:31:38 -0400 Subject: [PATCH 1/5] Revert "Switch back to @mozilla.org/browser/clh;1 and fix tests" This reverts commit 722287b81a5db3af6c8de5c22ac72ae633e9ef18. --- test/components/zotero-unit.js | 19 +++++-------------- test/content/runtests.html | 1 - test/runtests.sh | 2 +- 3 files changed, 6 insertions(+), 16 deletions(-) diff --git a/test/components/zotero-unit.js b/test/components/zotero-unit.js index fa262f884d..354f1ae250 100644 --- a/test/components/zotero-unit.js +++ b/test/components/zotero-unit.js @@ -24,7 +24,6 @@ ***** 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; @@ -32,8 +31,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; @@ -42,27 +41,19 @@ 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]); diff --git a/test/content/runtests.html b/test/content/runtests.html index 44dbdfcdd0..054d7200eb 100644 --- a/test/content/runtests.html +++ b/test/content/runtests.html @@ -1,4 +1,3 @@ - diff --git a/test/runtests.sh b/test/runtests.sh index d83914a3ba..7005f5817f 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -168,7 +168,7 @@ ZOTERO_TEST=1 "$ROOT_DIR/app/scripts/dir_build" -q makePath FX_PROFILE "$PROFILE" MOZ_NO_REMOTE=1 NO_EM_RESTART=1 "$Z_EXECUTABLE" -profile "$FX_PROFILE" \ - -test "$TESTS" -grep "$GREP" -ZoteroTest $Z_ARGS + -chrome chrome://zotero-unit/content/runtests.html -test "$TESTS" -grep "$GREP" -ZoteroTest $Z_ARGS # Check for success test -e "$PROFILE/success" From 097869a2301c2133d685b08f498c84d9522b5b14 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Thu, 31 Aug 2023 11:42:30 -0400 Subject: [PATCH 2/5] Add Browser Toolbox to Developer submenu --- chrome/content/zotero/standalone/standalone.js | 9 +++++++++ chrome/content/zotero/zoteroPane.xhtml | 1 + 2 files changed, 10 insertions(+) diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js index dd47ac7ff4..ec1a2daf73 100644 --- a/chrome/content/zotero/standalone/standalone.js +++ b/chrome/content/zotero/standalone/standalone.js @@ -961,6 +961,15 @@ function toJavaScriptConsole() { BrowserConsoleManager.openBrowserConsoleOrFocus(); } +function launchBrowserToolbox() { + const { BrowserToolboxLauncher } = ChromeUtils.import("resource://devtools/client/framework/browser-toolbox/Launcher.jsm"); + // Don't launch if already open + // (Can we focus the existing toolbox process?) + if (!BrowserToolboxLauncher.getBrowserToolboxSessionState()) { + BrowserToolboxLauncher.init(); + } +} + function openRunJSWindow() { openWindowByType( 'chrome://zotero/content/runJS.html', diff --git a/chrome/content/zotero/zoteroPane.xhtml b/chrome/content/zotero/zoteroPane.xhtml index 88fe29685f..232958adb7 100644 --- a/chrome/content/zotero/zoteroPane.xhtml +++ b/chrome/content/zotero/zoteroPane.xhtml @@ -684,6 +684,7 @@ label="&developer.label;"> + From 7ee3c424fcf3724cd7c6a408c964998f2d462046 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Fri, 1 Sep 2023 11:23:30 -0400 Subject: [PATCH 3/5] Browser Toolbox -> Developer Toolbox --- chrome/content/zotero/standalone/standalone.js | 2 +- chrome/content/zotero/zoteroPane.xhtml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js index ec1a2daf73..0d3677e356 100644 --- a/chrome/content/zotero/standalone/standalone.js +++ b/chrome/content/zotero/standalone/standalone.js @@ -961,7 +961,7 @@ function toJavaScriptConsole() { BrowserConsoleManager.openBrowserConsoleOrFocus(); } -function launchBrowserToolbox() { +function launchDeveloperToolbox() { const { BrowserToolboxLauncher } = ChromeUtils.import("resource://devtools/client/framework/browser-toolbox/Launcher.jsm"); // Don't launch if already open // (Can we focus the existing toolbox process?) diff --git a/chrome/content/zotero/zoteroPane.xhtml b/chrome/content/zotero/zoteroPane.xhtml index 232958adb7..b36f99a90f 100644 --- a/chrome/content/zotero/zoteroPane.xhtml +++ b/chrome/content/zotero/zoteroPane.xhtml @@ -684,7 +684,7 @@ label="&developer.label;"> - + From 2e9d7db0e8f38e97960648dcdf0abaa81c3bb03f Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Tue, 31 Oct 2023 11:28:50 -0400 Subject: [PATCH 4/5] Prompt to enable remote debugging if disabled --- .../content/zotero/standalone/standalone.js | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/chrome/content/zotero/standalone/standalone.js b/chrome/content/zotero/standalone/standalone.js index 0d3677e356..0fa63c7207 100644 --- a/chrome/content/zotero/standalone/standalone.js +++ b/chrome/content/zotero/standalone/standalone.js @@ -962,6 +962,26 @@ function toJavaScriptConsole() { } function launchDeveloperToolbox() { + let prefs = ['devtools.chrome.enabled', 'devtools.debugger.remote-enabled']; + let enabled = prefs.every(pref => !!Zotero.Prefs.get(pref, true)); + if (!enabled) { + let ps = Services.prompt; + let shouldEnable = ps.confirm( + null, + 'Remote Debugging Disabled', + 'Enable remote debugging? This will allow Firefox instances on this machine to control ' + Zotero.appName + '.' + + '\n\nThis is inherently a security risk and is NOT RECOMMENDED for normal use.' + ); + if (shouldEnable) { + for (let pref of prefs) { + Zotero.Prefs.set(pref, true, /* global */ true); + } + } + else { + return; + } + } + const { BrowserToolboxLauncher } = ChromeUtils.import("resource://devtools/client/framework/browser-toolbox/Launcher.jsm"); // Don't launch if already open // (Can we focus the existing toolbox process?) From da69bb246b0de186d016a72db859050e8e52a1ef Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Mon, 1 Apr 2024 11:37:38 -0400 Subject: [PATCH 5/5] Revert test runner changes --- test/components/zotero-unit.js | 19 ++++++++++++++----- test/content/runtests.html | 1 + test/runtests.sh | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/test/components/zotero-unit.js b/test/components/zotero-unit.js index 354f1ae250..fa262f884d 100644 --- a/test/components/zotero-unit.js +++ b/test/components/zotero-unit.js @@ -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]); diff --git a/test/content/runtests.html b/test/content/runtests.html index 054d7200eb..44dbdfcdd0 100644 --- a/test/content/runtests.html +++ b/test/content/runtests.html @@ -1,3 +1,4 @@ + diff --git a/test/runtests.sh b/test/runtests.sh index 7005f5817f..d83914a3ba 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -168,7 +168,7 @@ ZOTERO_TEST=1 "$ROOT_DIR/app/scripts/dir_build" -q makePath FX_PROFILE "$PROFILE" MOZ_NO_REMOTE=1 NO_EM_RESTART=1 "$Z_EXECUTABLE" -profile "$FX_PROFILE" \ - -chrome chrome://zotero-unit/content/runtests.html -test "$TESTS" -grep "$GREP" -ZoteroTest $Z_ARGS + -test "$TESTS" -grep "$GREP" -ZoteroTest $Z_ARGS # Check for success test -e "$PROFILE/success"