mark-rushakoff/OpenPhantomScripts — pull request #5 by Ali-Khatami (2013-03-29 07:20:26+00:00)
Title: Ajax enhancements

First off, I owe you a beer for putting these scripts together. Saved me after hours of headaches searching and searching not finding the answers I needed to get integrated with Travis CI using jasmine. Now onto me giving a little back...

The default options for phantomjs make it a little tough to create tests that use cross domain or local ajax files. I was doing some digging in the [API reference for WebPage](https://github.com/ariya/phantomjs/wiki/API-Reference-WebPage#settings-object) and came across 2 really helpful properties.

localToRemoteUrlAccessEnabled defines whether local resource (e.g. from file) can access remote URLs or not (defaults to false).

and

webSecurityEnabled defines whether web security should be enabled or not (defaults to true)

The defaults obviously make it more difficult to create really rich tests using ajax or cross domain pieces. Hopefully you find this addition useful. These properties fixed my issues with unit tests running fine locally but not working in Travis CI. I tested this method using inline commands however...

language: ruby
rvm:
- 1.9.3
notifications:
email: false
before_script:
- "export DISPLAY=:99.0"
- "sh -e /etc/init.d/xvfb start"
script:
- "wget https://raw.github.com/mark-rushakoff/OpenPhantomScripts/master/phantom-jasmine.js"
- "phantomjs --local-to-remote-url-access=true --web-security=false phantom-jasmine.js tests/index.html"
- "phantomjs --local-to-remote-url-access=true --web-security=false phantom-jasmine.js tests/index-amd.html"