Chromium Code Reviews| 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')); |
| + }); |
| +}); |