[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/firefox-javascript-repl 563ae0984c 01/24: firefox-javas
From: |
Thomas Fitzsimmons |
Subject: |
[elpa] externals/firefox-javascript-repl 563ae0984c 01/24: firefox-javascript-repl: New package |
Date: |
Thu, 1 Jun 2023 00:41:51 -0400 (EDT) |
branch: externals/firefox-javascript-repl
commit 563ae0984c5a552af19eaac736c518194ff2c4cd
Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
Commit: Thomas Fitzsimmons <fitzsim@fitzsim.org>
firefox-javascript-repl: New package
* firefox-javascript-repl.el: New file.
---
firefox-javascript-repl.el | 87 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 87 insertions(+)
diff --git a/firefox-javascript-repl.el b/firefox-javascript-repl.el
new file mode 100644
index 0000000000..2e1311bcf4
--- /dev/null
+++ b/firefox-javascript-repl.el
@@ -0,0 +1,87 @@
+;;; firefox-javascript-repl.el --- Jack into Firefox -*- lexical-binding: t -*-
+
+;; Copyright (C) 2023 Free Software Foundation, Inc.
+
+;; Author: Thomas Fitzsimmons <fitzsim@fitzsim.org>
+;; Version: 1.0.0
+
+;; This program is free software; you can redistribute it and/or modify
+;; it under the terms of the GNU General Public License as published by
+;; the Free Software Foundation, either version 3 of the License, or
+;; (at your option) any later version.
+
+;; This program is distributed in the hope that it will be useful,
+;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+;; GNU General Public License for more details.
+
+;; You should have received a copy of the GNU General Public License
+;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+;;; Commentary:
+
+;; REPL into a new Firefox instance's JavaScript engine.
+
+;; Installation:
+
+;; M-x package-install RET firefox-javascript-repl RET
+
+;; Usage:
+
+;; M-x firefox-javascript-repl RET
+
+;;; Code:
+(defcustom firefox-javascript-repl-binary "firefox"
+ "The name or full path of the firefox binary to run."
+ :group 'external
+ :type 'string)
+
+(defun firefox-javascript-repl--create-profile-directory ()
+ "Create a profile directory."
+ (let ((profile-directory (make-temp-file "firefox-javascript-repl-" t)))
+ (with-current-buffer
+ (find-file-noselect (expand-file-name "user.js" profile-directory))
+ (insert "user_pref(\"devtools.debugger.remote-enabled\", true);\n")
+ (insert "user_pref(\"devtools.chrome.enabled\", true);\n")
+ (insert "user_pref(\"devtools.debugger.prompt-connection\", false);\n")
+ (save-buffer 0))
+ profile-directory))
+
+(defun firefox-javascript-repl ()
+ "Run a new instance of Firefox in a new profile.
+Set about:config values `devtools.debugger.remote-enabled' to
+true, `devtools.chrome.enabled' to true,
+`devtools.debugger.prompt-connection' to false, and pass
+`-start-debugger-server'. Firefox will listen on
+localhost (127.0.0.1) TCP port 6000."
+ (interactive)
+ (when (not (process-status "firefox-javascript-repl"))
+ (let* ((profile-directory
+ (firefox-javascript-repl--create-profile-directory))
+ (process-name (file-name-nondirectory profile-directory))
+ (firefox-process
+ (start-process "firefox-javascript-repl"
+ process-name
+ firefox-javascript-repl-binary
+ "about:blank"
+ "-profile" profile-directory
+ "-start-debugger-server")))
+ (set-process-sentinel firefox-process
+ (lambda (process event)
+ (message "%S %S" process event)
+ (when (or (string= event "killed\n")
+ (string= event "finished\n"))
+ (message
+ "firefox-javascript-repl: %s %s; deleting %s"
+ process (string-trim event) profile-directory)
+ (delete-directory profile-directory t))))
+ nil)))
+
+(defun firefox-javascript-repl-stop ()
+ "Stop the Firefox process started by `firefox-javascript-repl'."
+ (interactive)
+ (kill-process "firefox-javascript-repl"))
+
+(provide 'firefox-javascript-repl)
+
+;;; firefox-javascript-repl.el ends here
- [elpa] externals/firefox-javascript-repl 075bd87281 15/24: Adjust commentary wording, (continued)
- [elpa] externals/firefox-javascript-repl 075bd87281 15/24: Adjust commentary wording, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 2016b0eafa 22/24: Make firefox-javascript-repl--mode private, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl c2a0f7f44a 04/24: Get basic REPL working, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl f0ed5fbf81 03/24: Get ready for asynchronous JavaScript evaluation, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 77c9907e3e 18/24: Move usage to start of commentary, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 1e0638d411 17/24: Mention throwaway profile in commentary, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 7b288e2dba 24/24: Bump version to 0.9.0, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 7bed24ae8e 23/24: Ignore errors when showing quirk, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl b0695f591d 02/24: Complete actor retrieval, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 3d5c11b468 05/24: Add .gitignore file, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 563ae0984c 01/24: firefox-javascript-repl: New package,
Thomas Fitzsimmons <=
- [elpa] externals/firefox-javascript-repl 9644f919dd 06/24: Fix string quoting, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 5c47a29fd8 09/24: Remove newlines before sending JavaScript, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl b4186a5762 12/24: Backport to Emacs 26.1, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 876dcb4615 13/24: Add Package-Requires, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl aaefd1f8f4 14/24: Add jss URL to commentary, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl c35e324539 16/24: Refer to Firefox Debugging Remote Protocol, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 76ba08cb86 19/24: Trim some messages, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 9208c234cb 20/24: Fix kill-buffer-hook for Emacs 26.1, Thomas Fitzsimmons, 2023/06/01
- [elpa] externals/firefox-javascript-repl 976f04d340 21/24: Pass process object to kill-process, Thomas Fitzsimmons, 2023/06/01