Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8727)

Unified Diff: chrome/common/extensions/docs/static/experimental.devtools.inspectedWindow.html

Issue 8497027: This includes small updates to the inspectedWindow.html documentation. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/static/experimental.devtools.inspectedWindow.html
===================================================================
--- chrome/common/extensions/docs/static/experimental.devtools.inspectedWindow.html (revision 109075)
+++ chrome/common/extensions/docs/static/experimental.devtools.inspectedWindow.html (working copy)
@@ -2,35 +2,53 @@
>chrome.experimental.devtools.inspectedWindow.* APIs</div>
<p>
-Use <code>chrome.experimental.devtools.inspectedWindow</code> to interact with
-the inspected window: obtain tab ID for the inspected page, evaluate the code
-in the context of inspected window, reload the page.
+Use <code>chrome.experimental.devtools.inspectedWindow</code>
+to interact with the inspected window:
+obtain the tab ID for the inspected page,
+evaluate the code in the context of inspected window,
+reload the page,
+or obtain the list of resources within the page.
</p><p>
See <a href="experimental.devtools.html">DevTools APIs summary</a> for
general introduction to using Developer Tools APIs.
</p>
-<h2>Notes</h2>
+<h2>Overview</h2>
<p>
-The <a href="#property-tabId"><code>tabId</code></a> property
-provides tab identifier that may be used with the <a href="tabs.html">
-<code>chrome.tabs.*</code></a> API calls.
+The <a href="#property-tabId"><code>tabId</code></a> property
+provides the tab identifier that you can use with the
+<a href="tabs.html"><code>chrome.tabs.*</code></a> API calls.
However, please note that <code>chrome.tabs.*</code> API is not
exposed to the Developer Tools extension pages due to security considerations
&mdash; you will need to pass the tab ID to the background page and invoke
the <code>chrome.tabs.*</code> API functions from there.
-</p></p>
+</p>
+<p>
The <code>eval()</code> method provides the ability for extensions to execute
JavaScript code in the context of the main frame of the inspected page.
-This method is different from
-<code>chrome.tabs.executeScript()</code> in the following aspects:
+This method if powerful when used in the right context
+and dangerous when used inappropriately.
+Use the <code>chrome.tabs.executeScript()</code> method
+unless you need the specific functionality
+that the <code>eval()</code> method provides.
+</p>
+<p>Here are the main differences between the
+<code>eval()</code> and <code>chrome.tabs.executeScript()</code> methods:
</p><ul>
<li>The <code>eval()</code> method does not
use an isolated world for the code being evaluated, so the JavaScript state
of the inspected window is accessible to the code.
+Use this method when access to the JavaScript state of the inspected page
+is required.
</li><li>
+The execution context of the code being evaluated includes the
+<a href="http://code.google.com/chrome/devtools/docs/console.html">Developer
+Tools console API</a>.
+For example,
+the code can use <code>inspect()</code> and <code>$0</code>.
+</li><li>
The evaluated code may return a value that is passed to the extension callback.
-The returned value has to be a valid JSON object (i.e. may contain only
+The returned value has to be a valid JSON object (it may contain only
primitive JavaScript types and acyclic references to other JSON
objects).
@@ -38,12 +56,7 @@
inspected page &mdash; the execution context is essentially controlled by the
inspected page; a malicious page may affect the data being returned to the
extension.</em>
-</li><li>
-The execution context of the code being evaluated includes the
-<a href="http://code.google.com/chrome/devtools/docs/console.html">Developer
-Tools console API</a> (e.g. <code>inspect()</code>, <code>$0</code> etc).
-</li>
-</ul>
+</li></ul>
<p class="caution">
<strong>Important:</strong>
Due to the security considerations explained above, the
@@ -62,7 +75,7 @@
etc) within the inspected page. The <code>getContent()</code> and <code
>setContent()</code> methods of the <code>Resource</code> class along with the
<code>onResourceContentCommitted</code> event may be used to support
-modification of the resource content, e.g. by an external editor.
+modification of the resource content, for example, by an external editor.
</p>
<h2 id="overview-examples">Examples</h2>

Powered by Google App Engine
This is Rietveld 408576698