xrSession_prevent_multiple_exclusive.https.html (1844B)
1 <!DOCTYPE html> 2 <body> 3 <script src=/resources/testharness.js></script> 4 <script src=/resources/testharnessreport.js></script> 5 <script src="resources/webxr_util.js"></script> 6 <script src="resources/webxr_test_constants.js"></script> 7 <canvas></canvas> 8 9 <script> 10 xr_promise_test( 11 "Test prevention of multiple simultaneous immersive sessions", 12 (t) => { 13 return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE) 14 .then( (controller) => new Promise((resolve) => { 15 navigator.xr.test.simulateUserActivation( () => { 16 resolve(navigator.xr.requestSession('immersive-vr') 17 .then( (session) => new Promise((resolve) => { 18 navigator.xr.test.simulateUserActivation( () => { 19 // Requesting a second immersive session when another immersive 20 // session is active should fail. Immersive sessions 21 // should take up the users entire view, and therefore it should 22 // be impossible for a user to be engaged with more than one. 23 resolve(promise_rejects_dom( 24 t, 25 "InvalidStateError", 26 navigator.xr.requestSession('immersive-vr') 27 ).then( () => { 28 // End the immersive session and try again. Now the immersive 29 // session creation should succeed. 30 return session.end().then( () => new Promise((resolve) => { 31 navigator.xr.test.simulateUserActivation( () => { 32 resolve(navigator.xr.requestSession('immersive-vr')); 33 }); 34 })); 35 })); 36 }); 37 }))); 38 }); 39 })); 40 }); 41 42 </script> 43 </body>