PageRenderTime 60ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/kite.md

https://github.com/thomasf/kite
Markdown | 428 lines | 313 code | 115 blank | 0 comment | 0 complexity | 849b0455485245d005cac36520adc2bf MD5 | raw file
Possible License(s): GPL-3.0
  1. % _Kite_ - WebKit Remote Debugger Front-end
  2. % Julian Scheid
  3. % 2012-08-30
  4. <!--
  5. kite.md -- User manual for Kite, a WebKit inspector front-end
  6. Copyright (C) 2012 Julian Scheid
  7. This file is formatted in pandoc-flavoured Markdown. Use the
  8. accompanying Makefile to translate into Info or HTML formats.
  9. This file is not part of GNU Emacs.
  10. Kite is free software: you can redistribute it and/or modify it
  11. under the terms of the GNU General Public License as published by
  12. the Free Software Foundation, either version 3 of the License, or
  13. (at your option) any later version.
  14. Kite is distributed in the hope that it will be useful, but WITHOUT
  15. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  16. or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
  17. License for more details.
  18. You should have received a copy of the GNU General Public License
  19. along with Kite. If not, see <http://www.gnu.org/licenses/>.
  20. -->
  21. _Kite_ is an Emacs front-end for the WebKit debugger. It enables
  22. inspecting, debugging, and live-editing Web pages and associated
  23. resources, such as scripts and stylesheets.
  24. # License
  25. Kite is free software: you can redistribute it and/or modify it under
  26. the terms of the GNU General Public License as published by the Free
  27. Software Foundation, either version 3 of the License, or (at your
  28. option) any later version.
  29. Kite is distributed in the hope that it will be useful, but WITHOUT
  30. ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  31. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  32. for more details.
  33. You should have received a copy of the GNU General Public License
  34. along with Kite. If not, see <http://www.gnu.org/licenses/>.
  35. # Installation
  36. ## Compatibility
  37. Kite is known to be compatible with Emacs version 24.1. There are
  38. currently no plans for compatibility with older releases.
  39. ## Automatic Installation
  40. **NOTE**: _Kite_ has not yet been uploaded to any package
  41. repository so these instructions do not apply.
  42. _Kite_ comes as a package conforming to Tromey's _package.el_. Ensure
  43. that an archive containing Kite is listed in `package-archives` and
  44. execute `M-x package-install RET kite RET`.
  45. ## Manual Installation
  46. Ensure that all kite source files as well as
  47. [json.el](http://edward.oconnor.cx/2006/03/json.el) and a recent
  48. version of [websocket.el](https://github.com/ahyatt/emacs-websocket)
  49. are on `load-path` and add `(require 'kite)` to your `.emacs` file.
  50. # Starting the Host Browser
  51. Kite currently only supports the WebKit Remote Debugging API and thus
  52. won't work with browsers not based on WebKit, such as Firefox or
  53. Opera. Support for other remote debugging interfaces may be added in
  54. the future.
  55. Many WebKit-based browsers do not yet expose the remote debugging
  56. interface and thus can't be used with Kite. At the time of this
  57. writing, the only browsers supported are recent versions of Chromium,
  58. Google Chrome, and Mobile Safari.
  59. We are working on adding a remote debugging interface to WebKitGTK+.
  60. This will enable debugging of WebKit instances embedded via the Emacs
  61. [xwidgets branch](http://emacswiki.org/emacs/EmacsXWidgets).
  62. ## Enabling Remote Debugging on Chromium and Google Chrome
  63. You can enable remote debugging for Chromium and Google Chrome by
  64. passing the `--remote-debugging-port=<port>` command line option.
  65. You may have to use the Google Chrome beta or development channel for
  66. this to work.
  67. The recommended default port is 9222. Thus, to start Google Chrome
  68. with the default port on Mac OS X, you would execute the following
  69. command:
  70. ~~~~
  71. open /Applications/Google\ Chrome.app --args --remote-debugging-port=9222
  72. ~~~~
  73. For more information, see here:
  74. <https://developers.google.com/chrome-developer-tools/docs/remote-debugging#remote>
  75. ## Enabling Remote Debugging on Mobile Safari
  76. Remote debugging a Mobile Safari instance has not yet been tested by
  77. us. If you want to give it a try, follow the instructions here:
  78. <http://atnan.com/blog/2011/11/17/enabling-remote-debugging-via-private-apis-in-mobile-safari/>
  79. # Kite Sessions
  80. Kite's most fundamental concept is that of a _debugging session_,
  81. which corresponds to an open connection to the remote debugging API
  82. for one specific open browser tab. Kite supports multiple
  83. simultaneous debugging sessions, but usually you will only have a
  84. single session active.
  85. A single WebKit tab can currently only be connected to one debugger,
  86. so if you are using the default WebKit debugging front-end you won't
  87. be able to use Kite, and vice versa.
  88. ## Kite Buffers Overview
  89. Kite provides a number of special buffers (major modes), each of which
  90. allows for interaction with one aspect of a debugging session.
  91. Accessing a Kite buffer when there is no debugging session active yet
  92. will prompt you to establish a new one. See instructions on
  93. [establishing a debugging session](#establishing-a-debugging-session).
  94. You can access Kite buffers using global key bindings or with an `M-x`
  95. incantation. The following buffers are available:
  96. Key Binding Incantation Description
  97. -------------- ------------------- ---------------------------------------
  98. `C-c C-k c` `kite-console` View console messages
  99. `C-c C-k d` `kite-debugger` View and manage breakpoints
  100. `C-c C-k h` `kite-heap` Analyze heap usage
  101. `C-c C-k s` `kite-scratch` Evaluate JavaScript code in page context
  102. `C-c C-k m` `kite-dom` Inspect and manipulate the DOM
  103. `C-c C-k n` `kite-network` Analyze HTTP requests and responses
  104. <!-- NOT YET IMPLEMENTED
  105. `C-c C-k r` `kite-resources` Access resources, such as images
  106. `C-c C-k t` `kite-timeline` View page-global events
  107. `C-c C-k p j` `kite-profile-js` Profile JavaScript performance
  108. `C-c C-k p c` `kite-profile-css` Profile CSS selector performance
  109. `C-c C-k p h` `kite-profile-heap` Profile Heap usage
  110. -->
  111. There are also secondary buffer types for inspection of JavaScript
  112. objects, stack frames, messages, per-DOM element CSS properties, and
  113. more. How such buffers are accessed depends on context, but is
  114. usually achieved by moving the point onto the textual representation
  115. of an entity and hitting `RET`.
  116. ## Establishing a Debugging Session
  117. When you access a Kite buffer and there is no debugging session active
  118. yet, an attempt will be made to establish a connection to a WebKit
  119. remote debugger interface on `kite-default-remote-host` (default:
  120. `127.0.0.1`) and `kite-default-remote-port` (default: 9222).
  121. If the connection succeeds you will be presented with a prompt that
  122. allows you to choose which of the pages currently open in the WebKit
  123. instance you want to debug. You can enter either the page URL or its
  124. title, and there are completions available for both.
  125. In case that the same page is open multiple times in the WebKit
  126. instance, the individual instances of the page are disambiguated using
  127. a numeric suffix derived from an internal WebKit identifier.
  128. Unfortunately, there is currently no easy way to know which suffix
  129. corresponds to which WebKit tab. However, pages opened later in time
  130. usually have higher suffix numbers.
  131. ## Remote Sessions and Multiple Debugging Sessions
  132. In some situations you might want to debug more than one page
  133. simultaneously. Use a prefix argument of `(4)` (the default when you
  134. use the `C-u` modifier key) for any of the Kite buffer commands and
  135. Kite will prompt you for a new session rather than using the existing
  136. one.
  137. You might also want to connect to a remote WebKit instance, i.e. one
  138. not running on `kite-default-remote-host` or `kite-default-remote-port`.
  139. By giving a prefix argument of `(16)` (by using the `C-u` modifier key
  140. twice) you'll force Kite to ask you for the host and port to connect
  141. to.
  142. ## Navigating Kite Buffers with Multiple Sessions
  143. If you have multiple debugging sessions active, Kite will normally
  144. attempt to keep you within the current session. For example, if you
  145. have two session active and you are currently visiting the *kite
  146. console* buffer for the first session, then doing `M-x kite-scratch`
  147. will take you to the scratch buffer for the first session.
  148. If you want to switch to a Kite buffer for a different session, there
  149. are three ways of doing so.
  150. Firstly, you can simply use the mechanics afforded by `M-x
  151. switch-to-buffer` et.al.: when multiple sessions are active, Kite
  152. buffer names carry a suffix derived from the (possibly disambiguated)
  153. page title.
  154. Secondly, by using the Kite command to switch to a buffer while
  155. visiting a buffer of the same type, Kite will cycle through the
  156. buffers for all open debugging sessions. For example, if you are
  157. currently visiting the `*kite console*` buffer for the first session,
  158. then doing `M-x kite-console` will take you to the `*kite console*`
  159. buffer for the second session.
  160. Finally, you can use a numeric prefix with the buffer access commands
  161. and Kite will take you straight to the buffer for the corresponding
  162. session, where the first session you opened is numbered 1, the second
  163. session 2, and so on. For example, `M-2 C-c C-k c` will take you to
  164. the console buffer for the second session. Note that numeric session
  165. designators will change as you close debugging sessions. Use the
  166. `Kite Session List` if you ever lose track.
  167. <!-- NOT YET IMPLEMENTED
  168. ## Managing Kite Sessions
  169. Use `M-x kite-sessions` or `C-c C-k s` to access the Kite session list
  170. buffer. Here you can get an overview of which debugging sessions are
  171. active and which numeric designator is assigned to them. You can also
  172. use the following key bindings to manage sessions:
  173. Key Action
  174. ----- ---------------------------------------------------------------
  175. `g` Refresh the session list
  176. `q` Bury the session list
  177. `z` Kill the session list only, leaving all session intact
  178. `DEL` Kill the session under point and all its buffers
  179. `c` Visit the console buffer for the session under point
  180. `d` Visit the session's debugger buffer
  181. `r` Visit the session's resources buffer
  182. `n` Visit the session's network buffer
  183. `h` Visit the session's heap analysis buffer
  184. `t` Visit the session's timeline buffer
  185. `p j` Visit the session's javascript profiler buffer
  186. `p c` Visit the session's CSS profiler buffer
  187. `p h` Visit the session's heap profiler buffer
  188. As with the normal kite buffer access commands, each of these key
  189. bindings can be prefixed in order to create new sessions and to
  190. connect to remote WebKit instances.
  191. -->
  192. # Kite Buffers
  193. ## Console Buffer
  194. The console buffer shows any messages which scripts on the page have
  195. emitted using the
  196. [console](https://developer.mozilla.org/en/DOM/console) object.
  197. The console buffer can be opened using `M-x kite-console` or by typing
  198. `C-c C-k c` with default key bindings.
  199. ### Evaluating JavaScript code
  200. You can type JavaScript code at the prompt and hit `RET` or `C-j` to
  201. send it to the remote debugger. The result of the evaluation or the
  202. stack trace (in case of error) will be displayed. The prompt supports
  203. basic identifier completion via the `TAB` key.
  204. ### Special Items in Messages
  205. Some parts of console messages have special key bindings:
  206. Object representations are rendered with `kite-object-face` and show
  207. an abbreviated representation of a JavaScript object. Typing `RET`
  208. (`M-x kite-inspect`) with point over the object representation brings
  209. up an Object Inspector view for that object.
  210. DOM node representation are rendered with `kite-node-face` and show an
  211. abbreviated representation of a DOM node. Typing `RET` (`M-x
  212. kite-inspect`) with point over the DOM node representation brings up
  213. the corresponding DOM view and moves point to the beginning of the
  214. node in question.
  215. ### Message Details
  216. In the console view, type `C-c i` to bring up an detail view for the
  217. message under point (`kite-show-log-entry`). The detail view show all
  218. available information on the log message, some of which is elided from
  219. the console view for brevity's sake.
  220. ### Message Source
  221. In the console view, type `C-c g` to go to the source location at
  222. which the message at point was emitted. If point is on a stack trace,
  223. go to the source location for the stack frame at point.
  224. ### Tail Follow
  225. If point is at the end of the console view buffer when a new message
  226. arrives, it will be moved to the end again. In other words, if point
  227. is at the end of the buffer it will stay at the end of the buffer.
  228. This allows you to always see the most recent messages, but at the
  229. same time leaves point alone when you examine other parts of the
  230. buffer.
  231. ### Page Reloads
  232. When the browser page is reloaded (either via `kite-reload-page` or by
  233. any other means, such as using the browser UI or by JavaScript code),
  234. `kite-console-page-reloaded-function` is executed with the console
  235. buffer current and point at the end of the buffer. By default, this
  236. function only inserts a page break followed by a line feed. In other
  237. words, messages from previous incarnations of the page are not cleared
  238. by default.
  239. This default behaviour is useful because it gives convenient access to
  240. past messages. You can bind `kite-console-page-reloaded-function` to
  241. `erase-buffer` if you prefer the behaviour of the default Webkit
  242. Inspector Frontend, which clears past messages on page reload.
  243. <!-- NOT YET IMPLEMENTED
  244. ### Narrowing to Groups
  245. ### Collapsing Groups
  246. ### Filtering Levels
  247. ### Clearing Messages
  248. -->
  249. ## Debug Buffer
  250. The debug buffer shows any breakpoints currently set and allows to
  251. clear breakpoints. It also shows whether JavaScript execution is
  252. currently paused.
  253. Sorry, no further documentation available yet. Use `M-x
  254. describe-mode` in a _Kite Debug_ buffer to learn about available key
  255. bindings.
  256. **TODO**:
  257. * Overall, the JavaScript debugger is not very usable yet.
  258. * When a breakpoint is hit, Emacs shows the source file and jumps to
  259. the break location; however, it doesn't show the stack trace or any
  260. variable bindings.
  261. * There should be a way to tell Emacs which local file corresponds to
  262. a network resource, so that Emacs can open the local file for
  263. editing. [Source
  264. map](http://www.html5rocks.com/en/tutorials/developertools/sourcemaps/)
  265. support should also be implemented.
  266. * A number of basic debugger commands, such as "execute until here",
  267. are not yet implemented.
  268. ## Scratch Buffer
  269. Sorry, no documentation available yet. Use `M-x describe-mode` in a
  270. _Kite Scratch_ buffer to learn about available key bindings.
  271. **TODO**:
  272. * This mode is currently very experimental.
  273. ## Network Buffer
  274. Sorry, no documentation available yet. Use `M-x describe-mode` in a
  275. _Kite Network_ buffer to learn about available key bindings.
  276. **TODO**:
  277. * The Network inspector doesn't yet sorting the table by criteria
  278. other than resource load order.
  279. * The Network inspector doesn't provide access to request and response
  280. headers, cookies, etc.
  281. * The code for the Network inspector is pretty convoluted; it should
  282. be rewritten using CL structs so that the intermediate
  283. representation is less obtuse and can be more easily reused for
  284. alternate display representations.
  285. ## DOM Buffer
  286. Sorry, no documentation available yet. Use `M-x describe-mode` in a
  287. _Kite DOM_ buffer to learn about available key bindings.
  288. **TODO**:
  289. * The DOM inspector doesn't support DOM mutation yet: although local
  290. modification is partially implemented, changes can not yet be sent
  291. to the remote debugger.
  292. * Likewise, CSS mutation isn't only partially implemented.
  293. ## Heap Buffer
  294. Sorry, no documentation available yet. Use `M-x describe-mode` in a
  295. _Kite Heap_ buffer to learn about available key bindings.
  296. # Global Key Bindings
  297. In addition to the key bindings listed in section [Kite Buffers
  298. Overview](#kite-buffers-overview), the following keys are bound by
  299. default:
  300. Key Binding Incantation Description
  301. -------------- ------------------------- ---------------------------------------
  302. `C-c C-k !` `kite-reload-page` Reload the page; ignore cache with prefix
  303. <!-- NOT YET IMPLEMENTED
  304. `C-c C-k C-r` `kite-resume` Resume execution
  305. `C-c C-k C-e` `kite-eval-expr` Evaluate JavaScript code in page context
  306. `C-c C-k C-p` `kite-previous-error` Go to source for previous error
  307. `C-c C-k C-n` `kite-next-error` Go to source for next error
  308. `C-c C-k C-u` `kite-goto-url` Navigate to URL
  309. `C-c C-k C-x` `kite-clear-console` Clear console messages
  310. `C-c C-k C-r` `kite-toggle-paint-rects` Toggle showing paint rects
  311. `C-c C-k C-i` `kite-pick-dom-node` Pick a DOM node with mouse in browser
  312. `C-c C-k C-s` `kite-upload-buffer` Upload a modified resource to the remote debugger
  313. -->