PageRenderTime 35ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

HTML | 164 lines | 142 code | 22 blank | 0 comment | 0 complexity | 21172eb3cfcc22557f40f028e9d77b4a MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, MPL-2.0-no-copyleft-exception, BSD-3-Clause
  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. <h3>Can I use JSCoverage to measure code coverage for a page on <code></code>?</h3>
  16. <p>
  17. In order to measure the code coverage of a page on <code></code>,
  18. you must run <code>jscoverage</code> to create a <code>jscoverage.html</code> file on the
  19. <code></code> server. You cannot use <code></code>
  20. to measure the code coverage of a page located on <code></code>.
  21. </p>
  22. <p>
  23. The fundamental reason for this limitation is the
  24. <a href="">Same Origin Policy</a>
  25. for untrusted JavaScript.
  26. </p>
  27. <p>
  28. (In fact, the current version of JSCoverage is slightly more restrictive
  29. than this: it requires that the JavaScript being measured reside under the
  30. same <strong>directory</strong> as the <code>jscoverage.html</code> file.)
  31. </p>
  32. <h3>Why doesn't my test suite run under JSCoverage in Firefox 3?</h3>
  33. <p>
  34. Firefox 3 introduces <a
  35. href="">new
  36. security restrictions</a> on local files. Depending on the way your
  37. test suite is organized, this may cause problems for JSCoverage.
  38. (You may get the error "uncaught exception: Permission denied to get property Window._$jscoverage".)
  39. There are several workarounds:
  40. </p>
  41. <ul class="list">
  42. <li><p>Place your files on a web server instead of loading them from the file system.
  43. This is usually the simplest solution.</p>
  44. <li><p>Organize your HTML files in your test suite in a flat directory structure. For example, suppose that
  45. you instrument your test suite with this command:</p>
  46. <pre>
  47. jscoverage src instrumented
  48. </pre>
  49. <p>If all your HTML files are located directly under the <code>src/</code> directory (i.e., not in a
  50. subdirectory of <code>src/</code>), then you should not have any problems using Firefox 3.</p>
  51. <li><p>Set the <a href="">Firefox preference</a> named
  52. <code><a href="">security.fileuri.origin_policy</a></code>
  53. to 3.</p>
  54. </ul>
  55. <h3>I'm trying to load my code with the URL
  56. <code>file:///C:/foo/bar/jscoverage.html?foo/bar.html</code>
  57. and I'm getting all kinds of JavaScript errors.</h3>
  58. <p>
  59. Internet Explorer 6 seems to have problems with a <code>file:</code> URL
  60. that has a query string with a slash in it.
  61. </p>
  62. <p>
  63. As a workaround:
  64. </p>
  65. <ul class="list">
  66. <li><p>Place your files on a web server instead of loading them from the file system.
  67. (<code>http:</code> URLs work fine.)</p>
  68. <li><p>Do not use a query string; enter your URL in the "URL" field in the "Browser" tab.</p>
  69. <li><p>Rearrange your directory structure so that <code>bar.html</code>
  70. ends up in the same directory as <code>jscoverage.html</code>; then
  71. you can use the URL
  72. <code>file:///C:/foo/bar/jscoverage.html?bar.html</code>
  73. with no slash in the query string.</p>
  74. <li><p>Use a different browser. (IE 7 seems to work.)</p>
  75. </ul>
  76. <h3>JSCoverage changes my cursor to a busy cursor, and it never changes back!</h3>
  77. <p>
  78. Certain browsers (<i>e. g</i>., Internet Explorer 6, Opera, Safari) have trouble changing
  79. the cursor. Try moving the mouse and your cursor should change back to normal.
  80. </p>
  81. <p>
  82. See <a href="">this discussion</a> for more information.
  83. </p>
  84. <h3>JSCoverage hangs sometimes when rendering the coverage report.</h3>
  85. <p>
  86. With Internet Explorer 6 (I think I see a pattern here), garbage collection can cause performance problems.
  87. (More information <a href="">here</a>.)
  88. </p>
  89. <h3 id="jsunit">Can JSCoverage be used with <a href="">JsUnit</a>?</h3>
  90. <p>
  91. It is necessary to run JSCoverage in <dfn>inverted mode</dfn>. You will have to
  92. modify JsUnit to launch JSCoverage.
  93. </p>
  94. <p>
  95. See the directory <code>doc/example-jsunit</code> for an example. It
  96. contains a copy of JsUnit version 2.2alpha11, with the file
  97. <code>jsunit/app/main-data.html</code> slightly modified to add a button
  98. which launches JSCoverage. It also contains a simple unit test file <code>test.html</code>. You
  99. can instrument this example as follows:
  100. </p>
  101. <pre>
  102. jscoverage --no-instrument=jsunit doc/example-jsunit doc/instrumented-jsunit
  103. </pre>
  104. <p>
  105. You can then run the <code>test.html</code> file in JsUnit's <code>jsunit/testRunner.html</code>.
  106. The simplest way to do this is probably to copy the contents of <code>doc/instrumented-jsunit</code>
  107. to the root of a web server and then access the URL
  108. </p>
  109. <pre>
  111. </pre>
  112. <p>
  113. After the test suite has been run, click on the "Coverage report" button
  114. to get a coverage report.
  115. </p>
  116. </div>
  117. </div>
  118. <div id="jscoverage-sidebar" class="yui-b">
  119. <ul>
  120. <li><a href="">Home</a>
  121. <li><a href="news.html">News</a> <a href="" type="application/rss+xml" title="RSS feed for JSCoverage"><img src="feed-icon-14x14.png" alt="RSS feed"></a>
  122. <li><a href="manual.html">Documentation</a>
  123. <li><a href="demo.html">Demo</a>
  124. <li><a href="">Download</a>
  125. <li>FAQ
  126. <li><a href="help.html">Help</a>
  127. <li><a href="license.html">License</a>
  128. <li><a href="links.html">Links</a>
  129. <li><a href="users.html">Users</a>
  130. <li><a href="">Bug tracker</a>
  131. </ul>
  132. </div>
  133. </div>
  134. <div id="ft">
  135. <address>
  136. Copyright &copy; 2007, 2008 <a href=""><img src="siliconforks-16x16.png" width="16" height="16" class="icon" alt="Silicon Forks"></a> <a href=""></a><br>
  137. <a href=""></a>
  138. </address>
  139. </div>
  140. </div>
  141. </body>
  142. </html>