pointer-event-has-persistentdeviceid-from-pointer-event-init.tentative.html (2226B)
1 <!DOCTYPE html> 2 <!-- 3 Tentative; contingent on merge of: 4 https://github.com/w3c/pointerevents/pull/495 5 --> 6 <script src="/resources/testharness.js"></script> 7 <script src="/resources/testharnessreport.js"></script> 8 <div id="console"></div> 9 10 <!-- This test verifies that pointerEvent.persistentDeviceId 11 can be set via PointerEventInit. --> 12 <script> 13 const PERSISTENT_ID = 1001; 14 const INVALID_PERSISTENT_ID = 0; 15 16 function CheckDeviceId(event, persistentDeviceId) { 17 assert_equals(event.persistentDeviceId, persistentDeviceId, "persistentDeviceId is populated"); 18 } 19 20 promise_test(async () => { 21 var deviceId = PERSISTENT_ID; 22 var downEvent = new PointerEvent("pointerdown", 23 {pointerId: 1, 24 bubbles: true, 25 cancelable: true, 26 pointerType: "pen", 27 width: 100, 28 height: 100, 29 isPrimary: true, 30 persistentDeviceId: deviceId 31 }); 32 CheckDeviceId(downEvent, PERSISTENT_ID); 33 var moveEvent = new PointerEvent("pointermove", 34 {pointerId: 1, 35 bubbles: true, 36 cancelable: true, 37 pointerType: "pen", 38 width: 100, 39 height: 100, 40 isPrimary: true, 41 persistentDeviceId: deviceId 42 }); 43 CheckDeviceId(moveEvent, PERSISTENT_ID); 44 var upEvent = new PointerEvent("pointerup", 45 {pointerId: 1, 46 bubbles: true, 47 cancelable: true, 48 pointerType: "pen", 49 width: 100, 50 height: 100, 51 isPrimary: true, 52 persistentDeviceId: deviceId 53 }); 54 CheckDeviceId(upEvent, PERSISTENT_ID); 55 }, 'PointerEvent.persistentDeviceId via PointerEventInit'); 56 57 promise_test(async () => { 58 var downEventEmptyProps = new PointerEvent("pointerdown", 59 {pointerId: 1, 60 bubbles: true, 61 cancelable: true, 62 pointerType: "pen", 63 width: 100, 64 height: 100, 65 isPrimary: true, 66 }); 67 assert_equals(downEventEmptyProps.persistentDeviceId, INVALID_PERSISTENT_ID); 68 }, 'No persistentDeviceId in PointerEventInit'); 69 </script>