tntim96 / JSCover

JSCover is a JavaScript Code Coverage Tool that measures line, branch and function coverage
GNU General Public License v2.0
399 stars 84 forks source link

Need a way to turn off window.opener handling #197

Closed cobexer closed 9 years ago

cobexer commented 9 years ago

In my CI environment I run Internet Explorer against my application, however if I open another window from within my application the second window merges it's coverage data with the first window. In Internet Explorer that makes the second window execute very slowly and for example causes the call to jscoverage_report to take upwards of 170 Seconds!!(my test automation often kills my browser during this time) In a lengthy process I optained a profiling result that showed around 150 calls to getArrayJSON.

(in my combined coverage I have around 70 files and 25500 statements)

I use JSCover in server mode, have an Apache reverse proxy in front of it (to make use easier in my CI and to avoid sending the webserver requests through JSCover) and manage storing the jscover data myself.

So to fix my performance issue I need a way to turn off window.opener integration.

tntim96 commented 9 years ago

I think the relevant code is the first 34 lines of header.js. I could add a switch, say --isolate-browsers, to turn this off - is that what you need?

cobexer commented 9 years ago

Yes if that code in the header.js would be skipped that would indeed solve the problem I am seeing. I guess that switch would be useful for all modes that do instumentation - that would also help a coworker that used to patch JSCover to avoid the connection.

tntim96 commented 9 years ago

Before I commit, can you test with either this test JAR or the 1.0.20-SNAPSHOT which will need this in your POM

<pluginRepository>
    <id>Sonatype repository</id>
    <name>Sonatype's Maven repository</name>
    <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</pluginRepository>

The switch to use is --isolate-browser.

The implementation will require newly opened windows to save their coverage data separately (it won't be combined with the opener window), but should speed up the jscoverage_report calls, as it will only include the coverage data for that window.

Any use of the jscoverage.html page will try to incorporate existing coverage data, but I assume from your description that you are not doing this.

cobexer commented 9 years ago

I just tried this build in our CI and this solved all issues I had with timeouts / hangs on Internet Explorer!

Thanks for the prompt fix!

tntim96 commented 9 years ago

Great. This will go in release 1.0.20

tntim96 commented 9 years ago

I've just released 1.0.20 if you want to use that. Should appear in Maven repository soon.

cobexer commented 9 years ago

Deployed 1.0.20 to the CI - works great! Thanks for the fast fix!