Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/capybara/cuprite/javascripts/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,8 @@ class Cuprite {
options["button"] || 0, null
)
} else if (EVENTS.FOCUS.indexOf(name) != -1) {
event = this.obtainEvent(name);
event = document.createEvent("FocusEvent");
event.initEvent(name, true, true);
} else if (EVENTS.FORM.indexOf(name) != -1) {
event = this.obtainEvent(name);
} else {
Expand Down
4 changes: 2 additions & 2 deletions spec/features/session_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,11 +200,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
Expand Down
6 changes: 3 additions & 3 deletions spec/support/public/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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})`)
Copy link
Author

@davidrunger davidrunger Aug 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like tests to cover the change in this PR, so I added the event constructor name in parentheses here. On main, this text would be Focus (Event). On this branch, it's Focus (FocusEvent).

})
.blur(function() {
$("#changes_on_blur").text("Blur")
.blur(function(event) {
$("#changes_on_blur").text(`Blur (${event.originalEvent.constructor.name})`)
})

$("#browser")
Expand Down
Loading