alexscheelmeyer / node-phantom

bridge to PhantomJS from Node.js
317 stars 117 forks source link

page.includeJs callback does not fire #50

Closed mr-mig closed 11 years ago

mr-mig commented 11 years ago
//initialize phantom and page
page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', function (err, res) {
  console.log("included");
})

I use the provided code snippet to debug the includeJs output. It works when launched by phantomjs itself, but it does not work when used via node-phantom.

It seems that in bridge.js the respond is not called in pageIncludeJs case. Maybe the respond funciton is not seen in the controlpage context?

Nodejs: 0.10.4 node-phantom: 0.2.3 phantomjs: 1.9.0

alexscheelmeyer commented 11 years ago

This works fine for me with PhantomJS 1.8.1. Could be related to API changes in v 1.9?

alexscheelmeyer commented 11 years ago

Have you checked for security violation errors? Seems that PhantomJS might be more strict regarding cross domain requests in later versions. See : http://stackoverflow.com/questions/15847123/on-phantomjs-cant-include-jquery-and-without-jquery-cant-post-form-data

mr-mig commented 11 years ago

How can I check the errors in phantomjs using the wrapper?

The problem is that when I use the same code running phantomjs testfile.js it evaluates and loads jQuery. Actually, I've tried this wrapper api with "local" scripts (I deliver them from localhost, so the url is smth like http://localhost:3000/statis/somescript.js) with no success either.

alexscheelmeyer commented 11 years ago

Local urls will probably not help with cross domain security issues.

If you follow the stackoverflow path one guy mentions that you should listen for onConsoleMessage. You should be able to listen for that callback with the wrapper.

mr-mig commented 11 years ago

Thanks for pointing out the page.onConsoleMessage and page.onError callbacks. I think it would be great if you add them explicitly in Readme.md. Today the stars are in the right position and page.includeJs works fine. I don't know what I was doing wrong, but is is not an issue, so I close it.