Raw File
xrSession_prevent_multiple_exclusive.https.html
<!DOCTYPE html>
<body>
  <script src=/resources/testharness.js></script>
  <script src=/resources/testharnessreport.js></script>
  <script src="resources/webxr_util.js"></script>
  <canvas></canvas>

  <script>
    xr_promise_test(
      "Test prevention of multiple simultaneous immersive sessions",
      (t) => {
      return XRTest.simulateDeviceConnection({ supportsImmersive:true })
        .then( (controller) => { return navigator.xr.requestDevice() })
        .then( (device) => new Promise((resolve) => {
          XRTest.simulateUserActivation( () => {
            resolve(device.requestSession({ immersive: true })
              .then( (session) => new Promise((resolve) => {
                XRTest.simulateUserActivation( () => {
                  // Requesting a second immersive session from a device that already
                  // has an active immersive session should fail. Immersive sessions
                  // should take up the users entire view, and therefore it should
                  // be impossible for a user to be engaged with more than one.
                  resolve(promise_rejects(
                    t,
                    "InvalidStateError",
                    device.requestSession({ immersive: true })
                  ).then( () => {
                      // End the immersive session and try again. Now the immersive
                      // session creation should succeed.
                      return session.end().then( () => new Promise((resolve) => {
                        XRTest.simulateUserActivation( () => {
                          resolve(device.requestSession({ immersive: true }));
                        });
                      }));
                    }));
                });
            })));
          });
        }));
    });

  </script>
</body>
back to top