Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(9038)

Unified Diff: chrome/test/data/webui/cr_elements/cr_dialog_test.js

Issue 2792853003: WebUI: For cr-dialog, make Enter key ignore disabled or hidden buttons (Closed)
Patch Set: Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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">
« no previous file with comments | « no previous file | ui/webui/resources/cr_elements/cr_dialog/cr_dialog.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698