xrSession_sameObject.https.html (2572B)
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 = "XRSession 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 renderState = session.renderState; 22 let sources = session.inputSources; 23 24 t.step(() => { 25 assert_not_equals(renderState, null, "renderState must not be null."); 26 assert_not_equals(sources, null, "inputSources must not be null."); 27 28 // Make sure [SameObject] attributes actually have the same object 29 // returned each time they are accessed. 30 assert_equals(renderState, session.renderState, 31 "XRSession.renderState returns the same object."); 32 assert_equals(sources, session.inputSources, 33 "XRSession.inputSources returns the same object."); 34 }); 35 36 session.requestAnimationFrame((time, xrFrame) => { 37 t.step(() => { 38 // Make sure the attributes still return the same object on the next 39 // frame. 40 assert_equals(renderState, session.renderState, 41 "XRSession.renderState returns the same object."); 42 assert_equals(sources, session.inputSources, 43 "XRSession.inputSources returns the same object."); 44 }); 45 46 // Even though changing handedness on the input source should cause that 47 // source to be re-created, it should not cause the entire 48 // XRInputSourceArray object on XRSession to be re-created. 49 input_source.setHandedness("left"); 50 session.requestAnimationFrame((time, xrFrame) => { 51 t.step(() => { 52 assert_equals(renderState, session.renderState, 53 "XRSession.renderState returns the same object."); 54 assert_equals(sources, session.inputSources, 55 "XRSession.inputSources returns the same object."); 56 }); 57 resolve(); 58 }); 59 }); 60 }); 61 }); 62 }; 63 64 xr_session_promise_test( 65 testName, testFunction, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr'); 66 </script>