chromium/third_party/blink/web_tests/wpt_internal/webxr/xrSession_dataProviderDisconnect_inline.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_constants.js"></script>

<script>
// This test manipulates mojo directly to simulate some behavior, and as such is
// chromium specific.
let testName = "Inline session ends if magic window data provider disconnects.";
let fakeDeviceInitParams = VALID_NON_IMMERSIVE_DEVICE;

let testFunction = function(session, fakeDeviceController, t) {
  return new Promise((resolve) => {
    session.addEventListener('end', () => resolve());

    // Request an animation frame to ensure that everything has time to get
    // initialized/connected and avoid a race-condition failure with the data
    // binding not being able to get closed.
    session.requestAnimationFrame(() => {
      fakeDeviceController.closeDataProvider();
      session.requestAnimationFrame(() => {});
    });
  });
}

// Inline that solely relies on the implicit viewer reference space ignores the
// data provider, so we need to make sure that we get a session that supports
// the local reference space.
xr_session_promise_test(
  testName, testFunction, fakeDeviceInitParams, 'inline', { requiredFeatures: ["local"] });

</script>