Index: chrome/test/data/webui/cr_elements/cr_dialog_test.js |
diff --git a/chrome/test/data/webui/cr_elements/cr_dialog_test.js b/chrome/test/data/webui/cr_elements/cr_dialog_test.js |
index 062211dab7a69851e671a22d5af59beb846ca37f..662386298da49a77298781b31c88021b6d176d0d 100644 |
--- a/chrome/test/data/webui/cr_elements/cr_dialog_test.js |
+++ b/chrome/test/data/webui/cr_elements/cr_dialog_test.js |
@@ -69,6 +69,36 @@ suite('cr-dialog', function() { |
assertEquals(1, clickedCounter); |
}); |
+ test('enter ignores hidden and disabled action buttons', function() { |
+ document.body.innerHTML = ` |
+ <dialog is="cr-dialog"> |
+ <div class="title">title</div> |
+ <div class="body"> |
+ <button id="hidden" class="action-button" hidden>hidden</button> |
+ <button class="action-button" disabled>disabled</button> |
+ <button class="action-button" disabled hidden>disabled hidden</button> |
+ <button id="active" class="action-button">active</button> |
+ </div> |
+ </dialog>`; |
+ |
+ var dialog = document.body.querySelector('dialog'); |
+ var hiddenButton = document.body.querySelector('#hidden'); |
+ var actionButton = document.body.querySelector('#active'); |
+ dialog.showModal(); |
+ |
+ // MockInteractions triggers event listeners synchronously. |
+ hiddenButton.addEventListener('click', function() { |
+ throw new Error('Hidden button received a click.'); |
dpapad
2017/04/04 17:10:17
Nit: Can we use assertNotReached() instead? We act
tommycli
2017/04/04 17:44:11
Done. And I can confirm this fails the test if I r
|
+ }) |
+ var clicked = false; |
+ actionButton.addEventListener('click', function() { |
+ clicked = true; |
+ }); |
+ |
+ MockInteractions.keyEventOn(dialog, 'keypress', 13, undefined, 'Enter'); |
+ assertTrue(clicked); |
+ }); |
+ |
test('focuses [autofocus] instead of title when present', function() { |
document.body.innerHTML = ` |
<dialog is="cr-dialog"> |