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());