Commit b98f5284 authored by Liviu Tinta's avatar Liviu Tinta Committed by Commit Bot

Fix flaky pointermove on chorded buttons when locked test

Pointer lock is acquired and released asynchronously. Remove
reliance on timeout from the test by waiting until lock is
properly acquired/released during the test steps.

Bug: 1025944
Change-Id: Ibd5b1c19efb9c00794f1b900e12a5f5a4edab16e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2360494Reviewed-by: default avatarMustaq Ahmed <mustaq@chromium.org>
Commit-Queue: Liviu Tinta <liviutinta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#800553}
parent b9ad0302
...@@ -6568,7 +6568,6 @@ crbug.com/1098067 [ Fuchsia ] virtual/text-antialias/bidi-isolate-nextlinebreak- ...@@ -6568,7 +6568,6 @@ crbug.com/1098067 [ Fuchsia ] virtual/text-antialias/bidi-isolate-nextlinebreak-
# Sheriff 2020-06-23 # Sheriff 2020-06-23
crbug.com/1098136 [ Linux ] virtual/android/fullscreen/video-fixed-background.html [ Failure ] crbug.com/1098136 [ Linux ] virtual/android/fullscreen/video-fixed-background.html [ Failure ]
crbug.com/1025944 [ Linux ] external/wpt/pointerevents/pointerlock/pointerevent_pointermove_on_chorded_mouse_button_when_locked.html [ Pass Failure ]
# Sheriff 2020-06-24 # Sheriff 2020-06-24
crbug.com/1098676 [ Win ] http/tests/devtools/console-xhr-logging.js [ Pass Failure ] crbug.com/1098676 [ Win ] http/tests/devtools/console-xhr-logging.js [ Pass Failure ]
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
var firstButton = 0; var firstButton = 0;
var pointer_locked = false; var pointer_locked = false;
function run() { async function run() {
var target0 = document.getElementById("target0"); var target0 = document.getElementById("target0");
// When a pointer changes button state and the circumstances produce no other pointer event, the pointermove event must be dispatched. // When a pointer changes button state and the circumstances produce no other pointer event, the pointermove event must be dispatched.
...@@ -44,7 +44,9 @@ ...@@ -44,7 +44,9 @@
on_event(target0, "pointerdown", function (event) { on_event(target0, "pointerdown", function (event) {
if (pointer_locked) { if (pointer_locked) {
detected_pointertypes[event.pointerType] = true; detected_pointertypes[event.pointerType] = true;
test_pointermove.step(function() {assert_true(step === 0, "There must not be more than one pointer down event.");}); test_pointermove.step(function() {
assert_true(step === 0, "There must not be more than one pointer down event.");
});
if (step == 0) { if (step == 0) {
step = 1; step = 1;
firstButton = event.buttons; firstButton = event.buttons;
...@@ -56,11 +58,17 @@ ...@@ -56,11 +58,17 @@
detected_pointertypes[event.pointerType] = true; detected_pointertypes[event.pointerType] = true;
if (step == 1 && event.button != -1) { // second button pressed if (step == 1 && event.button != -1) { // second button pressed
test_pointermove.step(function() {assert_true(event.buttons !== firstButton, "The pointermove event must be triggered by pressing a second button.");}); test_pointermove.step(function() {
test_pointermove.step(function() {assert_true((event.buttons & firstButton) != 0, "The first button must still be reported pressed.");}); assert_true(event.buttons !== firstButton, "The pointermove event must be triggered by pressing a second button.");
});
test_pointermove.step(function() {
assert_true((event.buttons & firstButton) != 0, "The first button must still be reported pressed.");
});
step = 2; step = 2;
} else if (step == 2 && event.button != -1) { // second button released } else if (step == 2 && event.button != -1) { // second button released
test_pointermove.step(function() {assert_true(event.buttons === firstButton, "The pointermove event must be triggered by releasing the second button.");}); test_pointermove.step(function() {
assert_true(event.buttons === firstButton, "The pointermove event must be triggered by releasing the second button.");
});
step = 3; step = 3;
} }
} }
...@@ -68,14 +76,13 @@ ...@@ -68,14 +76,13 @@
on_event(target0, "pointerup", function (event) { on_event(target0, "pointerup", function (event) {
if (pointer_locked) { if (pointer_locked) {
detected_pointertypes[event.pointerType] = true; detected_pointertypes[event.pointerType] = true;
step_timeout(function() { test_pointermove.step(function() {
test_pointermove.step(function() {assert_true(step === 3, "The pointerup event must be triggered after pressing and releasing the second button.");}); assert_true(step === 3, "The pointerup event must be triggered after pressing and releasing the second button.");
test_pointermove.step(function() {assert_true(event.buttons === 0, "The pointerup event must be triggered by releasing the last pressed button.");}); });
document.exitPointerLock(); test_pointermove.step(function() {
actions_promise.then( () => { assert_true(event.buttons === 0, "The pointerup event must be triggered by releasing the last pressed button.");
test_pointermove.done(); });
}); document.exitPointerLock();
}, 500);
} else { } else {
target0.requestPointerLock(); target0.requestPointerLock();
} }
...@@ -83,8 +90,12 @@ ...@@ -83,8 +90,12 @@
on_event(document, 'pointerlockchange', function(event) { on_event(document, 'pointerlockchange', function(event) {
if (document.pointerLockElement == target0) if (document.pointerLockElement == target0)
pointer_locked = true; pointer_locked = true;
else else{
pointer_locked = false; pointer_locked = false;
actions_promise.then( () => {
test_pointermove.done();
});
}
}); });
on_event(target0, "mouseup", function (event) { on_event(target0, "mouseup", function (event) {
event.preventDefault(); event.preventDefault();
...@@ -95,9 +106,16 @@ ...@@ -95,9 +106,16 @@
// Inject mouse input // Inject mouse input
var actions = new test_driver.Actions(); var actions = new test_driver.Actions();
actions_promise = actions.pointerMove(0, 0, {origin: target0}) actions_promise = actions
.pointerMove(0, 0, {origin: target0})
.pointerDown({button: actions.ButtonType.LEFT}) .pointerDown({button: actions.ButtonType.LEFT})
.pointerUp({button: actions.ButtonType.LEFT}) .pointerUp({button: actions.ButtonType.LEFT})
.send();
await actions_promise;
await resolveWhen(()=>pointer_locked);
actions = new test_driver.Actions();
actions_promise = actions
.pointerMove(0, 0, {origin: target0})
.pointerDown({button: actions.ButtonType.LEFT}) .pointerDown({button: actions.ButtonType.LEFT})
.pointerDown({button: actions.ButtonType.MIDDLE}) .pointerDown({button: actions.ButtonType.MIDDLE})
.pointerUp({button: actions.ButtonType.MIDDLE}) .pointerUp({button: actions.ButtonType.MIDDLE})
......
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