File: pointerevent_auxclick_is_a_pointerevent.html

package info (click to toggle)
firefox 143.0.3-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,617,328 kB
  • sloc: cpp: 7,478,492; javascript: 6,417,157; ansic: 3,720,058; python: 1,396,372; xml: 627,523; asm: 438,677; java: 186,156; sh: 63,477; makefile: 19,171; objc: 13,059; perl: 12,983; yacc: 4,583; cs: 3,846; pascal: 3,405; lex: 1,720; ruby: 1,003; exp: 762; php: 436; lisp: 258; awk: 247; sql: 66; sed: 53; csh: 10
file content (74 lines) | stat: -rw-r--r-- 3,227 bytes parent folder | download | duplicates (14)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE HTML>
<title>auxclick is a PointerEvent</title>
<meta name="variant" content="?mouse">
<meta name="variant" content="?pen">
<!-- TODO: Does any platform support auxclick with touch? -->
<link rel="help" href="https://github.com/w3c/pointerevents/pull/317">
<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';
  const target = document.getElementById("target");
  const pointer_type = location.search.substring(1);
  const test_pointer = pointer_type + "TestPointer";

  function assertAuxclickProperties(auxclick_event, pointerdown_event) {
    assert_equals(auxclick_event.constructor, window.PointerEvent,
        "auxclick should use a PointerEvent constructor");
    assert_true(auxclick_event instanceof PointerEvent,
        "auxclick should be a PointerEvent");
    assert_not_equals(auxclick_event.pointerId, -1,
        "auxclick.pointerId should not be -1");
    assert_equals(auxclick_event.pointerType, pointer_type,
        "auxclick.pointerType should match test action pointerType");
    assert_equals(auxclick_event.composed, true,
        "auxclick.composed should be true");

    if (pointerdown_event) {
      assert_equals(auxclick_event.pointerId, pointerdown_event.pointerId,
          "auxclick.pointerId should match pointerdown.pointerId");
    }
  }

  promise_test(async test => {
    let actions = new test_driver.Actions();
    actions = actions
      .addPointer(test_pointer, pointer_type)
      .pointerMove(0,0, {origin:target, sourceName:test_pointer})
      .pointerDown({button:actions.ButtonType.MIDDLE, sourceName:test_pointer})
      .pointerUp({button:actions.ButtonType.MIDDLE, sourceName:test_pointer});
    let pointerdown_prevented = preventDefaultPointerdownOnce(target, test);
    let pointerdown_promise = getEvent("pointerdown", target, test);
    let auxclick_promise = getEvent("auxclick", target, test);

    await actions.send();
    await pointerdown_prevented;
    let pointerdown_event = await pointerdown_promise;
    let auxclick_event = await auxclick_promise;

    assertAuxclickProperties(auxclick_event, pointerdown_event);
  }, "auxclick using " + pointer_type + " is a PointerEvent with correct properties");

  promise_test(async test => {
    let actions = new test_driver.Actions();
    actions = actions
      .addPointer(test_pointer, pointer_type)
      .pointerMove(0,0, {origin:target, sourceName:test_pointer})
      .pointerDown({button:actions.ButtonType.MIDDLE, sourceName:test_pointer})
      .pointerUp({button:actions.ButtonType.MIDDLE, sourceName:test_pointer});
    let auxclick_promise = getEvent("auxclick", target, test);

    await actions.send();
    let auxclick_event = await auxclick_promise;

    assertAuxclickProperties(auxclick_event);
  }, "auxclick using " + pointer_type + " is a PointerEvent with correct properties"
      + " when no other PointerEvent listeners are present");
</script>