summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/interaction/focus/focus-management/focus-event-targets-simple.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/interaction/focus/focus-management/focus-event-targets-simple.html')
-rw-r--r--testing/web-platform/tests/html/interaction/focus/focus-management/focus-event-targets-simple.html33
1 files changed, 33 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/interaction/focus/focus-management/focus-event-targets-simple.html b/testing/web-platform/tests/html/interaction/focus/focus-management/focus-event-targets-simple.html
new file mode 100644
index 0000000000..ab7bcfe6d0
--- /dev/null
+++ b/testing/web-platform/tests/html/interaction/focus/focus-management/focus-event-targets-simple.html
@@ -0,0 +1,33 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>Focus events fire at correct targets in correct order in simple case</title>
+ <link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
+ <link rel="help" href="https://html.spec.whatwg.org/#focus-update-steps">
+ <link rel="help" href="https://html.spec.whatwg.org/#focus-chain">
+ <meta name="flags" content="dom">
+ <script src="/resources/testharness.js"></script>
+ <script src="/resources/testharnessreport.js"></script>
+</head>
+<body>
+ <input type="text" id="a">
+ <script>
+// Record all the focus event targets in an array.
+// Modulo special cases in the "focus update steps" algorithm,
+// this should be the same as the new focus chain, except in reverse order.
+var newFocusChainReversedNotQuite = [];
+var pushTarget = function (e) {
+ newFocusChainReversedNotQuite.push(e.target);
+};
+// Window is the root node for event dispatch per https://html.spec.whatwg.org/multipage/webappapis.html#events-and-the-window-object
+window.addEventListener('focus', pushTarget, true);// Use event capturing since focus event doesn't bubble
+var input = document.getElementById('a');
+input.focus();
+window.removeEventListener('focus', pushTarget, true);
+test(function() {
+ assert_array_equals(newFocusChainReversedNotQuite, [input], "Exactly 1 focus event should fire and its target should be the input");
+}, "Focus events fire at correct targets in correct order in simple case");
+ </script>
+</body>
+</html>