lib/capybara/poltergeist/client/compiled/browser.js in poltergeist-0.1.0 vs lib/capybara/poltergeist/client/compiled/browser.js in poltergeist-0.2.0
- old
+ new
@@ -72,11 +72,11 @@
};
Browser.prototype.evaluate = function(script) {
return this.owner.sendResponse(this.page.evaluate("function() { return " + script + " }"));
};
Browser.prototype.execute = function(script) {
- this.page.execute("function() { return " + script + " }");
+ this.page.execute("function() { " + script + " }");
return this.owner.sendResponse(true);
};
Browser.prototype.push_frame = function(id) {
this.page.pushFrame(id);
return this.owner.sendResponse(true);
@@ -84,20 +84,23 @@
Browser.prototype.pop_frame = function() {
this.page.popFrame();
return this.owner.sendResponse(true);
};
Browser.prototype.click = function(id) {
+ var load_detected;
+ load_detected = false;
this.page.onLoadStarted = __bind(function() {
- return this.awaiting_response = true;
+ this.awaiting_response = true;
+ return load_detected = true;
}, this);
this.page.get(id).click();
return setTimeout(__bind(function() {
this.page.onLoadStarted = null;
- if (!this.awaiting_response) {
+ if (!load_detected) {
return this.owner.sendResponse(true);
}
- }, this), 0);
+ }, this), 10);
};
Browser.prototype.drag = function(id, other_id) {
this.page.get(id).dragTo(this.page.get(other_id));
return this.owner.sendResponse(true);
};
@@ -107,11 +110,49 @@
};
Browser.prototype.reset = function() {
this.resetPage();
return this.owner.sendResponse(true);
};
- Browser.prototype.render = function(path) {
- this.page.render(path);
+ Browser.prototype.render = function(path, full) {
+ var dimensions, document, viewport;
+ dimensions = this.page.validatedDimensions();
+ document = dimensions.document;
+ viewport = dimensions.viewport;
+ if (full) {
+ this.page.setScrollPosition({
+ left: 0,
+ top: 0
+ });
+ this.page.setClipRect({
+ left: 0,
+ top: 0,
+ width: document.width,
+ height: document.height
+ });
+ this.page.render(path);
+ this.page.setScrollPosition({
+ left: dimensions.left,
+ top: dimensions.top
+ });
+ } else {
+ this.page.setClipRect({
+ left: 0,
+ top: 0,
+ width: viewport.width,
+ height: viewport.height
+ });
+ this.page.render(path);
+ }
return this.owner.sendResponse(true);
+ };
+ Browser.prototype.resize = function(width, height) {
+ this.page.setViewportSize({
+ width: width,
+ height: height
+ });
+ return this.owner.sendResponse(true);
+ };
+ Browser.prototype.exit = function() {
+ return phantom.exit();
};
return Browser;
})();
\ No newline at end of file