1
0
Fork 0
firefox/testing/web-platform/tests/webxr/xrDevice_disconnect_ends.https.html
Daniel Baumann 5e9a113729
Adding upstream version 140.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
2025-06-25 09:37:52 +02:00

38 lines
1.3 KiB
HTML

<!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.js"></script>
<script>
const testName = "Immersive session ends when device is disconnected";
let watcherDone = new Event("watcherdone");
const fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let testFunction = function(session, testDeviceController, t) {
let sessionWatcher = new EventWatcher(t, session, ["end", "watcherdone"]);
let sessionPromise = sessionWatcher.wait_for(["end", "watcherdone"]);
let xrWatcher = new EventWatcher(t, navigator.xr, ["devicechange"]);
let xrPromise = xrWatcher.wait_for(["devicechange"]);
function onSessionEnd(event) {
t.step( () => {
assert_equals(event.session, session);
session.dispatchEvent(watcherDone);
});
}
session.addEventListener("end", onSessionEnd, false);
// The javascript needs to yield so that the event registration processes.
t.step_timeout(() => { testDeviceController.disconnect(); }, 0);
return Promise.all([sessionPromise, xrPromise]);
};
xr_session_promise_test(testName, testFunction,
fakeDeviceInitParams, 'immersive-vr');
</script>
</body>