events_session_select_subframe.https.html (2223B)
1 <!DOCTYPE html> 2 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharnessreport.js"></script> 4 <script src="resources/webxr_util.js"></script> 5 <script src="resources/webxr_test_constants.js"></script> 6 7 <script> 8 let testName = "Ensures that an XRInputSources primary input being pressed and " 9 + "released in the space of a single frame properly fires off the right " 10 + "events"; 11 12 let watcherDone = new Event("watcherdone"); 13 14 let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE; 15 16 let testFunction = function(session, fakeDeviceController, t) { 17 let eventWatcher = new EventWatcher( 18 t, session, ["selectstart", "selectend", "select", "watcherdone"]); 19 let eventPromise = eventWatcher.wait_for( 20 ["selectstart", "selectend", "select", "watcherdone"]); 21 22 function onSessionSelectStart(event) { 23 t.step( () => { 24 let input_sources = session.inputSources; 25 assert_equals(event.frame.session, session); 26 assert_equals(event.inputSource, input_sources[0]); 27 }); 28 } 29 30 function onSessionSelectEnd(event) { 31 t.step( () => { 32 let input_sources = session.inputSources; 33 assert_equals(event.frame.session, session); 34 assert_equals(event.inputSource, input_sources[0]); 35 }); 36 } 37 38 function onSessionSelect(event) { 39 t.step( () => { 40 let input_sources = session.inputSources; 41 assert_equals(event.frame.session, session); 42 assert_equals(event.inputSource, input_sources[0]); 43 }); 44 session.dispatchEvent(watcherDone); 45 } 46 session.addEventListener("selectstart", onSessionSelectStart, false); 47 session.addEventListener("selectend", onSessionSelectEnd, false); 48 session.addEventListener("select", onSessionSelect, false); 49 50 let input_source = fakeDeviceController.simulateInputSourceConnection(VALID_CONTROLLER); 51 52 // Press the primary input button and then release it a short time later. 53 requestSkipAnimationFrame(session, (time, xrFrame) => { 54 input_source.simulateSelect(); 55 56 session.requestAnimationFrame((time, xrFrame) => { 57 // Need to process one more frame to allow select to propegate. 58 }); 59 }); 60 }; 61 62 xr_session_promise_test( 63 testName, testFunction, fakeDeviceInitParams, 'immersive-vr'); 64 65 </script>