Bug 1735858 [wpt PR 31247] - App history: make it mostly nonfunctional for opaque...
[gecko.git] / testing / web-platform / tests / pointerlock / mouse_buttons_back_forward.html
blob6f4e764983b89f72cbd7e42a20fcb133dc8383f5
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <meta charset="utf-8" />
5 <title>Mouse Button Back/Forward</title>
6 <link rel="author" title="Google" href="http://www.google.com/" />
7 <script src="/resources/testharness.js"></script>
8 <script src="/resources/testharnessreport.js"></script>
9 <script src="/resources/testdriver.js"></script>
10 <script src="/resources/testdriver-actions.js"></script>
11 <script src="/resources/testdriver-vendor.js"></script>
12 <script>
13 var testMouseUp = async_test('Tests that when pointer is locked, the mouseup is preventable.');
14 var received_back = false;
15 var received_forward = false;
16 const left_button = 0;
17 const back_button = 3;
18 const forward_button = 4;
19 window.addEventListener('mouseup', function(e) {
20 if (e.button == left_button) {
21 document.body.requestPointerLock();
22 } else if (e.button == back_button) {
23 received_back = true;
24 e.preventDefault();
25 } else if (e.button == forward_button) {
26 received_forward = true;
27 e.preventDefault();
29 if (document.pointerLockElement && received_back && received_forward) {
30 testMouseUp.done();
31 document.exitPointerLock();
33 });
35 document.addEventListener("pointerlockchange", function() {
36 assert_equals(document.pointerLockElement, document.body);
38 // Inject mouse input
39 var actions = new test_driver.Actions();
40 actions.pointerMove(1, 1)
41 .pointerDown({button: actions.ButtonType.BACK})
42 .pointerUp({button: actions.ButtonType.BACK})
43 .pointerDown({button: actions.ButtonType.FORWARD})
44 .pointerUp({button: actions.ButtonType.FORWARD})
45 .send();
46 }, { once: true });
48 document.addEventListener("pointerlockerror", function() {
49 assert_unreached("Pointer lock error");
50 });
52 // Inject mouse input
53 var actions = new test_driver.Actions();
54 actions.pointerMove(1, 1)
55 .pointerDown({button: actions.ButtonType.LEFT})
56 .pointerUp({button: actions.ButtonType.LEFT})
57 .send();
58 </script>
60 </head>
61 <body id="target">
62 <h4>Test Description: Tests that the mouseup event is prevented.
63 <ol>
64 <li>Click the left mouse button to lock pointer</li>
65 <li>Click the back mouse button</li>
66 <li>Click the forward mouse button</li>
67 </ol>
68 </h4>
69 </body>
70 </html>