pointerlock_promise.html (1143B)
1 <!DOCTYPE html> 2 <html> 3 <body> 4 <meta name="timeout" content="long"> 5 <script src="/resources/testharness.js"></script> 6 <script src="/resources/testharnessreport.js"></script> 7 <script src="/resources/testdriver.js"></script> 8 <script src="/resources/testdriver-actions.js"></script> 9 <script src="/resources/testdriver-vendor.js"></script> 10 </head> 11 <body> 12 <h2>Description</h2> 13 <p>This test validates that pointer lock returns a Promise.</p> 14 <hr/> 15 16 <button id="Button">lockTarget</button> 17 18 <div id="target">Target</div> 19 20 <script type="text/javascript" > 21 const button = document.getElementById('Button'); 22 const target = document.getElementById('target'); 23 24 async_test(t => { 25 button.addEventListener('mousedown', t.step_func(async () => { 26 const promise = target.requestPointerLock(); 27 assert_true(promise instanceof Promise, "Test that requestPointerLock() returns Promise."); 28 await promise; 29 t.done(); 30 })); 31 }); 32 33 // Automated testing 34 test_driver.click(button); 35 </script> 36 </body> 37 </html>