aboutsummaryrefslogtreecommitdiffstats
path: root/src/devtools-protocol.lisp
diff options
context:
space:
mode:
authorTeddy Wing2021-02-27 19:12:07 +0100
committerTeddy Wing2021-02-27 19:12:07 +0100
commit4792097ca56f278344f18a0a78aaca1278fd146e (patch)
tree8c48974c3a68b955df597a7a5eaa8b7a3afdefa6 /src/devtools-protocol.lisp
parent5e0f58d30c08bd294539ede86757970d46cab4f6 (diff)
downloadextreload-4792097ca56f278344f18a0a78aaca1278fd146e.tar.bz2
Move everything from `l/` into the project root
This is the final project. Now that we got rid of the web extension and native host code, we can move the Lisp code to the root.
Diffstat (limited to 'src/devtools-protocol.lisp')
-rw-r--r--src/devtools-protocol.lisp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/devtools-protocol.lisp b/src/devtools-protocol.lisp
new file mode 100644
index 0000000..2d67033
--- /dev/null
+++ b/src/devtools-protocol.lisp
@@ -0,0 +1,45 @@
+;;;; DevTools Protocol messages.
+
+(in-package :extreload)
+
+(defun target-get-targets-msg (call-id)
+ "DevTools Protocol `Target.getTargets` message."
+ (jsown:to-json
+ `(:obj ("id" . ,call-id)
+ ("method" . "Target.getTargets"))))
+
+(defun target-attach-to-target-msg (call-id target-id)
+ "DevTools Protocol `Target.attachToTarget` message."
+ (jsown:to-json
+ `(:obj ("id" . ,call-id)
+ ("method" . "Target.attachToTarget")
+ ("params" . (:obj ("targetId" . ,target-id)
+ ("flatten" . t))))))
+
+(defun target-attached-to-target-msg-p (message)
+ "Returns true if `message` is `Target.attachedToTarget`."
+ (equal
+ (json-obj-get message "method")
+ "Target.attachedToTarget"))
+
+(defun runtime-evaluate-msg (call-id session-id expression)
+ "DevTools Protocol `Runtime.evaluate` message."
+ (jsown:to-json
+ `(:obj ("id" . ,call-id)
+ ("sessionId" . ,session-id)
+ ("method" . "Runtime.evaluate")
+ ("params" . (:obj ("expression" . ,expression))))))
+
+(defun runtime-evaluate-msg-p (message)
+ "Returns true if `message` is a response to `Runtime.evaluate`."
+ (jsown:keyp (json-obj-get message "result") "sessionId"))
+
+(defun runtime-evaluate-exception-p (message)
+ "Returns true if `message` describes a runtime exception"
+ (jsown:keyp (json-obj-get message "result") "exceptionDetails"))
+
+(defun parse-get-targets-response (response)
+ "Parses a list of target info objects from the response to `Target.getTargets`."
+ (let* ((result (json-obj-get response "result"))
+ (targetInfos (json-obj-get result "targetInfos")))
+ targetInfos))