mirror of
https://github.com/teampoltergeist/poltergeist.git
synced 2022-11-09 12:05:00 -05:00
We'll have to implement features provided by capybara >= 2.3
This commit is contained in:
parent
b7271f286b
commit
9387c8919a
6 changed files with 78 additions and 87 deletions
|
@ -174,20 +174,19 @@ PoltergeistAgent.Node = (function() {
|
|||
};
|
||||
|
||||
Node.prototype.isObsolete = function() {
|
||||
var obsolete;
|
||||
obsolete = (function(_this) {
|
||||
return function(element) {
|
||||
if (element.parentNode != null) {
|
||||
if (element.parentNode === document) {
|
||||
return false;
|
||||
} else {
|
||||
return obsolete(element.parentNode);
|
||||
}
|
||||
var obsolete,
|
||||
_this = this;
|
||||
obsolete = function(element) {
|
||||
if (element.parentNode != null) {
|
||||
if (element.parentNode === document) {
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
return obsolete(element.parentNode);
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return obsolete(this.element);
|
||||
};
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ Poltergeist.Browser = (function() {
|
|||
}
|
||||
|
||||
Browser.prototype.resetPage = function() {
|
||||
var _this = this;
|
||||
if (this.page != null) {
|
||||
this.page.release();
|
||||
phantom.clearCookies();
|
||||
|
@ -21,52 +22,42 @@ Poltergeist.Browser = (function() {
|
|||
width: this.width,
|
||||
height: this.height
|
||||
});
|
||||
this.page.onLoadStarted = (function(_this) {
|
||||
return function() {
|
||||
if (_this.state === 'mouse_event') {
|
||||
return _this.setState('loading');
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
this.page.onNavigationRequested = (function(_this) {
|
||||
return function(url, navigation) {
|
||||
if (_this.state === 'mouse_event' && navigation === 'FormSubmitted') {
|
||||
return _this.setState('loading');
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
this.page.onLoadFinished = (function(_this) {
|
||||
return function(status) {
|
||||
if (_this.state === 'loading') {
|
||||
_this.sendResponse({
|
||||
status: status,
|
||||
position: _this.last_mouse_event
|
||||
});
|
||||
return _this.setState('default');
|
||||
} else if (_this.state === 'awaiting_frame_load') {
|
||||
_this.sendResponse(true);
|
||||
return _this.setState('default');
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
this.page.onInitialized = (function(_this) {
|
||||
return function() {
|
||||
return _this.page_id += 1;
|
||||
};
|
||||
})(this);
|
||||
return this.page.onPageCreated = (function(_this) {
|
||||
return function(sub_page) {
|
||||
var name;
|
||||
if (_this.state === 'awaiting_sub_page') {
|
||||
name = _this.page_name;
|
||||
_this.page_name = null;
|
||||
_this.setState('default');
|
||||
return setTimeout((function() {
|
||||
return _this.push_window(name);
|
||||
}), 0);
|
||||
}
|
||||
};
|
||||
})(this);
|
||||
this.page.onLoadStarted = function() {
|
||||
if (_this.state === 'mouse_event') {
|
||||
return _this.setState('loading');
|
||||
}
|
||||
};
|
||||
this.page.onNavigationRequested = function(url, navigation) {
|
||||
if (_this.state === 'mouse_event' && navigation === 'FormSubmitted') {
|
||||
return _this.setState('loading');
|
||||
}
|
||||
};
|
||||
this.page.onLoadFinished = function(status) {
|
||||
if (_this.state === 'loading') {
|
||||
_this.sendResponse({
|
||||
status: status,
|
||||
position: _this.last_mouse_event
|
||||
});
|
||||
return _this.setState('default');
|
||||
} else if (_this.state === 'awaiting_frame_load') {
|
||||
_this.sendResponse(true);
|
||||
return _this.setState('default');
|
||||
}
|
||||
};
|
||||
this.page.onInitialized = function() {
|
||||
return _this.page_id += 1;
|
||||
};
|
||||
return this.page.onPageCreated = function(sub_page) {
|
||||
var name;
|
||||
if (_this.state === 'awaiting_sub_page') {
|
||||
name = _this.page_name;
|
||||
_this.page_name = null;
|
||||
_this.setState('default');
|
||||
return setTimeout((function() {
|
||||
return _this.push_window(name);
|
||||
}), 0);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Browser.prototype.runCommand = function(name, args) {
|
||||
|
@ -224,6 +215,7 @@ Poltergeist.Browser = (function() {
|
|||
};
|
||||
|
||||
Browser.prototype.push_frame = function(name, timeout) {
|
||||
var _this = this;
|
||||
if (timeout == null) {
|
||||
timeout = new Date().getTime() + 2000;
|
||||
}
|
||||
|
@ -235,11 +227,9 @@ Poltergeist.Browser = (function() {
|
|||
}
|
||||
} else {
|
||||
if (new Date().getTime() < timeout) {
|
||||
return setTimeout(((function(_this) {
|
||||
return function() {
|
||||
return _this.push_frame(name, timeout);
|
||||
};
|
||||
})(this)), 50);
|
||||
return setTimeout((function() {
|
||||
return _this.push_frame(name, timeout);
|
||||
}), 50);
|
||||
} else {
|
||||
return this.owner.sendError(new Poltergeist.FrameNotFound(name));
|
||||
}
|
||||
|
@ -255,16 +245,15 @@ Poltergeist.Browser = (function() {
|
|||
};
|
||||
|
||||
Browser.prototype.push_window = function(name) {
|
||||
var sub_page;
|
||||
var sub_page,
|
||||
_this = this;
|
||||
sub_page = this.page.getPage(name);
|
||||
if (sub_page) {
|
||||
if (sub_page.currentUrl() === 'about:blank') {
|
||||
return sub_page.onLoadFinished = (function(_this) {
|
||||
return function() {
|
||||
sub_page.onLoadFinished = null;
|
||||
return _this.push_window(name);
|
||||
};
|
||||
})(this);
|
||||
return sub_page.onLoadFinished = function() {
|
||||
sub_page.onLoadFinished = null;
|
||||
return _this.push_window(name);
|
||||
};
|
||||
} else {
|
||||
this.page_stack.push(this.page);
|
||||
this.page = sub_page;
|
||||
|
@ -287,18 +276,17 @@ Poltergeist.Browser = (function() {
|
|||
};
|
||||
|
||||
Browser.prototype.mouse_event = function(page_id, id, name) {
|
||||
var node;
|
||||
var node,
|
||||
_this = this;
|
||||
node = this.node(page_id, id);
|
||||
this.setState('mouse_event');
|
||||
this.last_mouse_event = node.mouseEvent(name);
|
||||
return setTimeout((function(_this) {
|
||||
return function() {
|
||||
if (_this.state !== 'loading') {
|
||||
_this.setState('default');
|
||||
return _this.sendResponse(_this.last_mouse_event);
|
||||
}
|
||||
};
|
||||
})(this), 5);
|
||||
return setTimeout(function() {
|
||||
if (_this.state !== 'loading') {
|
||||
_this.setState('default');
|
||||
return _this.sendResponse(_this.last_mouse_event);
|
||||
}
|
||||
}, 5);
|
||||
};
|
||||
|
||||
Browser.prototype.click = function(page_id, id) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
var Poltergeist,
|
||||
var Poltergeist, _ref, _ref1,
|
||||
__hasProp = {}.hasOwnProperty,
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
|
@ -68,7 +68,8 @@ Poltergeist.ObsoleteNode = (function(_super) {
|
|||
__extends(ObsoleteNode, _super);
|
||||
|
||||
function ObsoleteNode() {
|
||||
return ObsoleteNode.__super__.constructor.apply(this, arguments);
|
||||
_ref = ObsoleteNode.__super__.constructor.apply(this, arguments);
|
||||
return _ref;
|
||||
}
|
||||
|
||||
ObsoleteNode.prototype.name = "Poltergeist.ObsoleteNode";
|
||||
|
@ -178,7 +179,8 @@ Poltergeist.StatusFailError = (function(_super) {
|
|||
__extends(StatusFailError, _super);
|
||||
|
||||
function StatusFailError() {
|
||||
return StatusFailError.__super__.constructor.apply(this, arguments);
|
||||
_ref1 = StatusFailError.__super__.constructor.apply(this, arguments);
|
||||
return _ref1;
|
||||
}
|
||||
|
||||
StatusFailError.prototype.name = "Poltergeist.StatusFailError";
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
var __slice = [].slice;
|
||||
|
||||
Poltergeist.Node = (function() {
|
||||
var name, _fn, _i, _len, _ref;
|
||||
var name, _fn, _i, _len, _ref,
|
||||
_this = this;
|
||||
|
||||
Node.DELEGATES = ['allText', 'visibleText', 'getAttribute', 'value', 'set', 'setAttribute', 'isObsolete', 'removeAttribute', 'isMultiple', 'select', 'tagName', 'find', 'getAttributes', 'isVisible', 'position', 'trigger', 'parentId', 'parentIds', 'mouseEventTest', 'scrollIntoView', 'isDOMEqual', 'isDisabled', 'deleteText', 'containsSelection'];
|
||||
|
||||
|
@ -68,4 +69,4 @@ Poltergeist.Node = (function() {
|
|||
|
||||
return Node;
|
||||
|
||||
})();
|
||||
}).call(this);
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
var __slice = [].slice;
|
||||
|
||||
Poltergeist.WebPage = (function() {
|
||||
var command, delegate, _fn, _fn1, _i, _j, _len, _len1, _ref, _ref1;
|
||||
var command, delegate, _fn, _fn1, _i, _j, _len, _len1, _ref, _ref1,
|
||||
_this = this;
|
||||
|
||||
WebPage.CALLBACKS = ['onAlert', 'onConsoleMessage', 'onLoadFinished', 'onInitialized', 'onLoadStarted', 'onResourceRequested', 'onResourceReceived', 'onError', 'onNavigationRequested', 'onUrlChanged', 'onPageCreated'];
|
||||
|
||||
|
@ -414,4 +415,4 @@ Poltergeist.WebPage = (function() {
|
|||
|
||||
return WebPage;
|
||||
|
||||
})();
|
||||
}).call(this);
|
||||
|
|
|
@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|||
|
||||
s.required_ruby_version = '>= 1.9.3'
|
||||
|
||||
s.add_dependency 'capybara', '~> 2.1'
|
||||
s.add_dependency 'capybara', '~> 2.1', '< 2.3'
|
||||
s.add_dependency 'websocket-driver', '>= 0.2.0'
|
||||
s.add_dependency 'multi_json', '~> 1.0'
|
||||
s.add_dependency 'cliver', '~> 0.3.1'
|
||||
|
|
Loading…
Reference in a new issue