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

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

Issue 2700063002: MD Settings: focus header when dialog shows to signal to AT what's going on (Closed)
Patch Set: dpapad@ review Created 3 years, 10 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
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
new file mode 100644
index 0000000000000000000000000000000000000000..fa617c543d471d8521e8107352035dd3501bd0a0
--- /dev/null
+++ b/chrome/test/data/webui/cr_elements/cr_dialog_test.js
@@ -0,0 +1,41 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
dpapad 2017/02/24 20:46:10 Nit: 2017
Dan Beam 2017/02/24 22:08:31 Acknowledged.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+suite('cr-dialog', function() {
+ setup(function() {
+ PolymerTest.clearBody();
+ });
+
+ test('focuses title on show', function() {
+ document.body.innerHTML = `
+ <dialog is="cr-dialog">
+ <div class="title">title</div>
+ <div class="body"><button>button</button></div>
+ </dialog>`;
+
+ assertFalse(document.activeElement.matches('div.title'));
+ assertFalse(document.activeElement.matches('button'));
+
+ document.body.querySelector('dialog').showModal();
+
+ expectTrue(document.activeElement.matches('div.title'));
dpapad 2017/02/24 20:46:10 I am not asking you to replace expects with assert
Dan Beam 2017/02/24 22:08:31 they're different.
+ expectFalse(document.activeElement.matches('button'));
+ });
+
+ test('focuses [autofocus] instead of title when present', function() {
+ document.body.innerHTML = `
+ <dialog is="cr-dialog">
+ <div class="title">title</div>
+ <div class="body"><button autofocus>button</button></div>
+ </dialog>`;
+
+ assertFalse(document.activeElement.matches('button'));
+ assertFalse(document.activeElement.matches('div.title'));
+
+ document.body.querySelector('dialog').showModal();
+
+ expectTrue(document.activeElement.matches('button'));
+ expectFalse(document.activeElement.matches('div.title'));
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698