lib/capybara/poltergeist/client/browser.coffee in poltergeist-1.8.1 vs lib/capybara/poltergeist/client/browser.coffee in poltergeist-1.9.0

- old
+ new

@@ -80,12 +80,11 @@ if @currentPage.id == page_id @currentPage.get(id) else throw new Poltergeist.ObsoleteNode - visit: (url) -> - + visit: (url, max_wait=0) -> @currentPage.state = 'loading' #reset modal processing state when changing page @processed_modal_messages = [] @confirm_processes = [] @prompt_responses = [] @@ -107,10 +106,15 @@ @currentPage.waitState 'default', => if @currentPage.statusCode == null && @currentPage.status == 'fail' command.sendError(new Poltergeist.StatusFailError(url)) else command.sendResponse(status: @currentPage.status) + , max_wait, => + resources = @currentPage.openResourceRequests() + msg = if resources.length + "Timed out with the following resources still waiting #{@currentPage.openResourceRequests().join(',')}" + command.sendError(new Poltergeist.StatusFailError(url,msg)) return current_url: -> @current_command.sendResponse @currentPage.currentUrl() @@ -167,12 +171,12 @@ node = this.node(page_id, id) @currentPage.beforeUpload(node.id) @currentPage.uploadFile('[_poltergeist_selected]', value) @currentPage.afterUpload(node.id) - if phantom.version.major == 2 - # In phantomjs 2 - uploadFile only fully works if executed within a user action + if phantom.version.major == 2 && phantom.version.minor == 0 + # In phantomjs 2.0.x - uploadFile only fully works if executed within a user action # It does however setup the filenames to be uploaded, so if we then click on the # file input element the filenames will get set @click(page_id, id) else @current_command.sendResponse(true) @@ -478,9 +482,13 @@ @currentPage.goForward() @currentPage.waitState 'default', => command.sendResponse(true) else command.sendResponse(false) + + set_url_whitelist: -> + @currentPage.urlWhitelist = Array.prototype.slice.call(arguments) + @current_command.sendResponse(true) set_url_blacklist: -> @currentPage.urlBlacklist = Array.prototype.slice.call(arguments) @current_command.sendResponse(true)