|
15 | 15 | <dialog closedby="closerequest" data-behavior="closerequest"></dialog>
|
16 | 16 | <dialog closedby="none" data-behavior="none"></dialog>
|
17 | 17 |
|
18 |
| -<dialog closedby data-behavior="closerequest"></dialog> |
19 |
| -<dialog closedby="invalid" data-behavior="closerequest"></dialog> |
20 |
| -<dialog data-behavior="closerequest"></dialog> |
21 |
| - |
22 | 18 | <dialog closedby="AnY" data-behavior="any"></dialog>
|
23 | 19 | <dialog closedby="ClOsErEqUeSt" data-behavior="closerequest"></dialog>
|
24 | 20 | <dialog closedby="NoNe" data-behavior="none"></dialog>
|
25 | 21 |
|
| 22 | +<dialog closedby="invalid" data-behavior="auto"></dialog> |
| 23 | +<dialog closedby data-behavior="auto"></dialog> |
| 24 | +<dialog data-behavior="auto"></dialog> |
| 25 | + |
26 | 26 | <script>
|
27 | 27 | function openDialog(dialog,modal) {
|
28 | 28 | assert_false(dialog.open);
|
|
41 | 41 | t.add_cleanup(() => dialog.close());
|
42 | 42 | // Try hitting ESC
|
43 | 43 | openDialog(dialog,modal);
|
| 44 | + const closedByReflectionWhileOpen = dialog.closedBy; |
44 | 45 | const ESC = '\uE00C';
|
45 | 46 | await new test_driver.send_keys(document.documentElement,ESC);
|
46 | 47 | const respondsToEsc = !dialog.open;
|
|
51 | 52 | const respondsToLightDismiss = !dialog.open;
|
52 | 53 | dialog.close();
|
53 | 54 | // See if expectations match
|
| 55 | + let expectedReflectionWhileOpen = dialog.dataset.behavior; |
| 56 | + let expectedReflectionWhileClosed = dialog.dataset.behavior; |
54 | 57 | switch (dialog.dataset.behavior) {
|
55 | 58 | case 'any':
|
56 | 59 | assert_true(respondsToEsc,'Dialog should respond to ESC');
|
|
64 | 67 | assert_false(respondsToEsc,'Dialog should NOT respond to ESC');
|
65 | 68 | assert_false(respondsToLightDismiss,'Dialog should NOT respond to light dismiss');
|
66 | 69 | break;
|
| 70 | + case 'auto': |
| 71 | + if (modal) { |
| 72 | + assert_true(respondsToEsc,'Modal dialog in auto state should respond to ESC'); |
| 73 | + assert_false(respondsToLightDismiss,'Modal dialog in auto state should NOT respond to light dismiss'); |
| 74 | + expectedReflectionWhileOpen = 'closerequest'; |
| 75 | + } else { |
| 76 | + assert_false(respondsToEsc,'Non-modal dialog in auto state should NOT respond to ESC'); |
| 77 | + assert_false(respondsToLightDismiss,'Non-modal dialog in auto state should NOT respond to light dismiss'); |
| 78 | + expectedReflectionWhileOpen = 'none'; |
| 79 | + } |
| 80 | + expectedReflectionWhileClosed = 'none'; |
| 81 | + break; |
67 | 82 | default:
|
68 | 83 | assert_notreached('Invalid expectation');
|
69 | 84 | }
|
70 | 85 | // Check reflection
|
71 |
| - assert_equals(dialog.closedBy,dialog.dataset.behavior,'Reflection should be limited to known values'); |
| 86 | + assert_equals(closedByReflectionWhileOpen,expectedReflectionWhileOpen,'Reflection should be limited to known values (open)'); |
| 87 | + assert_equals(dialog.closedBy,expectedReflectionWhileClosed,'Reflection should be limited to known values (closed)'); |
72 | 88 | }, `closedby=${dialog.getAttribute('closedby')}, ${modal ? 'Modal' : 'Non-modal'}`);
|
73 | 89 | }
|
74 | 90 | }
|
|
0 commit comments