lib/capybara/poltergeist/client/browser.coffee in poltergeist-1.2.0 vs lib/capybara/poltergeist/client/browser.coffee in poltergeist-1.3.0

- old
+ new

@@ -24,11 +24,11 @@ @page.onNavigationRequested = (url, navigation) => this.setState 'loading' if @state == 'mouse_event' && navigation == 'FormSubmitted' @page.onLoadFinished = (status) => if @state == 'loading' - this.sendResponse(status: status, click: @last_click) + this.sendResponse(status: status, position: @last_mouse_event) this.setState 'default' else if @state == 'awaiting_frame_load' this.sendResponse(true) this.setState 'default' @@ -45,15 +45,20 @@ # At this point subpage isn't fully initialized, so we can't check # its name. Instead, we just schedule another attempt to push the # window. setTimeout((=> this.push_window(name)), 0) + runCommand: (name, args) -> + this.setState "default" + this[name].apply(this, args) + debug: (message) -> if @_debug console.log "poltergeist [#{new Date().getTime()}] #{message}" setState: (state) -> + return if @state == state this.debug "state #{@state} -> #{state}" @state = state sendResponse: (response) -> errors = @page.errors() @@ -276,9 +281,13 @@ phantom.addCookie(cookie) this.sendResponse(true) remove_cookie: (name) -> @page.deleteCookie(name) + this.sendResponse(true) + + cookies_enabled: (flag) -> + phantom.cookiesEnabled = flag this.sendResponse(true) set_js_errors: (value) -> @js_errors = value this.sendResponse(true)