tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

depth_sensing_preferences.https.html (5137B)


      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 <script src="../resources/webxr_test_constants_fake_depth.js"></script>
      7 <script>
      8  const depthConfigurationTestGenerator =
      9    function (sessionOptions, shouldGrantSession, shouldDepthBeEnabled = true) {
     10      return (t) => {
     11        return navigator.xr.test.simulateDeviceConnection(IMMERSIVE_AR_DEVICE)
     12          .then((controller) => new Promise((resolve, reject) => {
     13            navigator.xr.test.simulateUserActivation(() => {
     14              navigator.xr.requestSession('immersive-ar', sessionOptions)
     15                .then((session) => {
     16                  return session.end().then(() => {
     17                    if (!shouldGrantSession) {
     18                      reject("Session granted when expected rejection.");
     19                      return;
     20                    }
     21 
     22                    t.step(() => {
     23                      let depthEnabled = session.enabledFeatures.includes('depth-sensing');
     24                      assert_true(depthEnabled == shouldDepthBeEnabled);
     25                    });
     26 
     27                    resolve();
     28                  });
     29                })
     30                .catch((err) => {
     31                  if (shouldGrantSession) {
     32                    reject("Session rejected with error: " + err);
     33                    return;
     34                  }
     35 
     36                  resolve();
     37                });
     38            });
     39          }));
     40      };
     41    };
     42 
     43  // Valid configurations when depth is a required feature
     44  xr_promise_test(
     45    "depthSensing - Required - Fully populated grants session",
     46    depthConfigurationTestGenerator({
     47      'requiredFeatures': ['depth-sensing'],
     48      depthSensing: {
     49        usagePreference: DEPTH_CONFIG_ALL_USAGES,
     50        dataFormatPreference: DEPTH_CONFIG_ALL_FORMATS
     51      },
     52    }, /*shouldGrantSession=*/true));
     53 
     54  xr_promise_test(
     55    "depthSensing - Required - Empty usage grants session",
     56    depthConfigurationTestGenerator({
     57      'requiredFeatures': ['depth-sensing'],
     58      depthSensing: {
     59        usagePreference: [],
     60        dataFormatPreference: DEPTH_CONFIG_ALL_FORMATS
     61      },
     62    }, /*shouldGrantSession=*/true));
     63 
     64  xr_promise_test(
     65    "depthSensing - Required - Empty format grants session",
     66    depthConfigurationTestGenerator({
     67      'requiredFeatures': ['depth-sensing'],
     68      depthSensing: {
     69        usagePreference: DEPTH_CONFIG_ALL_USAGES,
     70        dataFormatPreference: [],
     71      },
     72    }, /*shouldGrantSession=*/true));
     73 
     74  xr_promise_test(
     75    "depthSensing - Required - Empty usage and format grants session",
     76    depthConfigurationTestGenerator({
     77      'requiredFeatures': ['depth-sensing'],
     78      depthSensing: {
     79        usagePreference: [],
     80        dataFormatPreference: [],
     81      },
     82    }, /*shouldGrantSession=*/true));
     83 
     84  // Invalid configurations when depth is a required feature
     85  xr_promise_test(
     86    "depthSensing - Required - Missing usage rejects session",
     87    depthConfigurationTestGenerator({
     88      'requiredFeatures': ['depth-sensing'],
     89      depthSensing: {
     90        dataFormatPreference: [],
     91      },
     92    }, /*shouldGrantSession=*/false));
     93 
     94  xr_promise_test(
     95    "depthSensing - Required - Missing format rejects session",
     96    depthConfigurationTestGenerator({
     97      'requiredFeatures': ['depth-sensing'],
     98      depthSensing: {
     99        usagePreference: [],
    100      },
    101    }, /*shouldGrantSession=*/false));
    102 
    103  xr_promise_test(
    104    "depthSensing - Required - Missing usage and format rejects session",
    105    depthConfigurationTestGenerator({
    106      'requiredFeatures': ['depth-sensing'],
    107      depthSensing: {},
    108    }, /*shouldGrantSession=*/false));
    109 
    110  xr_promise_test(
    111    "depthSensing - Required - Missing configuration rejects session",
    112    depthConfigurationTestGenerator({
    113      'requiredFeatures': ['depth-sensing'],
    114    }, /*shouldGrantSession=*/false));
    115 
    116  // Invalid configurations when depth is an optional feature
    117  xr_promise_test(
    118    "depthSensing - Optional - Missing usage optional still rejects session",
    119    depthConfigurationTestGenerator({
    120      'optionalFeatures': ['depth-sensing'],
    121      depthSensing: {
    122        dataFormatPreference: [],
    123      },
    124    }, /*shouldGrantSession=*/false));
    125 
    126  xr_promise_test(
    127    "depthSensing - Optional - Missing format optional still rejects session",
    128    depthConfigurationTestGenerator({
    129      'optionalFeatures': ['depth-sensing'],
    130      depthSensing: {
    131        usagePreference: [],
    132      },
    133    }, /*shouldGrantSession=*/false));
    134 
    135  xr_promise_test(
    136    "depthSensing - Optional - Missing usage and format optional still rejects session",
    137    depthConfigurationTestGenerator({
    138      'optionalFeatures': ['depth-sensing'],
    139      depthSensing: {},
    140    }, /*shouldGrantSession=*/false));
    141 
    142  xr_promise_test(
    143    "depthSensing - Optional - Missing configuration optional grants session without depth",
    144    depthConfigurationTestGenerator({
    145      'optionalFeatures': ['depth-sensing'],
    146    }, /*shouldGrantSession=*/true,
    147  /*shouldDepthBeEnabled=*/false));
    148 </script>