Bug 1659586 [wpt PR 25057] - Fix flaky pointermove on chorded buttons when locked test, a=testonly
authorLiviu Tinta <liviutinta@chromium.org>
Wed, 26 Aug 2020 08:54:38 +0000
changeset 546493 213d8449eeaacdc83bf5c5db0192858b66e8f46a
parent 546492 e99d52ed05de4bd5fb563dd4386fe51697b5a165
child 546494 1279bd47fd7d095ec4f2ddcf65b94adc8e820e31
push id37735
push userabutkovits@mozilla.com
push dateThu, 27 Aug 2020 21:29:40 +0000
treeherdermozilla-central@109f3a4de567 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstestonly
bugs1659586, 25057, 1025944, 2360494, 800553
milestone82.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1659586 [wpt PR 25057] - Fix flaky pointermove on chorded buttons when locked test, a=testonly Automatic update from web-platform-tests 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/+/2360494 Reviewed-by: Mustaq Ahmed <mustaq@chromium.org> Commit-Queue: Liviu Tinta <liviutinta@chromium.org> Cr-Commit-Position: refs/heads/master@{#800553} -- wpt-commits: 036f979463508b074bd145bb9d7d9582c675f2b9 wpt-pr: 25057
testing/web-platform/tests/pointerevents/pointerlock/pointerevent_pointermove_on_chorded_mouse_button_when_locked.html
--- a/testing/web-platform/tests/pointerevents/pointerlock/pointerevent_pointermove_on_chorded_mouse_button_when_locked.html
+++ b/testing/web-platform/tests/pointerevents/pointerlock/pointerevent_pointermove_on_chorded_mouse_button_when_locked.html
@@ -30,79 +30,97 @@
             var test_pointermove = async_test("pointer locked pointermove events received for button state changes");
             add_completion_callback(showPointerTypes);
             var actions_promise;
 
             var step = 0;
             var firstButton = 0;
             var pointer_locked = false;
 
-            function run() {
+            async function run() {
                 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.
                 // 5.2.6
 
                 on_event(target0, "pointerdown", function (event) {
                     if (pointer_locked) {
                         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) {
                             step = 1;
                             firstButton = event.buttons;
                         }
                     }
                 });
                 on_event(target0, "pointermove", function (event) {
                     if (pointer_locked) {
                         detected_pointertypes[event.pointerType] = true;
 
                         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() {assert_true((event.buttons & firstButton) != 0, "The first button must still be reported 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() {
+                                assert_true((event.buttons & firstButton) != 0, "The first button must still be reported pressed.");
+                            });
                             step = 2;
                         } 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;
                         }
                     }
                 });
                 on_event(target0, "pointerup", function (event) {
                     if (pointer_locked) {
                         detected_pointertypes[event.pointerType] = true;
-                        step_timeout(function() {
-                            test_pointermove.step(function() {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();
-                            actions_promise.then( () => {
-                                test_pointermove.done();
-                            });
-                        }, 500);
+                        test_pointermove.step(function() {
+                            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();
                     } else {
                         target0.requestPointerLock();
                     }
                 });
                 on_event(document, 'pointerlockchange', function(event) {
                     if (document.pointerLockElement == target0)
                         pointer_locked = true;
-                    else
+                    else{
                         pointer_locked = false;
+                        actions_promise.then( () => {
+                           test_pointermove.done();
+                        });
+                    }
                 });
                 on_event(target0, "mouseup", function (event) {
                     event.preventDefault();
                 });
                 on_event(target0, "contextmenu", function (event) {
                     event.preventDefault();
                 });
 
                 // Inject mouse input
                 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})
                        .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.MIDDLE})
                        .pointerUp({button: actions.ButtonType.MIDDLE})
                        .pointerUp({button: actions.ButtonType.LEFT})
                        .send();
             }
         </script>
         <h1>Pointer Lock Pointer Events pointermove on button state changes Tests</h1>