Skip to content

Commit

Permalink
Make sure the fix doesn't break IE
Browse files Browse the repository at this point in the history
Changed bot.action.clear so it still explicitly raise Blur event on IE.
Modified test case testClearingANonEmptyElement to assert blur event is
raised exactly once after bot.action.clear is called.

Signed-off-by: Alexei Barantsev <barancev@gmail.com>
  • Loading branch information
JohnChen0 authored and barancev committed Apr 28, 2019
1 parent 127b282 commit 87efe1b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
3 changes: 3 additions & 0 deletions javascript/atoms/action.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ bot.action.clear = function(element) {
element.value = '';
}
bot.events.fire(element, bot.events.EventType.CHANGE);
if (goog.userAgent.IE) {
bot.events.fire(element, bot.events.EventType.BLUR);
}
var body = bot.getDocument().body;
if (body) {
bot.action.LegacyDevice_.focusOnElement(body);
Expand Down
8 changes: 8 additions & 0 deletions javascript/atoms/test/action_test.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
});
}

var expectBlurEvent = goog.partial(expectEvent,
goog.events.EventType.BLUR);

var expectChangeEvent = goog.partial(expectEvent,
goog.events.EventType.CHANGE);

Expand All @@ -68,6 +71,9 @@
count, counts[eventType]);
}

var assertBlurFired = goog.partial(assertEventFired,
goog.events.EventType.BLUR);

var assertChangeFired = goog.partial(assertEventFired,
goog.events.EventType.CHANGE);

Expand Down Expand Up @@ -113,8 +119,10 @@
e.value = 'foobar';
e.disabled = false;
e.readOnly = false;
expectBlurEvent(e);
expectChangeEvent(e);
bot.action.clear(e);
assertBlurFired();
assertChangeFired();
assertEquals('', e.value);
});
Expand Down

0 comments on commit 87efe1b

Please sign in to comment.