lib/capybara/poltergeist/client/agent.coffee in poltergeist-1.17.0 vs lib/capybara/poltergeist/client/agent.coffee in poltergeist-1.18.0

- old
+ new

@@ -11,12 +11,12 @@ { error: { message: error.toString(), stack: error.stack } } # Somehow PhantomJS returns all characters(brackets, etc) properly encoded # except whitespace character in pathname part of the location. This hack # is intended to fix this up. - currentUrl: -> - window.location.href.replace(/\ /g, '%20') + frameUrl: -> + window.location.href find: (method, selector, within = document) -> try if method == "xpath" xpath = document.evaluate(selector, within, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null) @@ -53,11 +53,13 @@ afterUpload: (id) -> this.get(id).removeAttribute('_poltergeist_selected') clearLocalStorage: -> - localStorage?.clear() + try + localStorage?.clear() + catch error wrapResults: (result, page_id)-> @_visitedObjects ||= []; switch when result in @_visitedObjects @@ -248,16 +250,16 @@ if @isDisabled() false else if value == false && !@element.parentNode.multiple false else - this.trigger('focus', @element.parentNode) + this.trigger('focus', {}, @element.parentNode) @element.selected = value this.changed() - this.trigger('blur', @element.parentNode) + this.trigger('blur', {}, @element.parentNode) true tagName: -> @element.tagName @@ -324,11 +326,11 @@ offset.left += rect.left + parseInt(style.getPropertyValue("padding-left"), 10) offset position: -> - # Elements inside an SVG return underfined for getClientRects??? + # Elements inside an SVG return undefined for getClientRects??? rect = @element.getClientRects()[0] || @element.getBoundingClientRect() throw new PoltergeistAgent.ObsoleteNode unless rect frameOffset = this.frameOffset() pos = { @@ -340,16 +342,22 @@ height: rect.height } pos - trigger: (name, element = @element) -> + trigger: (name, options = {}, element = @element) -> if Node.EVENTS.MOUSE.indexOf(name) != -1 event = document.createEvent('MouseEvent') event.initMouseEvent( - name, true, true, window, 0, 0, 0, 0, 0, - false, false, false, false, 0, null + name, true, true, window, 0, + options['screenX'] || 0, options['screenY'] || 0, + options['clientX'] || 0, options['clientY'] || 0, + options['ctrlKey'] || false, + options['altKey'] || false, + options['shiftKey'] || false, + options['metaKey'] || false, + options['button'] || 0, null ) else if Node.EVENTS.FOCUS.indexOf(name) != -1 event = this.obtainEvent(name) else if Node.EVENTS.FORM.indexOf(name) != -1 event = this.obtainEvent(name) @@ -435,5 +443,6 @@ document.addEventListener( 'DOMContentLoaded', -> console.log('__DOMContentLoaded') ) +console.log('__DOMContentLoaded') if document.readyState == 'complete'