Skip to content

Commit

Permalink
Disable cache (#48)
Browse files Browse the repository at this point in the history
* Add indium-webkit-{enable|disable}-cache (see #34).
* Add a new documentation page about the network.
  • Loading branch information
TatriX authored and NicolasPetton committed May 12, 2017
1 parent aeca678 commit 48ab791
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 14 deletions.
48 changes: 37 additions & 11 deletions doc/Indium.texi
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ Table of contents
* Interaction in JS buffers::
* The stepping debugger::
* The inspector::
* Network::
Installation
Expand Down Expand Up @@ -149,6 +150,7 @@ The inspector
* Interaction in JS buffers::
* The stepping debugger::
* The inspector::
* Network::
@end menu

Expand Down Expand Up @@ -220,7 +222,7 @@ Add the following to your Emacs configuration:
@end example

@node Getting up and running,The REPL,Installation,Table of contents
@anchor{setup doc}@anchor{7}@anchor{setup up-and-running}@anchor{8}@anchor{setup getting-up-and-running}@anchor{9}
@anchor{setup doc}@anchor{7}@anchor{setup getting-up-and-running}@anchor{8}@anchor{setup up-and-running}@anchor{9}
@section Getting up and running


Expand All @@ -232,7 +234,7 @@ Add the following to your Emacs configuration:
@end menu

@node NodeJS,Chrome/Chromium,,Getting up and running
@anchor{setup nodejs}@anchor{a}@anchor{setup id1}@anchor{b}
@anchor{setup id1}@anchor{a}@anchor{setup nodejs}@anchor{b}
@subsection NodeJS


Expand Down Expand Up @@ -263,7 +265,7 @@ Connecting Indium to the node process will open a debugger on the first line of
the application code if you passed the CLI argument @code{--debug-brk}.

@node Chrome/Chromium,Using local files when debugging,NodeJS,Getting up and running
@anchor{setup chrome}@anchor{c}@anchor{setup chrome-chromium}@anchor{d}
@anchor{setup chrome-chromium}@anchor{c}@anchor{setup chrome}@anchor{d}
@subsection Chrome/Chromium


Expand Down Expand Up @@ -337,7 +339,7 @@ directory!
@end cartouche

@node The REPL,Interaction in JS buffers,Getting up and running,Table of contents
@anchor{repl the-repl}@anchor{10}@anchor{repl doc}@anchor{11}@anchor{repl repl}@anchor{12}
@anchor{repl repl}@anchor{10}@anchor{repl doc}@anchor{11}@anchor{repl the-repl}@anchor{12}
@section The REPL


Expand All @@ -354,7 +356,7 @@ directory!


A REPL (Read Eval Print Loop) buffer is automatically open when a new Indium
connection is made (see @ref{8,,Getting up and running}).
connection is made (see @ref{9,,Getting up and running}).

@image{repl,,,,png}

Expand Down Expand Up @@ -488,7 +490,7 @@ the current stack frame, and will be able to access local variables from the
stack, etc.

@node Interaction in JS buffers,The stepping debugger,The REPL,Table of contents
@anchor{code-evaluation doc}@anchor{19}@anchor{code-evaluation interaction}@anchor{1a}@anchor{code-evaluation interaction-in-js-buffers}@anchor{1b}
@anchor{code-evaluation interaction-in-js-buffers}@anchor{19}@anchor{code-evaluation interaction}@anchor{1a}@anchor{code-evaluation doc}@anchor{1b}
@section Interaction in JS buffers


Expand Down Expand Up @@ -542,7 +544,7 @@ Here's a list of available keybindings:


Press @code{C-c C-z} from any buffer with @code{indium-interaction-mode} turned on to
switch back to the REPL buffer (see @ref{12,,The REPL}).
switch back to the REPL buffer (see @ref{10,,The REPL}).

@node Adding and removing breakpoints,Live code update hot-swapping JavaScript sources,Switching to the REPL buffer,Interaction in JS buffers
@anchor{code-evaluation adding-and-removing-breakpoints}@anchor{1e}
Expand Down Expand Up @@ -634,17 +636,17 @@ window.addEventListener("patch", (event) => @{
@end example

@node The stepping debugger,The inspector,Interaction in JS buffers,Table of contents
@anchor{debugger the-stepping-debugger}@anchor{21}@anchor{debugger doc}@anchor{22}@anchor{debugger debugger}@anchor{1f}
@anchor{debugger debugger}@anchor{1f}@anchor{debugger the-stepping-debugger}@anchor{21}@anchor{debugger doc}@anchor{22}
@section The stepping debugger


@node The inspector,,The stepping debugger,Table of contents
@node The inspector,Network,The stepping debugger,Table of contents
@anchor{inspector inspector}@anchor{14}@anchor{inspector doc}@anchor{23}@anchor{inspector the-inspector}@anchor{24}
@section The inspector


Indium features an object inspector that can be open on any object reference
from a REPL buffer (see @ref{12,,The REPL}), the debugger (see @ref{1f,,The stepping debugger}), or
from a REPL buffer (see @ref{10,,The REPL}), the debugger (see @ref{1f,,The stepping debugger}), or
the result of any evaluation of JavaScript code (see @ref{1a,,Interaction in JS buffers}).

To inspect the result of the evaluation of an expression, press @code{C-c M-i}. An
Expand Down Expand Up @@ -718,8 +720,32 @@ Jump to the previous object in the inspector
@end multitable


@node Network,,The inspector,Table of contents
@anchor{network network}@anchor{26}@anchor{network id1}@anchor{27}@anchor{network doc}@anchor{28}
@section Network



@table @asis

@item You can disable or enable network cache using the following commands ::

M-x indium-webkit-disable-cache
M-x indium-webkit-enable-cache
@end table

Both commands save your choice which will be used for future Indium connections for the current Emacs session.


@table @asis

@item You can make it permament by setting ::

(setq indium-webkit-cache-disabled t)
@end table

@node Indices and tables,,Table of contents,Top
@anchor{index indices-and-tables}@anchor{26}
@anchor{index indices-and-tables}@anchor{29}
@chapter Indices and tables


Expand Down
26 changes: 24 additions & 2 deletions indium-webkit.el
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
(require 'indium-debugger)
(require 'indium-workspace)

(defvar indium-webkit-cache-disabled nil
"Network cache disabled state. If non-nil disable cache when Indium starts.")

(defvar indium-webkit-completion-function "function getCompletions(type)\n{var object;if(type==='string')\nobject=new String('');else if(type==='number')\nobject=new Number(0);else if(type==='boolean')\nobject=new Boolean(false);else\nobject=this;var resultSet={};for(var o=object;o;o=o.__proto__){try{if(type==='array'&&o===object&&ArrayBuffer.isView(o)&&o.length>9999)\ncontinue;var names=Object.getOwnPropertyNames(o);for(var i=0;i<names.length;++i)\nresultSet[names[i]]=true;}catch(e){}}\nreturn resultSet;}")

Expand Down Expand Up @@ -227,7 +229,24 @@ Allowed states: `\"none\"', `\"uncaught\"', `\"all\"'."
nil
t)))
(indium-webkit--send-request `((method . "Debugger.setPauseOnExceptions")
(params . ((state . ,state))))))
(params . ((state . ,state))))))

(defun indium-webkit--set-cache-disabled (disabled)
"Toggle ignoring cache for each request. If DISABLED, cache will not be used."
(indium-webkit--send-request `((method . "Network.setCacheDisabled")
(params . ((cacheDisabled . ,(if disabled t :json-false)))))))

(defun indium-webkit-enable-cache ()
"Enabled network cache for each request."
(interactive)
(setq indium-webkit-cache-disabled nil)
(indium-webkit--set-cache-disabled nil))

(defun indium-webkit-disable-cache ()
"Disable network cache for each request."
(interactive)
(setq indium-webkit-cache-disabled t)
(indium-webkit--set-cache-disabled t))

(defun indium-webkit--open-ws-connection (url websocket-url &optional on-open)
"Open a websocket connection to URL using WEBSOCKET-URL.
Expand Down Expand Up @@ -376,7 +395,10 @@ inspectors."

(defun indium-webkit--enable-network ()
"Enable the runtime on the current tab."
(indium-webkit--send-request '((method . "Network.enable"))))
(indium-webkit--send-request '((method . "Network.enable"))
(lambda (res)
(when indium-webkit-cache-disabled
(indium-webkit--set-cache-disabled t)))))

(defun indium-webkit--enable-debugger ()
"Enable the debugger on the current tab."
Expand Down
3 changes: 2 additions & 1 deletion sphinx-doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ Table of contents
code-evaluation
debugger
inspector

network

Indices and tables
------------------

Expand Down
12 changes: 12 additions & 0 deletions sphinx-doc/network.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
.. _network:

Network
=====================
You can disable or enable network cache using the following commands ::
M-x indium-webkit-disable-cache
M-x indium-webkit-enable-cache

Both commands save your choice which will be used for future Indium connections for the current Emacs session.

You can make it permament by setting ::
(setq indium-webkit-cache-disabled t)

0 comments on commit 48ab791

Please sign in to comment.