xrInputSource_sameObject.https.html (2421B)
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 = "XRInputSource attributes meet [SameObject] requirement"; 9 10 let testFunction = function(session, fakeDeviceController, t) { 11 return new Promise((resolve) => { 12 let input_source = fakeDeviceController.simulateInputSourceConnection({ 13 handedness: "right", 14 targetRayMode: "tracked-pointer", 15 pointerOrigin: VALID_POINTER_TRANSFORM, 16 gripOrigin: VALID_GRIP_TRANSFORM, 17 profiles: ["foo", "bar"] 18 }); 19 20 requestSkipAnimationFrame(session, (time, xrFrame) => { 21 let source = session.inputSources[0]; 22 let targetRaySpace = source.targetRaySpace; 23 let gripSpace = source.gripSpace; 24 let profiles = source.profiles; 25 26 t.step(() => { 27 assert_not_equals(targetRaySpace, null, 28 "target ray space must not be null"); 29 assert_not_equals(gripSpace, null, "grip space must not be null"); 30 31 // Make sure [SameObject] attributes actually have the same object 32 // returned each time they are accessed. 33 assert_equals(targetRaySpace, source.targetRaySpace, 34 "XRInputSource.targetRaySpace returns the same object."); 35 assert_equals(gripSpace, source.gripSpace, 36 "XRInputSource.gripSpace returns the same object."); 37 assert_equals(profiles, source.profiles, 38 "XRInputSource.profiles returns the same object."); 39 }); 40 41 session.requestAnimationFrame((time, xrFrame) => { 42 // Make sure the attributes still return the same object on the next 43 // frame when nothing has happened that would cause the input source 44 // to be recreated. 45 t.step(() => { 46 assert_equals(targetRaySpace, source.targetRaySpace, 47 "XRInputSource.targetRaySpace returns the same object each frame."); 48 assert_equals(gripSpace, source.gripSpace, 49 "XRInputSource.gripSpace returns the same object each frame."); 50 assert_equals(profiles, source.profiles, 51 "XRInputSource.profiles returns the same object each frame."); 52 }); 53 54 resolve(); 55 }); 56 }); 57 }); 58 }; 59 60 xr_session_promise_test( 61 testName, testFunction, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr'); 62 </script>