Permalink
Browse files

changed deprecated page.release to page.close. Also changed check to …

…avoid phantomjs crash in onResourceRequested
  • Loading branch information...
1 parent d06102b commit 65eec2f28e25b1b6ac2794e3c7b9b63374b1c3ce @alexscheelmeyer committed Feb 1, 2013
Showing with 11 additions and 11 deletions.
  1. +7 −7 bridge.js
  2. +3 −3 node-phantom.js
  3. +1 −1 test/testpagerelease.js
View
14 bridge.js
@@ -17,14 +17,14 @@ function setupPushNotifications(id, page) {
var callbacks=['onAlert','onConfirm','onConsoleMessage','onError','onInitialized','onLoadFinished',
'onLoadStarted','onPrompt','onResourceRequested','onResourceReceived','onUrlChanged',
'onCallback'];
- function push(notification) {
+ function push(notification){
controlpage.evaluate('function(){socket.emit("push",'+JSON.stringify(notification)+');}');
}
callbacks.forEach(function(cb) {
- page[cb]=function(){
+ page[cb]=function(parm){
var notification=Array.prototype.slice.call(arguments);
- var str=JSON.stringify(notification);
- if(str.length>436)return;
+ if((cb==='onResourceRequested')&&(parm.url.indexOf('data:image')===0)) return;
+
push([id, cb, notification]);
};
})
@@ -74,9 +74,9 @@ controlpage.onAlert=function(msg){
respond([id, cmdId, 'pageOpened', status]);
});
break;
- case 'pageRelease':
- page.release();
- respond([id,cmdId,'pageReleased']);
+ case 'pageClose':
+ page.close();
+ respond([id,cmdId,'pageClosed']);
break;
case 'pageInjectJs':
var result=page.injectJs(request[3]);
View
6 node-phantom.js
@@ -90,8 +90,8 @@ module.exports={
request(socket, [id, 'pageOpenWithCallback', url], callback);
}
},
- release:function(callback){
- request(socket,[id,'pageRelease'],callbackOrDummy(callback));
+ close:function(callback){
+ request(socket,[id,'pageClose'],callbackOrDummy(callback));
},
render:function(filename,callback){
request(socket,[id,'pageRender',filename],callbackOrDummy(callback));
@@ -157,7 +157,7 @@ module.exports={
cmds[cmdId].cb(null,JSON.parse(response[3]));
delete cmds[cmdId];
break;
- case 'pageReleased':
+ case 'pageClosed':
delete pages[id]; // fallthru
case 'pageSetDone':
case 'pageJsIncluded':
View
2 test/testpagerelease.js
@@ -5,7 +5,7 @@ exports.testPhantomPageRelease=function(beforeExit,assert){
assert.ifError(error);
ph.createPage(function(err,page){
assert.ifError(err);
- page.release(function(err){
+ page.close(function(err){
assert.ifError(err);
ph.exit();
});

0 comments on commit 65eec2f

Please sign in to comment.