Skip to content

Commit

Permalink
Merge pull request jcalderonzumba#17 from bamarni/js-errors
Browse files Browse the repository at this point in the history
allow to set js_errors on startup
  • Loading branch information
jcalderonzumba committed Jan 18, 2016
2 parents 5e231b4 + 03e7a87 commit 21bebb8
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 4 additions & 2 deletions docs/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ This statement can change in the future but that will require all clients to upg

##Start the Browser and the API
```bash
phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768 2>&1 >> /tmp/gastonjs.log &
phantomjs --ssl-protocol=any --ignore-ssl-errors=true vendor/jcalderonzumba/gastonjs/src/Client/main.js 8510 1024 768 false 2>&1 >> /tmp/gastonjs.log &
```
This will start a phantomjs process and the API listening on the 8510 port, the 1024x768 parameters are the width and height you want the browser to use. You can start the API on the port you want 8510 is just an example.
This will start a phantomjs process and the API listening on the 8510 port, the 1024x768 parameters are the width and
height you want the browser to use. The "false" argument is about [JavaScript errors](commands/javascript/set_js_errors.md),
if omitted it'll be "true" by default. You can start the API on the port you want, 8510 is just an example.

##API endpoint
Your client can start making HTTP POST requests to `http://localhost:8510/v1/api`
Expand Down
5 changes: 3 additions & 2 deletions src/Client/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ Poltergeist.Browser = (function () {
* @param owner
* @param width
* @param height
* @param jsErrors
* @constructor
*/
function Browser(owner, width, height) {
function Browser(owner, width, height, jsErrors) {
this.owner = owner;
this.width = width || 1024;
this.height = height || 768;
this.pages = [];
this.js_errors = true;
this.js_errors = (typeof jsErrors === 'boolean') ? jsErrors : true;
this._debug = false;
this._counter = 0;
this.resetPage();
Expand Down
2 changes: 1 addition & 1 deletion src/Client/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ phantom.injectJs("" + phantom.libraryPath + "/browser.js");

system = require('system');

new Poltergeist(system.args[1], system.args[2], system.args[3]);
new Poltergeist(system.args[1], system.args[2], system.args[3], system.args[4] === 'false' ? false : true);
5 changes: 3 additions & 2 deletions src/Client/poltergeist.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ Poltergeist = (function () {
* @param port
* @param width
* @param height
* @param jsErrors
* @constructor
*/
function Poltergeist(port, width, height) {
function Poltergeist(port, width, height, jsErrors) {
var self;
this.browser = new Poltergeist.Browser(this, width, height);
this.browser = new Poltergeist.Browser(this, width, height, jsErrors);

this.commandServer = new Poltergeist.Server(this, port);
this.commandServer.start();
Expand Down

0 comments on commit 21bebb8

Please sign in to comment.