mirror of
https://github.com/servo/servo.git
synced 2025-08-10 07:55:33 +01:00
Test for double focus events (covers #11665)
This commit is contained in:
parent
7d978e7b3d
commit
2c35233638
2 changed files with 82 additions and 0 deletions
|
@ -6310,6 +6310,12 @@
|
||||||
"url": "/_mozilla/mozilla/document_url.html"
|
"url": "/_mozilla/mozilla/document_url.html"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
"mozilla/double_focus.html": [
|
||||||
|
{
|
||||||
|
"path": "mozilla/double_focus.html",
|
||||||
|
"url": "/_mozilla/mozilla/double_focus.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"mozilla/element_attribute.html": [
|
"mozilla/element_attribute.html": [
|
||||||
{
|
{
|
||||||
"path": "mozilla/element_attribute.html",
|
"path": "mozilla/element_attribute.html",
|
||||||
|
|
76
tests/wpt/mozilla/tests/mozilla/double_focus.html
Normal file
76
tests/wpt/mozilla/tests/mozilla/double_focus.html
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Double focus/blur events</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<input>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
|
||||||
|
async_test(function(t) {
|
||||||
|
|
||||||
|
var input = document.querySelector("input");
|
||||||
|
|
||||||
|
var actions = [
|
||||||
|
input.focus,
|
||||||
|
input.focus,
|
||||||
|
input.blur,
|
||||||
|
input.blur,
|
||||||
|
input.focus,
|
||||||
|
input.focus,
|
||||||
|
input.blur,
|
||||||
|
input.blur,
|
||||||
|
input.focus,
|
||||||
|
];
|
||||||
|
|
||||||
|
var expected_events = [
|
||||||
|
"focus",
|
||||||
|
"blur",
|
||||||
|
"focus",
|
||||||
|
"blur",
|
||||||
|
"focus",
|
||||||
|
];
|
||||||
|
|
||||||
|
var received_events = [];
|
||||||
|
|
||||||
|
var action_idx = 0;
|
||||||
|
|
||||||
|
var onEvent = t.step_func(function(e) {
|
||||||
|
received_events.push(e.type);
|
||||||
|
if (action_idx == actions.length - 1) {
|
||||||
|
// All actions executed
|
||||||
|
assert_array_equals(expected_events, received_events);
|
||||||
|
t.done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function next() {
|
||||||
|
actions[action_idx].apply(input);
|
||||||
|
action_idx++;
|
||||||
|
if (action_idx < actions.length) {
|
||||||
|
// This can't be done on focus or blur events
|
||||||
|
// as we don't expect focus() to trigger a focus
|
||||||
|
// event if the input was already focused.
|
||||||
|
setTimeout(next, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
input.addEventListener("focus", onEvent, false);
|
||||||
|
input.addEventListener("blur", onEvent, false);
|
||||||
|
|
||||||
|
next();
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Add table
Add a link
Reference in a new issue