JSCoverage
code coverage for JavaScript

Bug #12 - jscoverage does not handle popups - can easily be fixed - solution attached

Submitted by: Duncan Loveday
Date submitted: 2009-06-11 17:06:03 UTC
Status: Closed
Hi,

I'm terribly impressed with jscoverage, however I have a suggestion to make.

My app launches popups a lot and I wanted cumulative coverage for the code
running in all the popups. As it stands, coverage figures for each popup are
separate. If popups are opened and closed then the figures cannot be combined.

I fixed this easily by editting the first few lines of boilerplate code in each
.js to replace "top" by the expression "(top.opener==null ? top : top.opener)" -
see below. It seems to work nicely - means all the coverage numbers are
accumulated in the top level window.

Duncan.

/* automatically generated by JSCoverage - do not edit */
if (! (top.opener==null ? top : top.opener)._$jscoverage) {
  (top.opener==null ? top : top.opener)._$jscoverage = {};
}
var _$jscoverage = (top.opener==null ? top : top.opener)._$jscoverage;
if (! _$jscoverage['slider/js/range.js']) {
  _$jscoverage['slider/js/range.js'] = [];
  _$jscoverage['slider/js/range.js'][33] = 0;
  _$jscoverage['slider/js/range.js'][34] = 0;
  _$jscoverage['slider/js/range.js'][35] = 0;
Submitted by: Ed
Date submitted: 2009-06-11 23:33:06 UTC
Thanks, I've been thinking of adding something like that in the next version.
Submitted by: Anonymous
Date submitted: 2009-10-08 07:14:50 UTC
when will be the Release of next version? can we get the following lines of 
code in the next release? or is there a way I can add the following lines of 
code only once, so that it will include in all instrumented js files .
"
if (! (top.opener==null ? top : top.opener)._$jscoverage) {
  (top.opener==null ? top : top.opener)._$jscoverage = {};
}
var _$jscoverage = (top.opener==null ? top : top.opener)._$jscoverage;"

because we are having approx 550+ js files in our application.  and it is very 
hard to include the 3 lines in all 550+ js files manually.  
Submitted by: sk
Date submitted: 2010-01-27 13:31:39 UTC
Hi,
 
   This will work only if you have two level of pop up. Let me explain my 
scenaio.

   I have the main application and click the link from the application which 
open the pop up window. ( I can get the coverage info if i close this pop up). 
now lets assume that pop up window itself have the another popup. We may not 
able to calculate the coverage for the second pop-up. so please let me know if 
there any solution to resolve this scenario.

Thanks
SK.
Submitted by: Ed
Date submitted: 2010-01-27 16:24:43 UTC
I believe the second pop-up is handled by the version of JSCoverage currently in
the Subversion repository.
Submitted by: Ed
Date submitted: 2010-04-26 01:37:06 UTC
I believe this is fixed now in version 0.5.  This bug is being closed; if there
are any further problems please submit a new bug.

Add a comment

Your name:
Your email address (optional - will never be displayed):
Comment:
Attachment (optional - maximum 64 KiB):
Copyright © 2008 Silicon Forks siliconforks.com
siliconforks@siliconforks.com