Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

phantomjs / Chrome gives "Refused to set unsafe header 'Content-Length'" #54

Closed
djfishe opened this issue Mar 8, 2013 · 4 comments
Closed
Assignees
Labels

Comments

@djfishe
Copy link

djfishe commented Mar 8, 2013

Hi,
when trying to run QUnit tests via phantomjs and using JSCover in server mode (I'm fetching the 'http://localhost:9082/test.html', which contains the QUnit tests, via JSCover server) - phantomjs is giving "Refused to set unsafe header 'Content-Length'" in the console.
This makes sense because WebKit browsers refuse to allow this kind of a behavior since it poses a security risk.
The same thing happens when trying to run the 'http://localhost:9082/test.html' directly in Chrome browser.

I checked where this header is set and there are two places:

  • \src\main\resources\report.js:41
  • \src\main\resources\jscoverage.js:1270

I wonder why this is there and is there a way to remove it.
I tried to comment out these two lines and then re-compile and build the jars (with ant) and when I run the JSCover in server mode and try to access 'http://localhost:9082/jscoverage.html' I get the following exception:

java.lang.RuntimeException: Problem loading file: '/jscoverage.html'
at jscover.util.IoUtils.loadFromClassPath(IoUtils.java:446)
at jscover.util.IoService.generateJSCoverageHtml(IoService.java:397)
at jscover.server.InstrumentingRequestHandler.handleGet(InstrumentingRequestHandler.java:433)
at jscover.server.HttpServer.run(HttpServer.java:403)
Caused by: java.lang.NullPointerException
at java.io.Reader.(Reader.java:61)
at java.io.InputStreamReader.(InputStreamReader.java:96)
at jscover.util.IoUtils.toString(IoUtils.java:382)
at jscover.util.IoUtils.loadFromClassPath(IoUtils.java:444)
... 3 more

@tntim96
Copy link
Owner

tntim96 commented Mar 8, 2013

Thanks for the report - I'll take a look...

@tntim96
Copy link
Owner

tntim96 commented Mar 8, 2013

Those lines are now removed in trunk. Are you able to build and test?

Problem loading file: '/jscoverage.html'

If you've built from an IDE, you'll have to copy the resources in directory to the classpath. The IntelliJ project files include ?*.properties;?*.xml;?*.gif;?*.png;?*.jpeg;?*.jpg;?*.html;?*.dtd;?*.tld;?*.ftl;?*.js;?*.css;?*.txt;?*.json;?*.MF. The Ant task jar-all will do all this for you to.

@ghost ghost assigned tntim96 Mar 8, 2013
@djfishe
Copy link
Author

djfishe commented Mar 8, 2013

Thanks. I'll build now and test.

@djfishe
Copy link
Author

djfishe commented Mar 8, 2013

It works. Thanks!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants