OLD | NEW |
| (Empty) |
1 <!DOCTYPE html> | |
2 <html> | |
3 <head> | |
4 <meta charset="utf-8"> | |
5 <title>Clicking with primary vs non-primary buttons</title> | |
6 <link rel="help" href="https://wicg.github.io/auxclick/"> | |
7 <script src="/resources/testharness.js"></script> | |
8 <script src="/resources/testharnessreport.js"></script> | |
9 <style> | |
10 #target { | |
11 background-color: green; | |
12 height: 200px; | |
13 width: 200px; | |
14 } | |
15 </style> | |
16 </head> | |
17 <body> | |
18 <h1>Clicking with primary vs non-primary buttons</h1> | |
19 <p>Double-click on the green box with a non-primary button. When using mouse
any button other than the left button is non-primary. If a "PASS" result appear
s, the test passes; otherwise, it fails.</p> | |
20 <div id="target"></div> | |
21 <script> | |
22 var test_auxclick = async_test("auxclick event sequence received."); | |
23 var target = document.querySelector('#target'); | |
24 document.addEventListener('contextmenu', event => { event.preventDefault();
}); | |
25 ['click', 'dblclick'].forEach(eventName => { | |
26 target.addEventListener(eventName, () => { | |
27 test_auxclick.step(() => { | |
28 assert_unreached(eventName + ' event should not be dispatched fo
r non-primary buttons.'); | |
29 }); | |
30 }); | |
31 document.addEventListener(eventName, () => { | |
32 test_auxclick.step(() => { | |
33 assert_unreached('document should not receive ' + eventName + '
for non-primary buttons.'); | |
34 }); | |
35 }, true); | |
36 }); | |
37 var click_count = 0; | |
38 var events = []; | |
39 ['mousedown', 'mouseup'].forEach(eventName => { | |
40 target.addEventListener(eventName, event => { | |
41 events.push(event.type); | |
42 }); | |
43 }); | |
44 target.addEventListener('auxclick', event => { | |
45 events.push(event.type); | |
46 click_count++; | |
47 if (click_count==1) { | |
48 test (() => { | |
49 assert_equals(event.detail, click_count, 'detail attribute of aux
click should be the click count.'); | |
50 }, "First auxclick should have detail=1 indicating the fire click"); | |
51 } else { | |
52 test (() => { | |
53 assert_equals(event.detail, click_count, 'detail attribute of aux
click should be the click count.'); | |
54 }, "Second auxclick should have detail=2 indicating the fire click"); | |
55 test_auxclick.step(() => { | |
56 assert_array_equals(events, ['mousedown', 'mouseup', 'auxclick',
'mousedown', 'mouseup', 'auxclick'], | |
57 'There should be two auxclick events for a non-primary butto
n double click each preceded by one mousemove and one mouseup'); | |
58 assert_equals(event.detail, click_count, 'detail attribute of au
xclick should be the click count.'); | |
59 }); | |
60 test_auxclick.done(); | |
61 } | |
62 }); | |
63 </script> | |
64 </body> | |
65 </html> | |
OLD | NEW |