<!DOCTYPE html>
<body>
  <script src=/resources/testharness.js></script>
  <script src=/resources/testharnessreport.js></script>
  <script src="resources/webxr_util.js"></script>
  <script src="resources/webxr_test_constants_single_view.js"></script>
  <script>
    xr_session_promise_test(
      "Tests requestSession should succeed when device does not support hand-tracking and hand-tracking is an optional feature",
      (session) => {
        assert_not_equals(session, null);
      }, TRACKED_IMMERSIVE_DEVICE_NO_HAND_TRACKING, 'immersive-vr', { optionalFeatures: ["hand-tracking"] });

    xr_promise_test(
      "Tests requestSession should fail when device does not support hand-tracking and hand-tracking is a required feature",
      (t) => {
        return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE_NO_HAND_TRACKING)
          .then((controller) => new Promise((resolve) => {
            navigator.xr.test.simulateUserActivation(() => {
              resolve(promise_rejects_dom(
                t, "NotSupportedError",
                navigator.xr.requestSession('immersive-vr', { requiredFeatures: ["hand-tracking"] })));
              });
          }));
      });
  </script>
</body>
