--web-security=no flag/NETWORK_ERR: XMLHttpRequest Exception 101

227 views
Skip to first unread message

Mel Adamaitis

unread,
Feb 29, 2016, 4:15:40 PM2/29/16
to phantomjs

I'm having trouble making a GET request for a JSON object on a different domain. I opened an issue on PhantomJS last week, but it hasn't seen any activity there yet. I was hoping maybe someone here has perhaps come across this error before, or at least might be able to point me in a better direction. Thanks in advance.

I've opened the issue here: https://github.com/ariya/phantomjs/issues/14040, here's the entire issue:

I did find this: https://github.com/ariya/phantomjs/issues/10985 and I went through the entire thing but it was not able to help me.

I'm using PhantomJS with CasperJS, and attempting to make a GET request for a JSON object. On the .send() method, I'm getting the NETWORK_ERR: XMLHttpRequest Exception 101 error.  After digging through this, I believe that the issue is most likely with PhantomJS and not CasperJS.

PhantomJS version:
1.8.2, 1.9.2, 1.9.8, 2.0.0

How to reproduce:
2. Run casperjs --ssl-protocol=tlsv1 --ignore-ssl-errors=true --cookies-file=/tmp/cookies.txt --web-security=no test home_page.js
3. See error:

A-0666:front-end-functional-tests madamaitis$ casperjs --ssl-protocol=tlsv1 --ignore-ssl-errors=true --cookies-file=/tmp/cookies.txt --web-security=no test home_page.js 
2016-02-24 14:09:06.733 phantomjs[51669:19647671] *** WARNING: Method userSpaceScaleFactor in class NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead. 
Test file: home_page.js                                                         
# Home page body tests.
XMLHttpRequest cannot load https://www.limelight.com/get_strings?page_name=home_page. Origin file:// is not allowed by Access-Control-Allow-Origin.
FAIL Error: NETWORK_ERR: XMLHttpRequest Exception 101
#    type: uncaughtError
#    file: home_page.js:90
#    error: {"line":90,"sourceId":252873456,"sourceURL":"home_page.js","stack":"Error: NETWORK_ERR: XMLHttpRequest Exception 101\n    at home_page.js:90\n    at /usr/local/Cellar/casperjs/1.1-beta3/libexec/modules/tester.js:1064\n    at /usr/local/Cellar/casperjs/1.1-beta3/libexec/bin/bootstrap.js:60\n    at begin (/usr/local/Cellar/casperjs/1.1-beta3/libexec/modules/tester.js:1093)\n    at home_page.js:141","stackArray":[{"sourceURL":"home_page.js","line":90},{"sourceURL":"/usr/local/Cellar/casperjs/1.1-beta3/libexec/modules/tester.js","line":1064},{"sourceURL":"/usr/local/Cellar/casperjs/1.1-beta3/libexec/bin/bootstrap.js","line":60},{"function":"begin","sourceURL":"/usr/local/Cellar/casperjs/1.1-beta3/libexec/modules/tester.js","line":1093},{"sourceURL":"home_page.js","line":141}],"code":101,"message":"NETWORK_ERR: XMLHttpRequest Exception 101","name":"NETWORK_ERR"}
#    stack: not provided
FAIL 1 test executed in 0.134s, 0 passed, 1 failed, 0 dubious, 0 skipped.       

Details for the 1 failed test:

In home_page.js:90
  Home page body tests.
    uncaughtError: Error: NETWORK_ERR: XMLHttpRequest Exception 101


CasperJS's documentation said to add the flag --web-security=no, and that this error would be solved. I looked through CasperJS's source code, and found that it was just piping that along directly to PhantomJS. So, then I looked through PhantomJS's source code for where the web-security flag is used and found this:


Java is certainly not my strongest language, and I'm certainly not very familiar with the codebase for this, but it looks as if the ability to turn off web security has been... commented out?

However, there's also a C++ file here:


That seems to allow it to be set... however it sets a variable called m_webSecurityEnabled that based on a search of the repo I don't see being used?

It was at this point that I decided that perhaps this would be better handled by asking someone more familiar with this project for some help. If this is actually an error with CasperJS, I'm happy to go open this up over there. It is sometimes difficult to be completely sure where to open an issue at. Thanks in advance.

Expected output
That the XMLHttpRequest object can retrieve the data at the specified endpoint without creating the NETWORK_ERR: XMLHttpRequest Exception 101 error.

My OS
Mac 10.10.3

How I installed PhantomJS
via Homebrew
Reply all
Reply to author
Forward
0 new messages