diff options
7 files changed, 464 insertions, 80 deletions
diff --git a/chrome/common/extensions/api/devtools_api.json b/chrome/common/extensions/api/devtools_api.json index b486820..fc9a09c 100644 --- a/chrome/common/extensions/api/devtools_api.json +++ b/chrome/common/extensions/api/devtools_api.json @@ -1,5 +1,58 @@ [ { + "namespace": "experimental.devtools.inspectedWindow", + "properties": { + "tabId": { + "description": "The ID of the tab being inspected. This ID may be used with chrome.tabs.* API.", + "type": "integer" + } + }, + "functions": [ + { + "name": "eval", + "type": "function", + "description": "Evaluates a JavaScript expression in the context of the main frame of the inspected page. The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown.", + "parameters": [ + { + "name": "expression", + "type": "string", + "description": "An expression to evaluate." + }, + { + "name": "callback", + "type": "function", + "description": "A function called when evaluation completes.", + "parameters": [ + { + "name": "result", + "type": "object", + "description": "The result of evaluation." + }, + { + "name": "isException", + "type": "boolean", + "description": "Set if an exception was caught while evaluating the expression" + } + ] + } + ] + }, + { + "name": "reload", + "type": "function", + "description": "Reloads the inspected page, optionally setting override for the user agent string.", + "parameters": [ + { + "name": "userAgent", + "type": "string", + "optional": true, + "description": "A user agent override string." + } + ] + } + ] + }, + { "namespace": "experimental.devtools.panels", "types": [ { @@ -248,9 +301,9 @@ ] }, { - "name": "onNavigation", + "name": "onNavigated", "type": "function", - "description": "Fired when an inspected window navigates to a new URL.", + "description": "Fired when the inspected window navigates to a new page.", "parameters": [ { "name": "url", @@ -442,4 +495,3 @@ ] } ] - diff --git a/chrome/common/extensions/docs/experimental.devtools.html b/chrome/common/extensions/docs/experimental.devtools.html index 7d26058..f07d3b2 100644 --- a/chrome/common/extensions/docs/experimental.devtools.html +++ b/chrome/common/extensions/docs/experimental.devtools.html @@ -323,6 +323,7 @@ Chrome Developer Tools: <ul> <li> <a href="experimental.devtools.audits.html">experimental.devtools.audits</a></li><li> + <a href="experimental.devtools.inspectedWindow.html">experimental.devtools.inspectedWindow</a></li><li> <a href="experimental.devtools.panels.html">experimental.devtools.panels</a></li><li> <a href="experimental.devtools.resources.html">experimental.devtools.resources</a></li> </ul> diff --git a/chrome/common/extensions/docs/experimental.devtools.inspectedWindow.html b/chrome/common/extensions/docs/experimental.devtools.inspectedWindow.html index b1d645c..e662d7e 100644 --- a/chrome/common/extensions/docs/experimental.devtools.inspectedWindow.html +++ b/chrome/common/extensions/docs/experimental.devtools.inspectedWindow.html @@ -16,7 +16,7 @@ <script type="text/javascript" src="js/api_page_generator.js"></script> <script type="text/javascript" src="js/bootstrap.js"></script> <script type="text/javascript" src="js/sidebar.js"></script> - <title>experimental.webInspector.inspectedWindow - Google Chrome Extensions - Google Code</title></head> + <title>chrome.experimental.devtools.inspectedWindow.* APIs - Google Chrome Extensions - Google Code</title></head> <body> <div id="gc-container" class="labs"> <div id="devModeWarning"> You are viewing extension docs in chrome via the 'file:' scheme: are you expecting to see local changes when you refresh? You'll need run chrome with --allow-file-access-from-files. @@ -251,28 +251,35 @@ <div class="g-unit" id="gc-pagecontent"> <div id="pageTitle"> - <h1 class="page_title">experimental.webInspector.inspectedWindow</h1> + <h1 class="page_title">chrome.experimental.devtools.inspectedWindow.* APIs</h1> </div> <!-- TABLE OF CONTENTS --> <div id="toc"> <h2>Contents</h2> <ol> - <li style="display: none; "> - <a>h2Name</a> + <li> + <a href="#H2-0">Notes</a> <ol> - <li> + <li style="display: none; "> + <a>h3Name</a> + </li> + </ol> + </li><li> + <a href="#overview-examples">Examples</a> + <ol> + <li style="display: none; "> <a>h3Name</a> </li> </ol> </li> <li> - <a href="#apiReference">API reference: experimental.webInspector.inspectedWindow</a> + <a href="#apiReference">API reference: chrome.experimental.devtools.inspectedWindow</a> <ol> - <li style="display: none; "> + <li> <a href="#properties">Properties</a> <ol> <li> - <a href="#property-anchor">propertyName</a> + <a href="#property-tabId">tabId</a> </li> </ol> </li> @@ -281,18 +288,16 @@ <ol> <li> <a href="#method-eval">eval</a> + </li><li> + <a href="#method-reload">reload</a> </li> </ol> </li> - <li> - <a href="#global-events">Events</a> + <li style="display: none; "> + <a>Events</a> <ol> <li> - <a href="#event-onDOMContentLoaded">onDOMContentLoaded</a> - </li><li> - <a href="#event-onLoaded">onLoaded</a> - </li><li> - <a href="#event-onNavigated">onNavigated</a> + <a href="#event-anchor">eventName</a> </li> </ol> </li> @@ -311,32 +316,174 @@ <!-- /TABLE OF CONTENTS --> <!-- Standard content lead-in for experimental API pages --> - <p id="classSummary" style="display: none; "> + <p id="classSummary"> For information on how to use experimental APIs, see the <a href="experimental.html">chrome.experimental.* APIs</a> page. </p> <!-- STATIC CONTENT PLACEHOLDER --> - <div id="static"></div> + <div id="static"><div id="pageData-name" class="pageData">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. +</p><p> +See <a href="experimental.devtools.html">DevTools APIs summary</a> for +general introduction to using Developer Tools APIs. +</p> + +<a name="H2-0"></a><h2>Notes</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. +However, please note that <code>chrome.tabs.*</code> API is not +exposed to the Developer Tools extension pages due to security considerations +— 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> +The <code>eval()</code> provides the ability for extensions to execute +JavaScript code in the context of the main frame of the inspected page. +This function is different from +<code>chrome.tabs.executeScript()</code> in the following aspects: +<p></p><ul> +<li>The <code>eval()</code> does not +use an isolated world for the code being evaluated, so the JavaScript state +of the inspected window is accessible to the 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 +primitive JavaScript types and acyclic references to other JSON +objects). + +<em>Please observe extra care while processing the data received from the +inspected page — 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> +<p class="caution"> +<strong>Important:</strong> +Due to the security considerations explained above, +<a href="tabs.html#method-executeScript"><code>chrome.tabs.executeScript()</code></a> is the preferred way for an extension +to access DOM data of the inspected page in cases where the access to +JavaScript state of the inspected page is not required. +</p><p> +The <code>reload()</code> may be used to reload the inspected page. +Additionally, a user agent string may be specifcied, which will cause Chrome +to use the given string in the User-Agent HTTP header while fetching the page +and its resources, and return it to the scripts running in that page. +</p> + +<h2 id="overview-examples">Examples</h2> +<p>The following code checks for the version of jQuery used by the inspected +page: + +</p><pre>chrome.experimental.devtools.inspectedWindow.eval( + "jQuery.fn.jquery", + function(result, isException) { + if (isException) + console.log("the page is not using jQuery"); + else + console.log("The page is using jQuery v" + result); + } +); +</pre> + +<p> +You can find more examples that use Developer Tools APIs in +<a href="samples.html#devtools">Samples</a>. +</p> +</div> <!-- API PAGE --> <div class="apiPage"> <a name="apiReference"></a> - <h2>API reference: experimental.webInspector.inspectedWindow</h2> + <h2>API reference: chrome.experimental.devtools.inspectedWindow</h2> <!-- PROPERTIES --> - <div class="apiGroup" style="display: none; "> + <div class="apiGroup"> <a name="properties"></a> <h3 id="properties">Properties</h3> <div> - <a></a> - <h4>getLastError</h4> + <a name="property-tabId"></a> + <h4>tabId</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span>chrome.extension</span><span>lastError</span> + <span>chrome.experimental.devtools.inspectedWindow.</span><span>tabId</span> </div> <div> + <dt> + <var>tabId</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional" style="display: none; ">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>integer</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>The ID of the tab being inspected. This ID may be used with chrome.tabs.* API.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> </div> </div> <!-- /apiGroup --> @@ -353,13 +500,13 @@ <div class="summary"><span style="display: none; ">void</span> <!-- Note: intentionally longer 80 columns --> - <span>experimental.webInspector.inspectedWindow.eval</span>(<span class="null"><span style="display: none; ">, </span><span>string</span> + <span>chrome.experimental.devtools.inspectedWindow.eval</span>(<span class="null"><span style="display: none; ">, </span><span>string</span> <var><span>expression</span></var></span><span class="null"><span>, </span><span>function</span> <var><span>callback</span></var></span>)</div> <div class="description"> <p class="todo" style="display: none; ">Undocumented.</p> - <p>Evaluates a JavaScript expression in the context of inspected page (NOTE: the expression must evaluate to a JSON-compliant object, otherwise the exception is thrown)</p> + <p>Evaluates a JavaScript expression in the context of the main frame of the inspected page. The expression must evaluate to a JSON-compliant object, otherwise an exception is thrown.</p> <!-- PARAMETERS --> <h4>Parameters</h4> @@ -559,7 +706,7 @@ <dd class="todo" style="display: none; "> Undocumented. </dd> - <dd>The result of evaluation</dd> + <dd>The result of evaluation.</dd> <dd style="display: none; "> This parameter was added in version <b><span></span></b>. @@ -678,56 +825,162 @@ </p> </div> <!-- /description --> - </div> <!-- /apiItem --> - - </div> <!-- /apiGroup --> - - <!-- EVENTS --> - <div id="eventsTemplate" class="apiGroup"> - <a name="global-events"></a> - <h3>Events</h3> - <!-- iterates over all events --> - <div class="apiItem"> - <a name="event-onDOMContentLoaded"></a> - <h4>onDOMContentLoaded</h4> + </div><div class="apiItem"> + <a name="method-reload"></a> <!-- method-anchor --> + <h4>reload</h4> - <div class="summary"> - <!-- Note: intentionally longer 80 columns --> - <span class="subdued">experimental.webInspector.inspectedWindow.</span><span>onDOMContentLoaded</span><span class="subdued">.addListener</span>(function(<span></span>) <span class="subdued">{...}</span>); - </div> + <div class="summary"><span style="display: none; ">void</span> + <!-- Note: intentionally longer 80 columns --> + <span>chrome.experimental.devtools.inspectedWindow.reload</span>(<span class="optional"><span style="display: none; ">, </span><span>string</span> + <var><span>userAgent</span></var></span>)</div> <div class="description"> <p class="todo" style="display: none; ">Undocumented.</p> - <p>Fired after DOMContentLoaded event on inspected page is fired.</p> + <p>Reloads the inspected page, optionally setting override for the user agent string.</p> <!-- PARAMETERS --> + <h4>Parameters</h4> + <dl> + <div> + <div> + <dt> + <var>userAgent</var> + <em> + + <!-- TYPE --> + <div style="display:inline"> + ( + <span class="optional">optional</span> + <span class="enum" style="display: none; ">enumerated</span> + <span id="typeTemplate"> + <span style="display: none; "> + <a> Type</a> + </span> + <span> + <span style="display: none; "> + array of <span><span></span></span> + </span> + <span>string</span> + <span style="display: none; "></span> + </span> + </span> + ) + </div> + + </em> + </dt> + <dd class="todo" style="display: none; "> + Undocumented. + </dd> + <dd>A user agent override string.</dd> + <dd style="display: none; "> + This parameter was added in version + <b><span></span></b>. + You must omit this parameter in earlier versions, + and you may omit it in any version. If you require this + parameter, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </dd> + + <!-- OBJECT PROPERTIES --> + <dd style="display: none; "> + <dl> + <div> + <div> + </div> + </div> + </dl> + </dd> + + <!-- OBJECT METHODS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- OBJECT EVENT FIELDS --> + <dd style="display: none; "> + <div></div> + </dd> + + <!-- FUNCTION PARAMETERS --> + <dd style="display: none; "> + <div></div> + </dd> + + </div> + </div> + </dl> + + <!-- RETURNS --> + <h4 style="display: none; ">Returns</h4> + <dl> + <div style="display: none; "> + <div> + </div> + </div> + </dl> + + <!-- CALLBACK --> <div style="display: none; "> - <h4>Parameters</h4> + <div> + <h4>Callback function</h4> + <p> + The callback <em>parameter</em> should specify a function + that looks like this: + </p> + <p> + If you specify the <em>callback</em> parameter, it should + specify a function that looks like this: + </p> + + <!-- Note: intentionally longer 80 columns --> + <pre>function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span>;</pre> <dl> <div> <div> </div> </div> </dl> + </div> </div> - </div> <!-- /decription --> - </div><div class="apiItem"> - <a name="event-onLoaded"></a> - <h4>onLoaded</h4> + <!-- MIN_VERSION --> + <p style="display: none; "> + This function was added in version <b><span></span></b>. + If you require this function, the manifest key + <a href="manifest.html#minimum_chrome_version">minimum_chrome_version</a> + can ensure that your extension won't be run in an earlier browser version. + </p> + </div> <!-- /description --> + + </div> <!-- /apiItem --> + + </div> <!-- /apiGroup --> + + <!-- EVENTS --> + <div id="eventsTemplate" class="apiGroup" style="display: none; "> + <a></a> + <h3>Events</h3> + <!-- iterates over all events --> + <div class="apiItem"> + <a></a> + <h4>event name</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span class="subdued">experimental.webInspector.inspectedWindow.</span><span>onLoaded</span><span class="subdued">.addListener</span>(function(<span></span>) <span class="subdued">{...}</span>); + <span class="subdued">chrome.bookmarks</span><span>onEvent</span><span class="subdued">.addListener</span>(function(<span>Type param1, Type param2</span>) <span class="subdued">{...}</span><span>, Type opt_param1, Type opt_param2</span>)); </div> <div class="description"> - <p class="todo" style="display: none; ">Undocumented.</p> - <p>Fired after load event on inspected page is fired.</p> + <p class="todo">Undocumented.</p> + <p> + A description from the json schema def of the event goes here. + </p> - <!-- PARAMETERS --> - <div style="display: none; "> - <h4>Parameters</h4> + <!-- LISTENER PARAMETERS --> + <div> + <h4>Listener parameters</h4> <dl> <div> <div> @@ -735,24 +988,10 @@ </div> </dl> </div> - </div> <!-- /decription --> - - </div><div class="apiItem"> - <a name="event-onNavigated"></a> - <h4>onNavigated</h4> - - <div class="summary"> - <!-- Note: intentionally longer 80 columns --> - <span class="subdued">experimental.webInspector.inspectedWindow.</span><span>onNavigated</span><span class="subdued">.addListener</span>(function(<span></span>) <span class="subdued">{...}</span>); - </div> - <div class="description"> - <p class="todo" style="display: none; ">Undocumented.</p> - <p>Fired when navigation occurs in the window being inspected.</p> - - <!-- PARAMETERS --> - <div style="display: none; "> - <h4>Parameters</h4> + <!-- EXTRA PARAMETERS --> + <div> + <h4>Extra parameters to addListener</h4> <dl> <div> <div> @@ -760,8 +999,17 @@ </div> </dl> </div> - </div> <!-- /decription --> + <!-- LISTENER RETURN VALUE --> + <h4>Listener returns</h4> + <dl> + <div> + <div> + </div> + </div> + </dl> + + </div> <!-- /description --> </div> <!-- /apiItem --> </div> <!-- /apiGroup --> diff --git a/chrome/common/extensions/docs/experimental.devtools.resources.html b/chrome/common/extensions/docs/experimental.devtools.resources.html index a7c2c04..d14b57d 100644 --- a/chrome/common/extensions/docs/experimental.devtools.resources.html +++ b/chrome/common/extensions/docs/experimental.devtools.resources.html @@ -304,7 +304,7 @@ <li> <a href="#event-onFinished">onFinished</a> </li><li> - <a href="#event-onNavigation">onNavigation</a> + <a href="#event-onNavigated">onNavigated</a> </li> </ol> </li> @@ -723,17 +723,17 @@ You can find examples that use this API in </div> <!-- /description --> </div><div class="apiItem"> - <a name="event-onNavigation"></a> - <h4>onNavigation</h4> + <a name="event-onNavigated"></a> + <h4>onNavigated</h4> <div class="summary"> <!-- Note: intentionally longer 80 columns --> - <span class="subdued">chrome.experimental.devtools.resources.</span><span>onNavigation</span><span class="subdued">.addListener</span>(function(<span>string url</span>) <span class="subdued">{...}</span><span></span>)); + <span class="subdued">chrome.experimental.devtools.resources.</span><span>onNavigated</span><span class="subdued">.addListener</span>(function(<span>string url</span>) <span class="subdued">{...}</span><span></span>)); </div> <div class="description"> <p class="todo" style="display: none; ">Undocumented.</p> - <p>Fired when an inspected window navigates to a new URL.</p> + <p>Fired when the inspected window navigates to a new page.</p> <!-- LISTENER PARAMETERS --> <div> diff --git a/chrome/common/extensions/docs/experimental.html b/chrome/common/extensions/docs/experimental.html index 8c62aec..69378a4 100644 --- a/chrome/common/extensions/docs/experimental.html +++ b/chrome/common/extensions/docs/experimental.html @@ -325,6 +325,7 @@ on the following experimental APIs: <a href="experimental.contentSettings.html">experimental.contentSettings</a></li><li> <a href="experimental.debugger.html">experimental.debugger</a></li><li> <a href="experimental.devtools.audits.html">experimental.devtools.audits</a></li><li> + <a href="experimental.devtools.inspectedWindow.html">experimental.devtools.inspectedWindow</a></li><li> <a href="experimental.devtools.panels.html">experimental.devtools.panels</a></li><li> <a href="experimental.devtools.resources.html">experimental.devtools.resources</a></li><li> <a href="experimental.infobars.html">experimental.infobars</a></li><li> diff --git a/chrome/common/extensions/docs/samples.json b/chrome/common/extensions/docs/samples.json index 32c398b..b93c3a9 100644 --- a/chrome/common/extensions/docs/samples.json +++ b/chrome/common/extensions/docs/samples.json @@ -46,10 +46,12 @@ "chrome.experimental.debugger.onEvent": "experimental.debugger.html#event-onEvent", "chrome.experimental.debugger.sendRequest": "experimental.debugger.html#method-sendRequest", "chrome.experimental.devtools.audits.addCategory": "experimental.devtools.audits.html#method-addCategory", + "chrome.experimental.devtools.inspectedWindow.eval": "experimental.devtools.inspectedWindow.html#method-eval", + "chrome.experimental.devtools.inspectedWindow.reload": "experimental.devtools.inspectedWindow.html#method-reload", "chrome.experimental.devtools.panels.create": "experimental.devtools.panels.html#method-create", "chrome.experimental.devtools.resources.getHAR": "experimental.devtools.resources.html#method-getHAR", "chrome.experimental.devtools.resources.onFinished": "experimental.devtools.resources.html#event-onFinished", - "chrome.experimental.devtools.resources.onNavigation": "experimental.devtools.resources.html#event-onNavigation", + "chrome.experimental.devtools.resources.onNavigated": "experimental.devtools.resources.html#event-onNavigated", "chrome.experimental.infobars.show": "experimental.infobars.html#method-show", "chrome.experimental.permissions.contains": "experimental.permissions.html#method-contains", "chrome.experimental.permissions.getAll": "experimental.permissions.html#method-getAll", diff --git a/chrome/common/extensions/docs/static/experimental.devtools.inspectedWindow.html b/chrome/common/extensions/docs/static/experimental.devtools.inspectedWindow.html new file mode 100644 index 0000000..7ab4add --- /dev/null +++ b/chrome/common/extensions/docs/static/experimental.devtools.inspectedWindow.html @@ -0,0 +1,80 @@ +<div id="pageData-name" class="pageData" +>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. +</p><p> +See <a href="experimental.devtools.html">DevTools APIs summary</a> for +general introduction to using Developer Tools APIs. +</p> + +<h2>Notes</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. +However, please note that <code>chrome.tabs.*</code> API is not +exposed to the Developer Tools extension pages due to security considerations +— 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> +The <code>eval()</code> provides the ability for extensions to execute +JavaScript code in the context of the main frame of the inspected page. +This function is different from +<code>chrome.tabs.executeScript()</code> in the following aspects: +</p><ul> +<li>The <code>eval()</code> does not +use an isolated world for the code being evaluated, so the JavaScript state +of the inspected window is accessible to the 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 +primitive JavaScript types and acyclic references to other JSON +objects). + +<em>Please observe extra care while processing the data received from the +inspected page — 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> +<p class="caution"> +<strong>Important:</strong> +Due to the security considerations explained above, +<a href="tabs.html#method-executeScript"><code +>chrome.tabs.executeScript()</code></a> is the preferred way for an extension +to access DOM data of the inspected page in cases where the access to +JavaScript state of the inspected page is not required.</em> +</p><p> +The <code>reload()</code> may be used to reload the inspected page. +Additionally, a user agent string may be specifcied, which will cause Chrome +to use the given string in the User-Agent HTTP header while fetching the page +and its resources, and return it to the scripts running in that page. +</p> + +<h2 id="overview-examples">Examples</h2> +<p>The following code checks for the version of jQuery used by the inspected +page: + +<pre> +chrome.experimental.devtools.inspectedWindow.eval( + "jQuery.fn.jquery", + function(result, isException) { + if (isException) + console.log("the page is not using jQuery"); + else + console.log("The page is using jQuery v" + result); + } +); +</pre> + +<p> +You can find more examples that use Developer Tools APIs in +<a href="samples.html#devtools">Samples</a>. +</p> |