/[jscoverage]/trunk/doc/faq.html
ViewVC logotype

Contents of /trunk/doc/faq.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 527 - (show annotations)
Fri Mar 26 22:53:18 2010 UTC (9 years, 4 months ago) by siliconforks
File MIME type: text/html
File size: 8999 byte(s)
Add question to FAQ.

1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
2 <html>
3 <head>
4 <title>JSCoverage - FAQ</title>
5 <link rel="stylesheet" type="text/css" href="reset-fonts-grids.css">
6 <link rel="stylesheet" type="text/css" href="style.css">
7 </head>
8 <body>
9 <div id="doc3" class="yui-t5">
10 <div id="hd"><h1><a href="./">JSCoverage</a><br><span class="tag">code coverage for JavaScript</span></h1></div>
11 <div id="bd">
12 <div id="yui-main">
13 <div id="jscoverage-main" class="yui-b">
14 <h2><abbr title="Frequently Asked Questions">FAQ</abbr></h2>
15
16 <h3>Can I use JSCoverage to measure code coverage for a page on <code>http://example.com/</code>?</h3>
17
18 <p>
19 In order to measure the code coverage of a page on <code>http://example.com/</code>,
20 you must run <code>jscoverage</code> to create a <code>jscoverage.html</code> file on the
21 <code>example.com</code> server. You cannot use <code>http://example.org/jscoverage.html</code>
22 to measure the code coverage of a page located on <code>http://example.com/</code>.
23 </p>
24
25 <p>
26 The fundamental reason for this limitation is the
27 <a href="http://www.mozilla.org/projects/security/components/same-origin.html">Same Origin Policy</a>
28 for untrusted JavaScript.
29 </p>
30
31 <p>
32 (In fact, the current version of JSCoverage is slightly more restrictive
33 than this: it requires that the JavaScript being measured reside under the
34 same <strong>directory</strong> as the <code>jscoverage.html</code> file.)
35 </p>
36
37 <h3 id="jscoverage-vs-jscoverage-server">Should I use the <code>jscoverage</code> program or the <code>jscoverage-server</code> program?</h3>
38 <p>
39 First, note that the <code>jscoverage</code> program and the <code>jscoverage-server</code> program are mutually exclusive alternatives;
40 you must use one or the other, but not both. If you try to use both at the same time you will get strange results.
41 </p>
42 <p>
43 Which of the two programs you use is largely a matter of personal preference.
44 The <code>jscoverage-server</code> program has some additional features,
45 such as the ability to store coverage reports to disk.
46 However, the <code>jscoverage</code> program is the more mature of the two and is generally easier to use;
47 this program is recommended if you do not need any of the additional features of <code>jscoverage-server</code>.
48 </p>
49
50 <h3>Why doesn't my test suite run under JSCoverage in Firefox 3?</h3>
51
52 <p>
53 Firefox 3 introduces <a
54 href="http://tech.groups.yahoo.com/group/jsunit/message/1075">new
55 security restrictions</a> on local files. Depending on the way your
56 test suite is organized, this may cause problems for JSCoverage.
57 (You may get the error "uncaught exception: Permission denied to get property Window._$jscoverage".)
58 There are several workarounds:
59 </p>
60
61 <ul class="list">
62 <li><p>Place your files on a web server instead of loading them from the file system.
63 This is usually the simplest solution.</p>
64 <li><p>Organize your HTML files in your test suite in a flat directory structure. For example, suppose that
65 you instrument your test suite with this command:</p>
66 <pre>
67 jscoverage src instrumented
68 </pre>
69 <p>If all your HTML files are located directly under the <code>src/</code> directory (i.e., not in a
70 subdirectory of <code>src/</code>), then you should not have any problems using Firefox 3.</p>
71 <li><p>Set the <a href="http://kb.mozillazine.org/Editing_configuration">Firefox preference</a> named
72 <code><a href="http://kb.mozillazine.org/Security.fileuri.origin_policy">security.fileuri.origin_policy</a></code>
73 to 3.</p>
74 </ul>
75
76 <h3>I'm trying to load my code with the URL
77 <code>file:///C:/foo/bar/jscoverage.html?foo/bar.html</code>
78 and I'm getting all kinds of JavaScript errors.</h3>
79
80 <p>
81 Internet Explorer 6 seems to have problems with a <code>file:</code> URL
82 that has a query string with a slash in it.
83 </p>
84 <p>
85 As a workaround:
86 </p>
87 <ul class="list">
88 <li><p>Place your files on a web server instead of loading them from the file system.
89 (<code>http:</code> URLs work fine.)</p>
90 <li><p>Do not use a query string; enter your URL in the "URL" field in the "Browser" tab.</p>
91 <li><p>Rearrange your directory structure so that <code>bar.html</code>
92 ends up in the same directory as <code>jscoverage.html</code>; then
93 you can use the URL
94 <code>file:///C:/foo/bar/jscoverage.html?bar.html</code>
95 with no slash in the query string.</p>
96 <li><p>Use a different browser. (IE 7 seems to work.)</p>
97 </ul>
98
99 <h3>JSCoverage changes my cursor to a busy cursor, and it never changes back!</h3>
100
101 <p>
102 Certain browsers (<i>e. g</i>., Internet Explorer 6, Opera, Safari) have trouble changing
103 the cursor. Try moving the mouse and your cursor should change back to normal.
104 </p>
105
106 <p>
107 See <a href="http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/631908bd63241136/783c307480f95d8c">this discussion</a> for more information.
108 </p>
109
110 <h3>JSCoverage hangs sometimes when rendering the coverage report.</h3>
111
112 <p>
113 With Internet Explorer 6 (I think I see a pattern here), garbage collection can cause performance problems.
114 (More information <a href="http://ajaxian.com/archives/garbage-collection-in-ie6">here</a>.)
115 </p>
116
117 <h3 id="jsunit">Can JSCoverage be used with <a href="http://www.jsunit.net/">JsUnit</a>?</h3>
118
119 <p>
120 It is necessary to run JSCoverage in <dfn>inverted mode</dfn>. You will have to
121 modify JsUnit to launch JSCoverage.
122 </p>
123
124 <p>
125 See the directory <code>doc/example-jsunit</code> for an example. It
126 contains a copy of JsUnit version 2.2alpha11, with the file
127 <code>jsunit/app/main-data.html</code> slightly modified to add a button
128 which launches JSCoverage. It also contains a simple unit test file <code>test.html</code>. You
129 can instrument this example as follows:
130 </p>
131
132 <pre>
133 jscoverage --no-instrument=jsunit doc/example-jsunit doc/instrumented-jsunit
134 </pre>
135
136 <p>
137 You can then run the <code>test.html</code> file in JsUnit's <code>jsunit/testRunner.html</code>.
138 The simplest way to do this is probably to copy the contents of <code>doc/instrumented-jsunit</code>
139 to the root of a web server and then access the URL
140 </p>
141
142 <pre>
143 http://127.0.0.1/jsunit/testRunner.html?testPage=http://127.0.0.1/test.html&amp;autoRun=true
144 </pre>
145
146 <p>
147 After the test suite has been run, click on the "Coverage report" button
148 to get a coverage report.
149 </p>
150
151 <h3 id="ie-proxy">Does Internet Explorer work with <code>jscoverage-server --proxy</code>?</h3>
152
153 <p>
154 Internet Explorer <a href="http://www.fiddler2.com/fiddler/help/hookup.asp#Q-LocalTraffic">does
155 not use a proxy for URLs with host <code>127.0.0.1</code> or
156 <code>localhost</code></a>.
157 The proxy <em>will</em> be used if you use your machine's actual IP
158 address or host name.
159 For example, if your IP address is <code>192.168.100.100</code>, you can
160 access a URL like <code>http://192.168.100.100/jscoverage.html</code> in
161 Internet Explorer and it will work.
162 (Under Windows, you can get your machine's IP address with the <code>ipconfig</code> command.)
163 </p>
164 </div>
165 </div>
166 <div id="jscoverage-sidebar" class="yui-b">
167 <ul>
168 <li><a href="./">Home</a>
169 <li><a href="news.html">News</a> <a href="http://siliconforks.com/jscoverage/news.xml" type="application/rss+xml" title="RSS feed for JSCoverage"><img src="feed-icon-14x14.png" alt="RSS feed"></a>
170 <li><a href="manual.html">Documentation</a>
171 <li><a href="demo.html">Demo</a>
172 <li><a href="http://siliconforks.com/jscoverage/download.html">Download</a>
173 <li>FAQ
174 <li><a href="help.html">Help</a>
175 <li><a href="license.html">License</a>
176 <li><a href="links.html">Links</a>
177 <li><a href="users.html">Users</a>
178 <li><a href="http://siliconforks.com/jscoverage/bugs/">Bug tracker</a>
179 </ul>
180 </div>
181 </div>
182 <div id="ft">
183 <address>
184 Copyright &copy; 2007, 2008, 2009, 2010 <a href="http://siliconforks.com/"><img src="siliconforks-16x16.png" width="16" height="16" class="icon" alt="Silicon Forks"></a> <a href="http://siliconforks.com/">siliconforks.com</a><br>
185 <a href="mailto:jscoverage@siliconforks.com">jscoverage@siliconforks.com</a>
186 </address>
187 </div>
188 </div>
189 </body>
190 </html>

  ViewVC Help
Powered by ViewVC 1.1.24