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

Side by Side Diff: chrome/common/extensions/docs/server2/templates/intros/experimental_devtools_audits.html

Issue 10797039: Extensions Docs Server: devtools API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: move parsing logic into utils Created 8 years, 4 months 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!-- BEGIN AUTHORED CONTENT -->
2 <p id="classSummary">
3 Use the <code>chrome.experimental.devtools.audits</code> module to add new audit
4 categories to Developer Tools' Audit panel.
5 </p><p>
6 See <a href="experimental.devtools.html">DevTools APIs summary</a> for
7 general introduction to using Developer Tools APIs</a>.
8 </p>
9
10 <h2>Overview</h2>
11
12 <p>
13 Each audit category is represented by a line on <em>Select audits to run</em>
14 screen in the Audits panel. The following example adds a category named
15 <em>Readability</em>:</p>
16 <pre>
17 var category = chrome.experimental.devtools.audits.addCategory("Readability", 2) ;
18 </pre>
19 <img src="{{static}}/images/devtools-audits-category.png"
20 style="margin-left: 20px"
21 width="489" height="342"
22 alt="Extension audit category on the launch screen of Audits panel" />
23 <p>
24 If the category's checkbox is checked, the <code>onAuditStarted</code> event of
25 that category will be fired when user clicks the <em>Run</em> button.
26 </p>
27 <p>The event handler in your extension receives <code>AuditResults</code>
28 as an argument and should add one or more results using <code>addResult()</code>
29 method. This may be done asynchronously, i.e. after the handler returns. The
30 run of the category is considered to be complete once the extension adds the
31 number of results declared when adding the category with
32 <code>addCategory()</code> or
33 calls AuditResult's <code>done()</code> method.
34 </p>
35 <p>The results may include additional details visualized as an expandable
36 tree by the Audits panel. You may build the details tree using the
37 <code>createResult()</code> and <code>addChild()</code> methods. The child node
38 may include specially formatted fragments created by the
39 <code>auditResults.createSnippet()</code>
40 and <code>auditResults.createURL()</code> methods.
41 </p>
42
43 <h2>Examples</h2>
44 <p>The following example adds a handler for onAuditStarted event that creates
45 two audit results and populates one of them with the additional details:
46 </p>
47
48 <pre>
49 category.onAuditStarted.addListener(function(results) {
50 var details = results.createResult("Details...");
51 var styles = details.addChild("2 styles with small font");
52 var elements = details.addChild("3 elements with small font");
53
54 results.addResult("Font Size (5)",
55 "5 elements use font size below 10pt",
56 results.Severity.Severe,
57 details);
58 results.addResult("Contrast",
59 "Text should stand out from background",
60 results.Severity.Info);
61 });
62 </pre>
63 <p>The audit result tree produced by the snippet above will look like this:
64 </p>
65 <img src="{{static}}/images/devtools-audits-results.png"
66 style="margin-left: 20px"
67 width="330" height="169"
68 alt="Audit results example" />
69
70 <p>
71 You can find more examples that use this API in
72 <a href="samples.html#devtools.audits">Samples</a>.
73 </p>
74 <!-- END AUTHORED CONTENT -->
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698