Skip to content

Commit

Permalink
Bug 1728343 [wpt PR 30257] - Reland "Populate pointerId, pointerType …
Browse files Browse the repository at this point in the history
…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 <liviutinta@chromium.org>
> Reviewed-by: Robert Flack <flackr@chromium.org>
> 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 <mustaq@chromium.org>
Reviewed-by: Robert Flack <flackr@chromium.org>
Commit-Queue: Liviu Tinta <liviutinta@chromium.org>
Cr-Commit-Position: refs/heads/main@{#917671}

--

wpt-commits: 69a086eab1e1b4d01c815b5e2b6cb75a30d8571f
wpt-pr: 30257
  • Loading branch information
liviutinta authored and moz-wptsync-bot committed Sep 4, 2021
1 parent 29239c8 commit 28e39ec
Showing 1 changed file with 17 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<!DOCTYPE HTML>
<title>contexmenu is a PointerEvent</title>
<meta name="variant" content="?mouse">
<meta name="variant" content="?touch">
<link rel="help" href="https://github.com/w3c/pointerevents/pull/317">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
Expand All @@ -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());
</script>

0 comments on commit 28e39ec

Please sign in to comment.