Permalink
Browse files

Update to support latest Chromium version; workaround for flakey exec…

…ution context reporting
  • Loading branch information...
1 parent 526c58b commit 43b248a28e139d239989e467635cb4a2a75780b1 @jscheid committed Oct 5, 2012
Showing with 33 additions and 26 deletions.
  1. +15 −23 kite-console.el
  2. +17 −0 kite-util.el
  3. +1 −3 kite.el
View
@@ -692,14 +692,8 @@ FIXME: this should be consolidated with
insert the result or error message, along with a new prompt, into
the buffer."
(unless (kite--is-whitespace-or-comment input)
- (kite-send
- "Runtime.evaluate"
- :params
- (list :expression input
- :contextId (plist-get (kite-session-current-context
- kite-session)
- :id))
- :success-function
+ (kite--eval-in-current-context
+ input
(lambda (result)
(if (eq :json-false (plist-get result :wasThrown))
(comint-output-filter
@@ -762,13 +756,17 @@ console."
(interactive)
(let* ((contexts-by-unique-name
(kite--session-contexts-by-unique-name))
- (selection (completing-read "Context: "
- (mapcar (function car)
- contexts-by-unique-name)
- nil
- t
- nil
- 'kite-context-history))
+ (selection
+ (if contexts-by-unique-name
+ (completing-read "Context: "
+ (mapcar (function car)
+ contexts-by-unique-name)
+ nil
+ t
+ nil
+ 'kite-context-history)
+ (message "Only the default execution context is available")
+ nil))
(new-context (cdr (assoc selection
contexts-by-unique-name))))
(when new-context
@@ -842,14 +840,8 @@ FIXME: no error handling."
(lexical-let ((lex-js-regex js-regex)
(lex-callback callback))
- (kite-send
- "Runtime.evaluate"
- :params
- (list :expression object-expr
- :contextId (plist-get (kite-session-current-context
- kite-session)
- :id))
- :success-function
+ (kite--eval-in-current-context
+ object-expr
(lambda (result)
(lexical-let ((object-id (kite--get result
:result
View
@@ -266,6 +266,23 @@ ERROR-OBJECT-ID."
"\n")
"\n"))))))
+(defun kite--eval-in-current-context (input success-function)
+ "Evaluate INPUT in the remote remote debugger in the current
+execution context and asynchronously invoke SUCCESS-FUNCTION with
+the results in case of success."
+ (let ((eval-params (list :expression input))
+ (context-id (plist-get (kite-session-current-context
+ kite-session)
+ :id)))
+ (when context-id
+ (setq eval-params (plist-put eval-params :contextId context-id)))
+ (kite-send
+ "Runtime.evaluate"
+ :params
+ eval-params
+ :success-function
+ success-function)))
+
(defun kite--rgba (r g b a)
"Return the given RGBA color value in the WebKit remote
debugger API `RGBA' structure format."
View
@@ -273,14 +273,12 @@ and :title."
;; Enable subsystems
+ (kite-send "Runtime.enable")
(kite-send "Page.enable")
(kite-send "Inspector.enable")
(kite-send "Debugger.enable")
(kite-send "CSS.enable")
- (kite-send "Runtime.setReportExecutionContextCreation"
- :params '(:enabled t))
-
;; Get initial state
(kite--dom-initialize)

0 comments on commit 43b248a

Please sign in to comment.