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

Unified Diff: LayoutTests/fast/dom/HTMLDialogElement/show-modal-focusing-steps.html

Issue 112553002: Implement new focusing steps for modal <dialog>. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: drop inert ancestors change Created 7 years 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 | LayoutTests/fast/dom/HTMLDialogElement/show-modal-focusing-steps-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/HTMLDialogElement/show-modal-focusing-steps.html
diff --git a/LayoutTests/fast/dom/HTMLDialogElement/show-modal-focusing-steps.html b/LayoutTests/fast/dom/HTMLDialogElement/show-modal-focusing-steps.html
new file mode 100644
index 0000000000000000000000000000000000000000..d09e80d2f5bb152fe00a74f0657fa09b4638ebd1
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLDialogElement/show-modal-focusing-steps.html
@@ -0,0 +1,63 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+<script>
+description('Tests focus when a modal dialog is opened.');
+
+function test()
+{
+ outerButton = document.getElementById('outer-button');
+ shouldBe('document.activeElement', 'outerButton');
+
+ debug('Test that focus goes to body if the dialog has no focusable elements, including itself');
+ var outerDialog = document.getElementById('outer-dialog');
+ outerDialog.showModal();
+ shouldBe('document.activeElement', 'document.body');
+
+ debug('Test that an autofocus element in the dialog gets focus.');
+ var dialog = document.getElementById('dialog');
+ dialog.showModal();
+ autofocusButton = document.getElementById('autofocus-button');
+ shouldBe('document.activeElement', 'autofocusButton');
+ dialog.close();
+
+ debug('... or else first focusable element in the dialog gets focus.');
+ autofocusButton.parentNode.removeChild(autofocusButton);
+ dialog.showModal();
+ firstButton = document.getElementById('first-button');
+ shouldBe('document.activeElement', 'firstButton');
+ dialog.close();
+
+ debug('... or else the dialog itself gets focus.');
+ var buttons = dialog.querySelectorAll('button');
+ for (var i = 0; i < buttons.length; ++i)
+ buttons[i].hidden = true;
+ dialog.showModal();
+ shouldBe('document.activeElement', 'dialog');
+ dialog.close();
+
+ document.getElementById('outer-dialog').close();
+ finishJSTest();
+}
+</script>
+</head>
+<body onload="test();">
+<button id="outer-button" autofocus></button>
+<dialog id="outer-dialog">
+ <dialog id="dialog" tabindex=0>
+ <button disabled></button>
+ <dialog>
+ <button autofocus></button>
+ </dialog>
+ <button id="first-button"></button>
+ <div>
+ <span>
+ <button id="autofocus-button" autofocus></button>
+ </span>
+ </div>
+ <button id="final-button"></button>
+ </dialog>
+</dialog>
+</body>
+</html>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLDialogElement/show-modal-focusing-steps-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698