blob: 3f6e584d1ea3f9d34dd56d3ff1102708dc772983 [file] [log] [blame]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Focus-related events should fire in the correct order</title>
<link rel="help" href="https://w3c.github.io/uievents/#events-focusevent-event-order">
<meta name="flags" content="interact">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/uievents/resources/eventrecorder.js"></script>
</head>
<body>
<ol>
<li>Click into the text input.</li>
<li>Click just below the text input.</li>
<li>Click into the text input again.</li>
<li>Click the "Done" button.</li>
</ol>
<div id="a" tabindex="1" style="width:400px; height:300px">
<br /><br /><br />
<input type="text", id="b"></div>
</div>
<button type="button" id="done">Done</button>
</body>
<script>
setup({explicit_timeout: true});
function stopPropagation(e) {
e.stopPropagation();
}
var relevantEvents = [
"focus",
"blur",
"focusin",
"focusout"
];
window.onload = function () {
var a = document.getElementById("a");
var b = document.getElementById("b");
var inputs = [a, b];
EventRecorder.configure({
objectMap: {
"a": a,
"b": b,
}
});
EventRecorder.addEventListenersForNodes(relevantEvents, inputs, stopPropagation);
var expected = [
{type: "focusin", target: "b"},
{type: "focus", target: "b"},
{type: "focusout", target: "b"},
{type: "focusin", target: "a"},
{type: "blur", target: "b"},
{type: "focus", target: "a"},
{type: "focusout", target: "a"},
{type: "focusin", target: "b"},
{type: "blur", target: "a"},
{type: "focus", target: "b"},
{type: "focusout", target: "b"},
{type: "blur", target: "b"}
];
async_test(function(t) {
document.getElementById("done").addEventListener("click", function () {
t.step(function () {
assert_true(EventRecorder.checkRecords(expected));
t.done();
});
}, false);
}, "Focus-related events should fire in the correct order");
EventRecorder.start();
};
</script>
</html>