Skip to content

Commit 66f3e56

Browse files
joshbruningsevaseva
authored andcommitted
Update select_test.html for Chrome 45.
Update tests to reflect that Chrome 45+ no longer incorrectly fires a 'change' event in 4 tests. Signed-off-by: Seva Lotoshnikov <[email protected]>
1 parent a8b05b5 commit 66f3e56

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

javascript/atoms/test/select_test.html

+18-10
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,25 @@
360360

361361
action(elem);
362362

363-
// WebKit and IE9 standards mode fire change events when the
364-
// checkbox isn't toggled.
365-
assertChanges(
366-
goog.userAgent.WEBKIT || bot.userAgent.IE_DOC_9 ? 1 : 0);
363+
// Some browsers fire change events when the checkbox isn't toggled.
364+
assertChanges(firesChangeEventIfNotToggled() ? 1 : 0);
367365
assertFalse(bot.dom.isSelected(elem));
368366
}
369367

368+
function firesChangeEventIfNotToggled() {
369+
if (goog.userAgent.product.CHROME && bot.userAgent.isProductVersion(45)) {
370+
// Chrome 45 and above do not fire the change event.
371+
return false;
372+
} else if (goog.userAgent.WEBKIT || bot.userAgent.IE_DOC_9) {
373+
// Other browsers with goog.userAgent.WEBKIT fire the change event.
374+
// IE 9 standards mode fires the change event.
375+
return true;
376+
}
377+
378+
// All other browsers do not fire the change event.
379+
return false;
380+
}
381+
370382
var testClickCannotSelectCheckboxWhenDefaultPrevented =
371383
goog.partial(cannotSelectCheckboxWhenDefaultPrevented,
372384
bot.action.click);
@@ -394,12 +406,8 @@
394406
assertChanges(1);
395407
assertTrue(bot.dom.isSelected(elem));
396408
} else {
397-
// IE9 standards mode and Chrome still fire the change event.
398-
if (bot.userAgent.IE_DOC_9 || goog.userAgent.product.CHROME) {
399-
assertChanges(1);
400-
} else {
401-
assertChanges(0);
402-
}
409+
// Some browsers fire change events when the checkbox isn't toggled.
410+
assertChanges(firesChangeEventIfNotToggled() ? 1 : 0);
403411
assertFalse(bot.dom.isSelected(elem));
404412
}
405413
}

0 commit comments

Comments
 (0)