lib/capybara/poltergeist/client/compiled/agent.js in poltergeist-1.0.3 vs lib/capybara/poltergeist/client/compiled/agent.js in poltergeist-1.1.0

- old
+ new

@@ -81,10 +81,18 @@ throw new PoltergeistAgent.ObsoleteNode; } return node[name].apply(node, args); }; + PoltergeistAgent.prototype.beforeUpload = function(id) { + return this.get(id).setAttribute('_poltergeist_selected', ''); + }; + + PoltergeistAgent.prototype.afterUpload = function(id) { + return this.get(id).removeAttribute('_poltergeist_selected'); + }; + return PoltergeistAgent; })(); PoltergeistAgent.ObsoleteNode = (function() { @@ -221,24 +229,42 @@ } else { return true; } }; + Node.prototype.frameOffset = function() { + var offset, rect, win; + win = window; + offset = { + top: 0, + left: 0 + }; + while (win.frameElement) { + rect = window.frameElement.getClientRects()[0]; + win = win.parent; + offset.top += rect.top; + offset.left += rect.left; + } + return offset; + }; + Node.prototype.position = function() { - var rect; + var frameOffset, pos, rect; rect = this.element.getClientRects()[0]; if (!rect) { throw new PoltergeistAgent.ObsoleteNode; } - return { - top: rect.top, - right: rect.right, - left: rect.left, - bottom: rect.bottom, + frameOffset = this.frameOffset(); + pos = { + top: rect.top + frameOffset.top, + right: rect.right + frameOffset.left, + left: rect.left + frameOffset.left, + bottom: rect.bottom + frameOffset.top, width: rect.width, height: rect.height }; + return pos; }; Node.prototype.trigger = function(name) { var event; if (Node.EVENTS.MOUSE.indexOf(name) !== -1) { @@ -261,10 +287,13 @@ Node.prototype.blur = function() { return this.element.blur(); }; Node.prototype.clickTest = function(x, y) { - var el, origEl; + var el, frameOffset, origEl; + frameOffset = this.frameOffset(); + x -= frameOffset.left; + y -= frameOffset.top; el = origEl = document.elementFromPoint(x, y); while (el) { if (el === this.element) { return { status: 'success'