nathanboktae / mocha-phantomjs

:coffee: :ghost: Run client-side mocha tests in the command line through phantomjs
MIT License
954 stars 112 forks source link

Unsafe JavaScript attempt #167

Closed 3rd-Eden closed 9 years ago

3rd-Eden commented 9 years ago

Hey,

I've been trying to get this project running on my local machine. But every time I run the test suite I'm greeted by the following error:

Unsafe JavaScript attempt to access frame with URL about:blank from frame with URL file:///Users/V1/Projects/unshiftio/url-parse/node_modules/mocha-phantomjs/lib/mocha-phantomjs.coffee. Domains, protocols and ports must match.

It might be related to 1.9.8 release of phantomjs: https://github.com/ariya/phantomjs/issues/12697

metaskills commented 9 years ago

Interesting. I just checked master and ran the tests fine and I have 1.9.8 installed too. Thats not to say that this is not a problem, but I did not see it yet. Looking for others to chime in.

3rd-Eden commented 9 years ago

I also tried running my own tests using mochify and it works as intended. The tests that I was running against can be found here: https://github.com/unshiftio/url-parse/blob/master/test.js

paulfalgout commented 9 years ago

I'm also running into this issue, and here's someone else experiencing it as well via the gulp plugin. https://github.com/mrhooray/gulp-mocha-phantomjs/issues/22

andreialecu commented 9 years ago

I had this issue as well, but I resolved it by updating mocha.js to the latest version.

erik-vanlankvelt commented 9 years ago

I'm having the same issue. Also using gulp-mocha-phantomjs.

nathanboktae commented 9 years ago

Yes it is because of the above referenced phantomjs issue. I saw it while working on mocha-phantomjs-core too.

from what I've seen, forcing phantomjs@1.9.16 will get around this issue.

mike-engel commented 9 years ago

@nathanboktae I just tried to install phantomjs@1.9.16 in both the main project and inside mocha-phantomjs to no avail. I've also tried upgrade mocha, to no avail as well.

erik-vanlankvelt commented 9 years ago

Any progress on this? Not all my tests run due to this error.

nathanboktae commented 9 years ago

This is not an issue with mocha-phantomjs but phantomjs versions >= 1.9.8 < 2.0, as evidenced here by a CI run on mocha-phantomjs-core.

I'm going to be focusing on v4 that will move to phantomjs 2, so this will be resolved then. For now, you can force using an older version of phantomjs via the -p option if you are blocked.

halcarleton commented 9 years ago

@nathanboktae

from what I've seen, forcing phantomjs@1.9.16 will get around this issue.

Are you referring to forcing the npm package phantomjs to phantomjs@1.9.16? If so I tried this and it still installs version 1.9.8 of PhantomJS.

$ ./node_modules/phantomjs/lib/phantom/bin/phantomjs -v
1.9.8

Is there a workaround that will solve this until v2.0.0 is stable on linux?

nathanboktae commented 9 years ago

If so I tried this and it still installs version 1.9.8 of PhantomJS.

Correct I was mistaken.

Install phantomjs 1.9.16 yourself then use the -p option to use that phantomjs.

halcarleton commented 9 years ago

The npm package or the actual software?

I tried that with the npm package, and I don't see a v1.9.16 of PhantomJS.

I'll try building 1.9.7 from source and will report back.

halcarleton commented 9 years ago

Alright, I built PhantomJS 1.9.7 from source by following these instructions, except instead of git checkout 2.0 I used git checkout 1.9.7.

Then I changed the PhantomJS path in my mocha-phantomjs test command from ./node_modules/phantomjs/lib/phantom/bin/phantomjs to /usr/bin/phantomjs(which is a symlink).

This has fixed this issue for me.

nathanboktae commented 9 years ago

Alright, I built PhantomJS 1.9.7 from source

Ouch, there are built versions available for 1.9.7 FYI.

halcarleton commented 9 years ago

Hmm, I didn't see any information about built older versions on the PhantomJS website, or through a quick google search. The only pre-built versions I could find were 1.9.0(via apt-get install phantomjs) and 1.9.8(via npm install phantomjs).

Oh well, it only took around 40-60 min to build and my work day was already over anyways.

Inviz commented 9 years ago

Broke our Travis. Why would you do this in minor version? My problem is that I dont even control that, as it gets required via grunt-mocha-phantomjs intermediate

nathanboktae commented 9 years ago

Why would you do this in minor version

Right it shouldn't have been. My bad I'll revert the dependency version and republish, then publish a minor bump.

And in v4 it'll be a direct dependency avoiding the problem.

nickp10 commented 9 years ago

This change has caused an issue with the gulp-mocha-phantomjs module. I'm not entirely sure how the dependency versions are working, but gulp-mocha-phantomjs is allowing phantomjs 1.9.17, where this change is only allowing up to 1.9.15. This results in the following error:

npm ERR! peerinvalid The package phantomjs does not satisfy its siblings' peerDependencies requirements! npm ERR! peerinvalid Peer mocha-phantomjs@3.5.4 wants phantomjs@1.9.1 - 1.9.7-15

The workaround is to explicitly reference phantomjs 1.9.15 in my package.json file.