Source code
Revision control
Copy as Markdown
Other Tools
Test Info: Warnings
- This test has a WPT meta file that expects 1 subtest issues.
- This WPT test may be referenced by the following Test IDs:
- /pointerevents/pointerevent_auxclick_is_a_pointerevent.html?mouse - WPT Dashboard Interop Dashboard
- /pointerevents/pointerevent_auxclick_is_a_pointerevent.html?pen - WPT Dashboard Interop Dashboard
<!DOCTYPE HTML>
<title>auxclick is a PointerEvent</title>
<meta name="variant" content="?mouse">
<meta name="variant" content="?pen">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="pointerevent_support.js"></script>
<input id="target" style="margin: 20px">
<script>
'use strict';
let target = document.getElementById("target");
let pointerId = 0;
let pointerType = "";
let inputSource = location.search.substring(1);
target.addEventListener("pointerdown", (e)=>{
pointerId = e.pointerId;
pointerType = e.pointerType;
});
function testFunction(test){
return test.step_func(e=>{
assert_equals(e.constructor, window.PointerEvent,
"auxclick should use a PointerEvent constructor");
assert_true(e instanceof PointerEvent,
"auxclick should be a PointerEvent");
assert_equals(e.pointerId, pointerId,
"auxclick's pointerId should match the pointerId of the pointer event that triggers it");
assert_equals(e.pointerType, pointerType,
"auxclick's pointerType should match the pointerType of the pointer event that triggers it");
assert_equals(e.composed, true, "auxclick.composed should be true");
});
}
function run_test(pointerType){
promise_test((test) => new Promise((resolve, reject) => {
const testPointer = pointerType + "TestPointer";
let auxclickFunc = testFunction(test);
test.add_cleanup(() => {
target.removeEventListener("auxclick", auxclickFunc);
pointerId = 0;
pointerType = "";
});
let pointerDownPrevented = preventDefaultPointerdownOnce(target);
target.addEventListener("auxclick", auxclickFunc);
let eventWatcher = new EventWatcher(test, target, ["auxclick"]);
let actions = new test_driver.Actions();
actions = actions
.addPointer(testPointer, pointerType)
.pointerMove(0,0, {origin:target, sourceName:testPointer})
.pointerDown({button:actions.ButtonType.MIDDLE, sourceName:testPointer})
.pointerUp({button:actions.ButtonType.MIDDLE, sourceName:testPointer});
Promise.all([
pointerDownPrevented,
eventWatcher.wait_for("auxclick"),
actions.send()
]).then(()=>resolve());
}), "auxclick using " + pointerType + " is a PointerEvent");
}
run_test(inputSource);
// TODO(crbug.com/1150441): Add test for auxclick from touch. Note: Calling
// run_test("touch") here times out.
</script>