chromium/third_party/blink/web_tests/wpt_internal/webxr/ar/ar_anchor_getAnchors_null.https.html

<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>let additionalChromiumResources = ["../resources/xr-internal-device-mocking.js"];</script>
<script src="/webxr/resources/webxr_util.js"></script>
<script src="/webxr/resources/webxr_test_asserts.js"></script>
<script src="/webxr/resources/webxr_test_constants.js"></script>
<script src="/webxr/resources/webxr_test_constants_fake_world.js"></script>

<script>

// 1m above world origin.
const VIEWER_ORIGIN_TRANSFORM = {
  position: [0, 1, 0],
  orientation: [0, 0, 0, 1],
};

const fakeDeviceInitParams = {
  supportedModes: ["immersive-ar"],
  views: VALID_VIEWS,
  supportedFeatures: ALL_FEATURES,
  viewerOrigin: VIEWER_ORIGIN_TRANSFORM,
};

// Attempts to access XRFrame.trackedAnchors and expects to get empty set
// since no anchors are being created. Leverages internal API to mock anchorsData
// that will be returned from the device to null. This is internal in order to
// avoid exposing Chrome-specific implementation details through WebXR Test API.
const testFunction = function(session, fakeDeviceController, t) {
  const debug = xr_debug.bind(this, 'testGetAnchors');

  let done = false;

  fakeDeviceController.setMockAnchorDataIsNull(true);

  session.requestReferenceSpace('local').then((localRefSpace) => {
    const onFrame = function(time, frame) {
      const trackedAnchors = frame.trackedAnchors;
      t.step(() => {
        assert_equals(trackedAnchors.size, 0);
      });

      done = true;
    };

    session.requestAnimationFrame(onFrame);
  }); // session.requestReferenceSpace(...)

  return t.step_wait(() => done);
};  // testFunction

xr_session_promise_test("XRFrame's trackedAnchors is empty when the feature was requested & device returned null anchorsData",
  testFunction,
  fakeDeviceInitParams,
  'immersive-ar', { 'requiredFeatures': ['anchors'] });

</script>