diff --git a/CHANGELOG.md b/CHANGELOG.md index 8d3fe5e9..9a09adb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,15 +4,23 @@ - Support time inputs [#245] - Add initial support for shadow_root [#234] - Support `Capybara::Cuprite::Node#rect` [#276] +- Extend `Node#set` with the `datetime-local` input type [#295] +- Support HTML5 drag-and-drop and drag modifier keys in `Node#drag_to` [#315] +- Support `Element#drop` for files and strings [#316] ### Changed +- Bump Ferrum dependency to `~> 0.18.0` ### Fixed -- Ensure node has focus before setting value [#280] +- Ensure the node has focus before setting value [#280] - Raise `ObsoleteNode` instead of silently acting on a node that got disconnected from the DOM between being found and being used [#239] - `Capybara::Cuprite::Node#send_keys` ignores empty or nil keys instead of raising, matching the Selenium and rack_test drivers [#313] +- `Driver#switch_to_frame` accepts a `Capybara::Cuprite::Node` instead of only a wrapped `Capybara::Node::Element` [#312] +- Report `tag_name` as `"ShadowRoot"` for shadow root nodes [#318] +- Treat non-summary descendants of a closed `
` element as non-visible [#317] - `switch_to_window` sends `Target.activateTarget` so Chrome reactivates the window's renderer immediately instead of leaving it backgrounded, which could stall the next input command for several seconds [#321] - `Node#set` fires `input` and `change` events for a `color` input, since its value can only be set via JavaScript and never gets them naturally [#229] +- Generate a `FocusEvent` (not a generic `Event`) for focus-related events (`blur`, `focus`, `focusin`, `focusout`), matching real browser behavior [#272] ### Removed diff --git a/lib/capybara/cuprite/javascripts/index.js b/lib/capybara/cuprite/javascripts/index.js index 7c3d3b8a..092c0226 100644 --- a/lib/capybara/cuprite/javascripts/index.js +++ b/lib/capybara/cuprite/javascripts/index.js @@ -464,7 +464,7 @@ class Cuprite { options["button"] || 0, null ) } else if (EVENTS.FOCUS.indexOf(name) != -1) { - event = this.obtainEvent(name); + event = new FocusEvent(name, { bubbles: true, cancelable: true }); } else if (EVENTS.FORM.indexOf(name) != -1) { event = this.obtainEvent(name); } else { diff --git a/spec/features/session_spec.rb b/spec/features/session_spec.rb index d21f5c34..209c3261 100644 --- a/spec/features/session_spec.rb +++ b/spec/features/session_spec.rb @@ -227,11 +227,11 @@ end it "fires the focus event" do - expect(@session.find(:css, "#changes_on_focus").text).to eq("Focus") + expect(@session.find(:css, "#changes_on_focus").text).to eq("Focus (FocusEvent)") end it "fires the blur event" do - expect(@session.find(:css, "#changes_on_blur").text).to eq("Blur") + expect(@session.find(:css, "#changes_on_blur").text).to eq("Blur (FocusEvent)") end it "fires the keydown event before the value is updated" do diff --git a/spec/support/public/test.js b/spec/support/public/test.js index 6dc31950..4a275ee2 100644 --- a/spec/support/public/test.js +++ b/spec/support/public/test.js @@ -28,10 +28,10 @@ $(function() { $("#changes_on_keypress").text(increment) }) .focus(function(event) { - $("#changes_on_focus").text("Focus") + $("#changes_on_focus").text(`Focus (${event.originalEvent.constructor.name})`) }) - .blur(function() { - $("#changes_on_blur").text("Blur") + .blur(function(event) { + $("#changes_on_blur").text(`Blur (${event.originalEvent.constructor.name})`) }) $("#change_me_color")