lib/capybara/poltergeist/client/compiled/node.js in poltergeist-1.1.2 vs lib/capybara/poltergeist/client/compiled/node.js in poltergeist-1.2.0
- old
+ new
@@ -2,11 +2,11 @@
Poltergeist.Node = (function() {
var name, _fn, _i, _len, _ref,
_this = this;
- Node.DELEGATES = ['text', 'getAttribute', 'value', 'setAttribute', 'isObsolete', 'removeAttribute', 'isMultiple', 'select', 'tagName', 'find', 'isVisible', 'position', 'trigger', 'parentId', 'clickTest', 'scrollIntoView', 'isDOMEqual', 'focusAndHighlight', 'blur'];
+ Node.DELEGATES = ['allText', 'visibleText', 'getAttribute', 'value', 'set', 'setAttribute', 'isObsolete', 'removeAttribute', 'isMultiple', 'select', 'tagName', 'find', 'isVisible', 'position', 'trigger', 'parentId', 'mouseEventTest', 'scrollIntoView', 'isDOMEqual', 'isDisabled'];
function Node(page, id) {
this.page = page;
this.id = id;
}
@@ -17,21 +17,23 @@
_ref = Node.DELEGATES;
_fn = function(name) {
return Node.prototype[name] = function() {
var args;
+
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
return this.page.nodeCall(this.id, name, args);
};
};
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
name = _ref[_i];
_fn(name);
}
- Node.prototype.clickPosition = function() {
+ Node.prototype.mouseEventPosition = function() {
var middle, pos, viewport;
+
viewport = this.page.viewportSize();
pos = this.position();
middle = function(start, end, size) {
return start + ((Math.min(end, size) - start) / 2);
};
@@ -39,43 +41,35 @@
x: middle(pos.left, pos.right, viewport.width),
y: middle(pos.top, pos.bottom, viewport.height)
};
};
- Node.prototype.click = function(event) {
+ Node.prototype.mouseEvent = function(name) {
var pos, test;
- if (event == null) {
- event = 'click';
- }
+
this.scrollIntoView();
- pos = this.clickPosition();
- test = this.clickTest(pos.x, pos.y);
+ pos = this.mouseEventPosition();
+ test = this.mouseEventTest(pos.x, pos.y);
if (test.status === 'success') {
- this.page.mouseEvent(event, pos.x, pos.y);
+ this.page.mouseEvent(name, pos.x, pos.y);
return pos;
} else {
- throw new Poltergeist.ClickFailed(test.selector, pos);
+ throw new Poltergeist.MouseEventFailed(name, test.selector, pos);
}
};
Node.prototype.dragTo = function(other) {
var otherPosition, position;
+
this.scrollIntoView();
- position = this.clickPosition();
- otherPosition = other.clickPosition();
+ position = this.mouseEventPosition();
+ otherPosition = other.mouseEventPosition();
this.page.mouseEvent('mousedown', position.x, position.y);
return this.page.mouseEvent('mouseup', otherPosition.x, otherPosition.y);
};
Node.prototype.isEqual = function(other) {
return this.page === other.page && this.isDOMEqual(other.id);
- };
-
- Node.prototype.set = function(value) {
- this.focusAndHighlight();
- this.page.sendEvent('keypress', 16777219);
- this.page.sendEvent('keypress', value.toString());
- return this.blur();
};
return Node;
}).call(this);