Skip to content

Commit a64220f

Browse files
committed
[Add] add render timeout
1 parent ac6e2f3 commit a64220f

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

index.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,11 @@ function mergeSettings(settings){
164164
}
165165
},
166166
render: {
167-
format: 'jpeg', // @see http://phantomjs.org/api/webpage/method/render.html
168-
quality: 80, // @see http://phantomjs.org/api/webpage/method/render.html
169-
ext: 'jpg', // the same as format, if not specified
170-
delay: 1000 // delay(ms) before screenshot.
167+
format: 'jpeg', // @see http://phantomjs.org/api/webpage/method/render.html
168+
quality: 80, // @see http://phantomjs.org/api/webpage/method/render.html
169+
ext: 'jpg', // the same as format, if not specified
170+
delay: 1000, // delay(ms) before screenshot.
171+
timeout: 30 * 1000 // render timeout, max waiting time
171172
},
172173
path: {
173174
root: DEFAULT_DATA_DIRNAME, // data and screenshot save path root

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "page-monitor",
3-
"version": "0.4.0",
3+
"version": "0.4.1",
44
"description": "monitor pages and diff the dom change with phantomjs",
55
"main": "index.js",
66
"scripts": {

phantomjs/index.js

+7
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ function createPage(url, options, onload){
178178
}
179179
};
180180
page.open(url);
181+
if(options.render.timeout){
182+
setTimeout(function(){
183+
clearTimeout(timer);
184+
callback = function(){};
185+
onload(page);
186+
}, options.render.timeout);
187+
}
181188
return page;
182189
}
183190

0 commit comments

Comments
 (0)