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
75
76
|
<!DOCTYPE HTML>
<title>click is a PointerEvent</title>
<meta name="variant" content="?mouse">
<meta name="variant" content="?pen">
<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>
<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">
<iframe src="resources/minimal.html" height="20" width="20"></iframe>
<script>
'use strict';
const pointer_type = location.search.substring(1);
let subframe_loaded = getMessageData("subframe-loaded", frames[0]);
function assert_click_construction(click_event, window_object) {
assert_equals(click_event.constructor, window_object.PointerEvent,
"click should use a PointerEvent constructor");
assert_true(click_event instanceof window_object.PointerEvent,
"click should be a PointerEvent instance");
}
function assert_click_attributes(click_event, pointerdown_event, pointerup_event) {
assert_equals(click_event.pointerId, pointerdown_event.pointerId,
"click.pointerId should match the pointerId of the triggering pointerdown");
assert_equals(click_event.pointerType, pointerdown_event.pointerType,
"click.pointerType should match the pointerType of the triggering pointerdown");
assert_equals(click_event.pointerId, pointerup_event.pointerId,
"click.pointerId should match the pointerId of the triggering pointerup");
assert_equals(click_event.pointerType, pointerup_event.pointerType,
"click.pointerType should match the pointerType of the triggering pointerup");
}
promise_test(async () => {
const target = document.getElementById("target");
let pointerdown_promise = getEvent("pointerdown", target);
let pointerup_promise = getEvent("pointerup", target);
let click_promise = getEvent("click", target);
await clickInTarget(pointer_type, target);
let pointerdown_event = await pointerdown_promise;
let pointerup_event = await pointerup_promise;
let click_event = await click_promise;
assert_click_construction(click_event, this);
assert_click_attributes(click_event, pointerdown_event, pointerup_event);
}, "click using " + pointer_type + " is a PointerEvent");
promise_test(async () => {
await subframe_loaded;
const target = frames[0];
let pointerdown_promise = getEvent("pointerdown", target);
let pointerup_promise = getEvent("pointerup", target);
let click_promise = getEvent("click", target);
await clickInTarget(pointer_type, frames[0].document.body);
let pointerdown_event = await pointerdown_promise;
let pointerup_event = await pointerup_promise;
let click_event = await click_promise;
assert_click_construction(click_event, frames[0]);
assert_click_attributes(click_event, pointerdown_event, pointerup_event);
}, "click in a subframe using " + pointer_type + " is a PointerEvent");
</script>
|