From d8283beebde4128e1884084943e2ddb274993f8a Mon Sep 17 00:00:00 2001 From: Liviu Tinta Date: Sat, 4 Sep 2021 22:04:39 +0000 Subject: [PATCH] Bug 1728343 [wpt PR 30257] - Reland "Populate pointerId, pointerType for contextmenu event", a=testonly Automatic update from web-platform-tests Reland "Populate pointerId, pointerType for contextmenu event" This is a second reland of a6d69d5243dd02afbd8ef02e5a5c557dd8c4a9e9 I believe the reason for the test failures when this landed the first time was related to how pointerId was populated for the contextmenu pointer event. With crrev.com/c/2889205 landed, we have a robust way to associate the gesture event sequence with the corresponding pointer event sequence. This CL uses the approach in crrev.com/c/2889205 to populate the pointerId for the contextmenu pointer event. The reason this didn't reland at first, is because there is a difference between the gesture sequences generated by run_web_tests.py and wpt runner. See crbug.com/1245118. Until crbug.com/1245118 is fixed, I am adding an expectation file for chrome. The other reason this didn't reland at first, is because the test pointerevent_contextmenu_is_a_pointerevent.html?touch is flaky on Mac. I am going to add it back to TestExpectations, and try to land the TestExpectations file change separately from this CL. Original change's description: > Populate pointerId, pointerType for contextmenu event > > For contextmenu as a pointer event pointerId and pointerType > were not populated. > > In this CL we are populating pointerId/pointerType for contextmenu > coming from touch and mouse. > For touch we use a similar approach to crrev.com/c/2800231 > for populating pointerId,pointerType for clicks generated in > GestureManager::HandleGestureTap. > The main change will be in EventHandler::SendContextMenuEvent > where we'll be passing id and pointer type to the call to > MouseEventManager::DispatchMouseEvent. This in turn will > populate pointerId and pointerType correctly when the contextmenu > PointerEvent is created. > > Bug: 1150442,1150441 > TEST: external/wpt/pointerevents/pointerevent_contextmenu_is_a_pointerevent.html > Change-Id: If2408d9cf0d5f00b08efcf2236ff7933472972ce > Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2874026 > Commit-Queue: Liviu Tinta > Reviewed-by: Robert Flack > Cr-Commit-Position: refs/heads/master@{#881145} Bug: 1150442,1150441,1207709,626703 Change-Id: I84cd65f80be00fa7a09c8248039c95ec05a2e1fb Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3132060 Reviewed-by: Mustaq Ahmed Reviewed-by: Robert Flack Commit-Queue: Liviu Tinta Cr-Commit-Position: refs/heads/main@{#917671} -- wpt-commits: 69a086eab1e1b4d01c815b5e2b6cb75a30d8571f wpt-pr: 30257 --- ...erevent_contextmenu_is_a_pointerevent.html | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/testing/web-platform/tests/pointerevents/pointerevent_contextmenu_is_a_pointerevent.html b/testing/web-platform/tests/pointerevents/pointerevent_contextmenu_is_a_pointerevent.html index 8a820834a3a2b..2d64a0d100844 100644 --- a/testing/web-platform/tests/pointerevents/pointerevent_contextmenu_is_a_pointerevent.html +++ b/testing/web-platform/tests/pointerevents/pointerevent_contextmenu_is_a_pointerevent.html @@ -1,5 +1,7 @@ contexmenu is a PointerEvent + + @@ -13,17 +15,28 @@ 'use strict'; let contextmenuTest = async_test("contextmenu is a PointerEvent"); let target = document.getElementById("target"); +let pointerdownPointerId, pointerdownPointerType; +let inputSource = location.search.substring(1); target.addEventListener("contextmenu", contextmenuTest.step_func((e)=>{ assert_equals(e.constructor, window.PointerEvent, "contextmenu should use a PointerEvent constructor"); assert_true(e instanceof PointerEvent, "contextmenu should be a PointerEvent"); - // TODO(crbug.com/1150441,crbug.com/1150442): Test pointerId, pointerType are properly populated from the pointer event stream + assert_equals(e.pointerId, pointerdownPointerId, "contextmenu's pointerId should match the pointerId of the pointer event that triggers it"); + assert_equals(e.pointerType, pointerdownPointerType, "contextmenu's pointerType should match the pointerType of the pointer event that triggers it"); })); +target.addEventListener("pointerdown", e=>{ + pointerdownPointerId = e.pointerId; + pointerdownPointerType = e.pointerType; +}); let eventWatcher = new EventWatcher(contextmenuTest, target, ["contextmenu"]); let actions = new test_driver.Actions(); -actions = actions.pointerMove(0,0, {origin:target}) - .pointerDown({button:actions.ButtonType.RIGHT}) - .pointerUp({button:actions.ButtonType.RIGHT}); +// TODO: We might be able to test "pen" just like "touch". +let testPointer = inputSource + "TestPointer"; +actions = actions.addPointer(testPointer, inputSource) + .pointerMove(0,0, {sourceName:testPointer, origin:target}) + .pointerDown({sourceName:testPointer, button:actions.ButtonType.RIGHT}) + .pause(inputSource === "touch" ? 1500 : 0, "pointer", {sourceName:testPointer}) + .pointerUp({sourceName:testPointer, button:actions.ButtonType.RIGHT}); Promise.all([eventWatcher.wait_for("contextmenu"), actions.send()]).then(()=>contextmenuTest.done());