http://example.com/
?
In order to measure the code coverage of a page on http://example.com/
,
you must run jscoverage
to create a jscoverage.html
file on the
example.com
server. You cannot use http://example.org/jscoverage.html
to measure the code coverage of a page located on http://example.com/
.
The fundamental reason for this limitation is the Same Origin Policy for untrusted JavaScript.
(In fact, the current version of JSCoverage is slightly more restrictive
than this: it requires that the JavaScript being measured reside under the
same directory as the jscoverage.html
file.)
file:///C:/foo/bar/jscoverage.html?foo/bar.html
and I'm getting all kinds of JavaScript errors.
Internet Explorer 6 seems to have problems with a file:
URL
that has a query string with a slash in it.
As a workaround:
http:
URLs work fine.)
bar.html
ends up in the same directory as jscoverage.html
; then
you can use the URL
file:///C:/foo/bar/jscoverage.html?bar.html
with no slash in the query string.
Certain browsers (e. g., Internet Explorer 6, Opera, Safari) have trouble changing the cursor. Try moving the mouse and your cursor should change back to normal.
See this discussion for more information.
With Internet Explorer 6 (I think I see a pattern here), garbage collection can cause performance problems. (More information here.)
It is necessary to run JSCoverage in inverted mode. You will have to modify JsUnit to launch JSCoverage.
See the directory doc/example-jsunit
for an example. It
contains a copy of JsUnit version 2.2alpha11, with the file
jsunit/app/main-data.html
slightly modified to add a button
which launches JSCoverage. It also contains a simple unit test file test.html
. You
can instrument this example as follows:
jscoverage --no-instrument=jsunit doc/example-jsunit doc/instrumented-jsunit
You can then run the test.html
file in JsUnit's jsunit/testRunner.html
.
The simplest way to do this is probably to copy the contents of doc/instrumented-jsunit
to the root of a web server and then access the URL
http://127.0.0.1/jsunit/testRunner.html?testPage=http://127.0.0.1/test.html&autoRun=true
After the test suite has been run, click on the "Coverage report" button to get a coverage report.