chromium/chrome/test/data/xr/e2e_test_files/html/test_webxr_profiles.html

<!doctype html>
<!--
A collection of helper functions and listeners to confirm the state of input
sources for the same object tests.
-->
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="../resources/webxr_e2e.css">
  </head>
  <body>
    <canvas id="webgl-canvas"></canvas>
    <script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script>
    <script src="../resources/webxr_e2e.js"></script>
    <script src="../resources/webxr_boilerplate.js"></script>
    <script>
      function setupImmersiveSessionToRequestHands() {
        immersiveSessionInit = { requiredFeatures: ["hand-tracking"] }
      }

      let inputChangeEvents = 0;
      function onInputSourcesChange(event) {
        inputChangeEvents++;
      }

      onSessionStartedCallback = function(session) {
        if (session.mode.startsWith("immersive")) {
          session.addEventListener('inputsourceschange', onInputSourcesChange, false);
        }
      }

      function getCurrentInputSources() {
        let currentSession = sessionInfos[sessionTypes.IMMERSIVE].currentSession;
        return Array.from(currentSession.inputSources.values());
      }

      function validateAllInputSourcesContainProfile(profile) {
        getCurrentInputSources().forEach((source) => {
          assert_true(source.profiles.includes(profile),
            "Every element in input sources should contain: " + profile);
        });
      }

      function validateNoInputSourcesContainProfile(profile) {
        getCurrentInputSources().forEach((source) => {
          assert_false(source.profiles.includes(profile),
            "No element in input sources should contain: " + profile);
        });
      }
    </script>
  </body>
</html>