Commit 60020675 600206752e83b66e46bec66977640db9ee75b63f by Laurent Jouanneau

Refs #482: casper.viewport should wait after repaint

Since setting the viewport forces a redraw of the
rendering, in an asynchronous manner, it should wait a bit of time.
At least SlimerJS needs this delay to redraw its window.
1 parent 1d02ae71
......@@ -1892,12 +1892,22 @@ Casper.prototype.viewport = function viewport(width, height, then) {
if (!utils.isNumber(width) || !utils.isNumber(height) || width <= 0 || height <= 0) {
throw new CasperError(f("Invalid viewport: %dx%d", width, height));
}
this.page.viewportSize = {
width: width,
height: height
};
this.emit('viewport.changed', [width, height]);
return utils.isFunction(then) ? this.then(then) : this;
return this.then(function _step() {
this.waitStart();
setTimeout(function _check(self) {
self.waitDone();
self.emit('viewport.changed', [width, height]);
if (utils.isFunction(then)){
self.then(then);
}
}, 300, this);
});
};
/**
......