Skip to content
This repository
Browse code

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

…avoid phantomjs crash in onResourceRequested
  • Loading branch information...
commit 65eec2f28e25b1b6ac2794e3c7b9b63374b1c3ce 1 parent d06102b
alexscheelmeyer authored

Showing 3 changed files with 11 additions and 11 deletions. Show diff stats Hide diff stats

  1. +7 7 bridge.js
  2. +3 3 node-phantom.js
  3. +1 1  test/testpagerelease.js
14 bridge.js
@@ -17,14 +17,14 @@ function setupPushNotifications(id, page) {
17 17 var callbacks=['onAlert','onConfirm','onConsoleMessage','onError','onInitialized','onLoadFinished',
18 18 'onLoadStarted','onPrompt','onResourceRequested','onResourceReceived','onUrlChanged',
19 19 'onCallback'];
20   - function push(notification) {
  20 + function push(notification){
21 21 controlpage.evaluate('function(){socket.emit("push",'+JSON.stringify(notification)+');}');
22 22 }
23 23 callbacks.forEach(function(cb) {
24   - page[cb]=function(){
  24 + page[cb]=function(parm){
25 25 var notification=Array.prototype.slice.call(arguments);
26   - var str=JSON.stringify(notification);
27   - if(str.length>436)return;
  26 + if((cb==='onResourceRequested')&&(parm.url.indexOf('data:image')===0)) return;
  27 +
28 28 push([id, cb, notification]);
29 29 };
30 30 })
@@ -74,9 +74,9 @@ controlpage.onAlert=function(msg){
74 74 respond([id, cmdId, 'pageOpened', status]);
75 75 });
76 76 break;
77   - case 'pageRelease':
78   - page.release();
79   - respond([id,cmdId,'pageReleased']);
  77 + case 'pageClose':
  78 + page.close();
  79 + respond([id,cmdId,'pageClosed']);
80 80 break;
81 81 case 'pageInjectJs':
82 82 var result=page.injectJs(request[3]);
6 node-phantom.js
@@ -90,8 +90,8 @@ module.exports={
90 90 request(socket, [id, 'pageOpenWithCallback', url], callback);
91 91 }
92 92 },
93   - release:function(callback){
94   - request(socket,[id,'pageRelease'],callbackOrDummy(callback));
  93 + close:function(callback){
  94 + request(socket,[id,'pageClose'],callbackOrDummy(callback));
95 95 },
96 96 render:function(filename,callback){
97 97 request(socket,[id,'pageRender',filename],callbackOrDummy(callback));
@@ -157,7 +157,7 @@ module.exports={
157 157 cmds[cmdId].cb(null,JSON.parse(response[3]));
158 158 delete cmds[cmdId];
159 159 break;
160   - case 'pageReleased':
  160 + case 'pageClosed':
161 161 delete pages[id]; // fallthru
162 162 case 'pageSetDone':
163 163 case 'pageJsIncluded':
2  test/testpagerelease.js
@@ -5,7 +5,7 @@ exports.testPhantomPageRelease=function(beforeExit,assert){
5 5 assert.ifError(error);
6 6 ph.createPage(function(err,page){
7 7 assert.ifError(err);
8   - page.release(function(err){
  8 + page.close(function(err){
9 9 assert.ifError(err);
10 10 ph.exit();
11 11 });

0 comments on commit 65eec2f

Please sign in to comment.
Something went wrong with that request. Please try again.