Commit 50b853d1 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Simulate user inputs in focus-events/focus.html, fix event order.

Use testdriver Action API to simulate mouse actions in
uievents/order-of-events/focus-events/focus.html.

This test now matches major browser implementations that "focus"
preceeds "focusin", and "blur" preceeds "focusout".  See:
    https://github.com/w3c/uievents/issues/276.

Bug: 1145677
Change-Id: I9e5965c90a18560cce560b73a3df88d0e840473d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2519193Reviewed-by: default avatarMustaq Ahmed <mustaq@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827515}
parent ba04a73c
......@@ -1794,9 +1794,6 @@ crbug.com/472330 fast/borders/border-image-outset-split-inline-vertical-lr.html
crbug.com/472330 fast/writing-mode/box-shadow-vertical-lr.html [ Failure ]
crbug.com/472330 fast/writing-mode/box-shadow-vertical-rl.html [ Failure ]
# These are the failing tests because Chrome hasn't implemented according to the spec.
crbug.com/645988 external/wpt/uievents/order-of-events/focus-events/focus-manual.html [ Failure ]
crbug.com/346473 fast/events/drag-on-mouse-move-cancelled.html [ Failure ]
# These tests are skipped as there is no touch support on Mac.
......
......@@ -5,10 +5,12 @@
<title>Focus-related events should fire in the correct order</title>
<link rel="author" title="Chris Rebert" href="http://chrisrebert.com">
<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>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
</head>
<body>
......@@ -40,7 +42,9 @@ var relevantEvents = [
window.onload = function () {
var a = document.getElementById("a");
var b = document.getElementById("b");
var button = document.getElementById("done");
var inputs = [a, b];
var actions_promise;
EventRecorder.configure({
objectMap: {
"a": a,
......@@ -50,25 +54,41 @@ window.onload = function () {
EventRecorder.addEventListenersForNodes(relevantEvents, inputs, stopPropagation);
var expected = [
{type: "focusin", target: "a"},
{type: "focus", target: "a"},
{type: "focusout", target: "a"},
{type: "focusin", target: "b"},
{type: "focusin", target: "a"},
{type: "blur", target: "a"},
{type: "focusout", target: "a"},
{type: "focus", target: "b"},
{type: "focusout", target: "b"},
{type: "blur", target: "b"}
{type: "focusin", target: "b"},
{type: "blur", target: "b"},
{type: "focusout", target: "b"}
];
async_test(function(t) {
document.getElementById("done").addEventListener("click", function () {
button.addEventListener("click", function () {
t.step(function () {
assert_true(EventRecorder.checkRecords(expected));
// Make sure the test finishes after all the input actions are completed.
actions_promise.then( () => {
t.done();
});
});
}, false);
}, "Focus-related events should fire in the correct order");
EventRecorder.start();
// Inject mouse inputs.
actions_promise = new test_driver.Actions()
.pointerMove(0, 0, {origin: a})
.pointerDown()
.pointerUp()
.pointerMove(0, 0, {origin: b})
.pointerDown()
.pointerUp()
.pointerMove(0, 0, {origin: button})
.pointerDown()
.pointerUp()
.send();
};
</script>
</html>
importAutomationScript('/pointerevents/pointerevent_common_input.js');
function inject_input() {
return mouseClickInTarget('#a').then(function() {
return mouseClickInTarget('#b');
}).then(function() {
return mouseClickInTarget('#done');
});
}
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment