summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/xrDevice_disconnect_ends.https.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/webxr/xrDevice_disconnect_ends.https.html')
-rw-r--r--testing/web-platform/tests/webxr/xrDevice_disconnect_ends.https.html38
1 files changed, 38 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/xrDevice_disconnect_ends.https.html b/testing/web-platform/tests/webxr/xrDevice_disconnect_ends.https.html
new file mode 100644
index 0000000000..644a4d68e4
--- /dev/null
+++ b/testing/web-platform/tests/webxr/xrDevice_disconnect_ends.https.html
@@ -0,0 +1,38 @@
+<!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>