summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/depth-sensing
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:22:09 +0000
commit43a97878ce14b72f0981164f87f2e35e14151312 (patch)
tree620249daf56c0258faa40cbdcf9cfba06de2a846 /testing/web-platform/tests/webxr/depth-sensing
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 110.0.1.upstream/110.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webxr/depth-sensing')
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_dataUnavailable.https.html27
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_inactiveFrame.https.html26
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_incorrectUsage.https.html48
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_luminance_alpha_dataValid.https.html110
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_staleView.https.html26
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/dataUnavailableTests.js58
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/depth_sensing_notEnabled.https.html61
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https.html27
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_inactiveFrame.https.html26
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https.html46
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https.html26
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/inactiveFrameTests.js36
-rw-r--r--testing/web-platform/tests/webxr/depth-sensing/staleViewsTests.js39
13 files changed, 556 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_dataUnavailable.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_dataUnavailable.https.html
new file mode 100644
index 0000000000..e120f0b7dd
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_dataUnavailable.https.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/webxr_util.js"></script>
+<script src="../../resources/webxr_test_asserts.js"></script>
+<script src="../../resources/webxr_test_constants.js"></script>
+<script src="../../resources/webxr_test_constants_fake_depth.js"></script>
+<script src="../dataUnavailableTests.js"></script>
+
+<script>
+
+const fakeDeviceInitParams = {
+ supportedModes: ["immersive-ar"],
+ views: VALID_VIEWS,
+ supportedFeatures: ALL_FEATURES,
+ depthSensingData: DEPTH_SENSING_DATA,
+};
+
+xr_session_promise_test("Ensures depth data is not available when cleared in the controller, `cpu-optimized`",
+ dataUnavailableTestFunctionGenerator(/*isCpuOptimized=*/true),
+ fakeDeviceInitParams,
+ 'immersive-ar', {
+ requiredFeatures: ['depth-sensing'],
+ depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE,
+ });
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_inactiveFrame.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_inactiveFrame.https.html
new file mode 100644
index 0000000000..92c20cecbf
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_inactiveFrame.https.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/webxr_util.js"></script>
+<script src="../../resources/webxr_test_asserts.js"></script>
+<script src="../../resources/webxr_test_constants.js"></script>
+<script src="../../resources/webxr_test_constants_fake_depth.js"></script>
+<script src="../inactiveFrameTests.js"></script>
+
+<script>
+
+const fakeDeviceInitParams = {
+ supportedModes: ["immersive-ar"],
+ views: VALID_VIEWS,
+ supportedFeatures: ALL_FEATURES,
+};
+
+xr_session_promise_test("Ensures getDepthInformation() throws when not run in an active frame, `cpu-optimized`",
+ inactiveFrameTestFunctionGenerator(/*isCpuOptimized=*/true),
+ fakeDeviceInitParams,
+ 'immersive-ar', {
+ requiredFeatures: ['depth-sensing'],
+ depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE,
+ });
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_incorrectUsage.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_incorrectUsage.https.html
new file mode 100644
index 0000000000..44868d8cb0
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_incorrectUsage.https.html
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/webxr_util.js"></script>
+<script src="../../resources/webxr_test_asserts.js"></script>
+<script src="../../resources/webxr_test_constants.js"></script>
+<script src="../../resources/webxr_test_constants_fake_depth.js"></script>
+<script src="../incorrectUsageTests.js"></script>
+
+<script>
+
+const fakeDeviceInitParams = {
+ supportedModes: ["immersive-ar"],
+ views: VALID_VIEWS,
+ supportedFeatures: ALL_FEATURES,
+};
+
+const incorrectUsagetestFunctionTryGetWebGLOnCpu = function (session, controller, t, sessionObjects) {
+ return session.requestReferenceSpace('viewer').then((viewerSpace) => {
+ let done = false;
+
+ const glBinding = new XRWebGLBinding(session, sessionObjects.gl);
+
+ session.requestAnimationFrame((time, frame) => {
+ const pose = frame.getViewerPose(viewerSpace);
+ for(const view of pose.views) {
+ t.step(() => {
+ assert_throws_dom("InvalidStateError", () => glBinding.getDepthInformation(view),
+ "XRWebGLBinding.getDepthInformation() should throw when depth sensing is in `cpu-optimized` usage mode");
+ });
+ }
+
+ done = true;
+ });
+
+ return t.step_wait(() => done);
+ });
+};
+
+xr_session_promise_test("Ensures XRWebGLDepthInformation is not obtainable in `cpu-optimized` usage mode",
+ incorrectUsagetestFunctionTryGetWebGLOnCpu,
+ fakeDeviceInitParams,
+ 'immersive-ar', {
+ requiredFeatures: ['depth-sensing'],
+ depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE,
+ });
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_luminance_alpha_dataValid.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_luminance_alpha_dataValid.https.html
new file mode 100644
index 0000000000..db88c42558
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_luminance_alpha_dataValid.https.html
@@ -0,0 +1,110 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/webxr_util.js"></script>
+<script src="../../resources/webxr_math_utils.js"></script>
+<script src="../../resources/webxr_test_asserts.js"></script>
+<script src="../../resources/webxr_test_constants.js"></script>
+<script src="../../resources/webxr_test_constants_fake_depth.js"></script>
+
+<script>
+
+const fakeDeviceInitParams = {
+ supportedModes: ["immersive-ar"],
+ views: VALID_VIEWS,
+ supportedFeatures: ALL_FEATURES,
+ depthSensingData: DEPTH_SENSING_DATA,
+};
+
+const assert_depth_valid_at = function(depthInformation, row, column, deltaRow, deltaColumn) {
+ // column and row correspond to the depth buffer coordinates,
+ // *not* to normalized view coordinates the getDepthInMeters() expects.
+
+ const expectedValue = getExpectedValueAt(column, row);
+
+ // 1. Normalize:
+ let x = (column + deltaColumn) / depthInformation.width;
+ let y = (row + deltaRow) / depthInformation.height;
+
+ // 2. Apply the transform that changes the origin and axes:
+ x = 1.0 - x;
+ y = 1.0 - y;
+
+ const depthValue = depthInformation.getDepthInMeters(x, y);
+ assert_approx_equals(depthValue, expectedValue, FLOAT_EPSILON,
+ "Depth value at (" + column + "," + row + "), deltas=(" + deltaColumn + ", " + deltaRow + "), "
+ + "coordinates (" + x + "," + y + ") must match!");
+}
+
+const assert_depth_valid = function(depthInformation) {
+
+ assert_true(depthInformation.data instanceof ArrayBuffer,
+ "XRCpuDepthInformation.data must be of type `ArrayBuffer`!");
+
+ for(let row = 0; row < depthInformation.height; row++) {
+ for(let column = 0; column < depthInformation.width; column++) {
+ // middle of the pixel:
+ assert_depth_valid_at(depthInformation, row, column, 0.5, 0.5);
+
+ // corners of the pixel:
+ assert_depth_valid_at(depthInformation, row, column, FLOAT_EPSILON, FLOAT_EPSILON);
+ assert_depth_valid_at(depthInformation, row, column, FLOAT_EPSILON, 1 - FLOAT_EPSILON);
+ assert_depth_valid_at(depthInformation, row, column, 1 - FLOAT_EPSILON, FLOAT_EPSILON);
+ assert_depth_valid_at(depthInformation, row, column, 1 - FLOAT_EPSILON, 1 - FLOAT_EPSILON);
+ }
+ }
+
+ // Verify out-of-bounds accesses throw:
+ assert_throws_js(RangeError,
+ () => depthInformation.getDepthInMeters(-FLOAT_EPSILON, 0.0),
+ "getDepthInMeters() should throw when run with invalid indices - negative x");
+ assert_throws_js(RangeError,
+ () => depthInformation.getDepthInMeters(0.0, -FLOAT_EPSILON),
+ "getDepthInMeters() should throw when run with invalid indices - negative y");
+ assert_throws_js(RangeError,
+ () => depthInformation.getDepthInMeters(1+FLOAT_EPSILON, 0.0),
+ "getDepthInMeters() should throw when run with invalid indices - too big x");
+ assert_throws_js(RangeError,
+ () => depthInformation.getDepthInMeters(0.0, 1+FLOAT_EPSILON),
+ "getDepthInMeters() should throw when run with invalid indices - too big y");
+};
+
+const testCpuOptimizedLuminanceAlpha = function(session, fakeDeviceController, t) {
+ return session.requestReferenceSpace('viewer').then((viewerSpace) => {
+ let done = false;
+
+ const rafCallback = function(time, frame) {
+ const pose = frame.getViewerPose(viewerSpace);
+ if(pose) {
+ for(const view of pose.views) {
+ const depthInformation = frame.getDepthInformation(view);
+
+ t.step(() => {
+ assert_not_equals(depthInformation, null, "XRCPUDepthInformation must not be null!");
+ assert_approx_equals(depthInformation.width, DEPTH_SENSING_DATA.width, FLOAT_EPSILON);
+ assert_approx_equals(depthInformation.height, DEPTH_SENSING_DATA.height, FLOAT_EPSILON);
+ assert_approx_equals(depthInformation.rawValueToMeters, DEPTH_SENSING_DATA.rawValueToMeters, FLOAT_EPSILON);
+ assert_transform_approx_equals(depthInformation.normDepthBufferFromNormView, DEPTH_SENSING_DATA.normDepthBufferFromNormView);
+ assert_depth_valid(depthInformation);
+ });
+ }
+ }
+
+ done = true;
+ };
+
+ session.requestAnimationFrame(rafCallback);
+
+ return t.step_wait(() => done);
+ });
+};
+
+xr_session_promise_test("Ensures depth data is returned and values match expectation, cpu-optimized, luminance-alpha.",
+ testCpuOptimizedLuminanceAlpha,
+ fakeDeviceInitParams,
+ 'immersive-ar', {
+ 'requiredFeatures': ['depth-sensing'],
+ depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE,
+ });
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_staleView.https.html b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_staleView.https.html
new file mode 100644
index 0000000000..6a411ace45
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/cpu/depth_sensing_cpu_staleView.https.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/webxr_util.js"></script>
+<script src="../../resources/webxr_test_asserts.js"></script>
+<script src="../../resources/webxr_test_constants.js"></script>
+<script src="../../resources/webxr_test_constants_fake_depth.js"></script>
+<script src="../staleViewsTests.js"></script>
+
+<script>
+
+const fakeDeviceInitParams = {
+ supportedModes: ["immersive-ar"],
+ views: VALID_VIEWS,
+ supportedFeatures: ALL_FEATURES,
+};
+
+xr_session_promise_test("Ensures getDepthInformation() throws when run with stale XRView, `cpu-optimized`",
+ staleViewsTestFunctionGenerator(/*isCpuOptimized=*/true),
+ fakeDeviceInitParams,
+ 'immersive-ar', {
+ requiredFeatures: ['depth-sensing'],
+ depthSensing: VALID_DEPTH_CONFIG_CPU_USAGE,
+ });
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/dataUnavailableTests.js b/testing/web-platform/tests/webxr/depth-sensing/dataUnavailableTests.js
new file mode 100644
index 0000000000..7460af7132
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/dataUnavailableTests.js
@@ -0,0 +1,58 @@
+'use strict';
+
+const TestStates = Object.freeze({
+ "ShouldSucceedScheduleRAF": 1,
+ "ShouldFailScheduleRAF": 2,
+ "ShouldSucceedTestDone": 3,
+});
+
+const dataUnavailableTestFunctionGenerator = function(isCpuOptimized) {
+ return (session, controller, t, sessionObjects) => {
+ let state = TestStates.ShouldSucceedScheduleRAF;
+
+ return session.requestReferenceSpace('viewer').then((viewerSpace) => {
+ let done = false;
+
+ const glBinding = new XRWebGLBinding(session, sessionObjects.gl);
+
+ const rafCb = function(time, frame) {
+ const pose = frame.getViewerPose(viewerSpace);
+ for(const view of pose.views) {
+ const depthInformation = isCpuOptimized ? frame.getDepthInformation(view)
+ : glBinding.getDepthInformation(view);
+
+ if (state == TestStates.ShouldSucceedScheduleRAF
+ || state == TestStates.ShouldSucceedTestDone) {
+ t.step(() => {
+ assert_not_equals(depthInformation, null);
+ });
+ } else {
+ t.step(() => {
+ assert_equals(depthInformation, null);
+ });
+ }
+ }
+
+ switch(state) {
+ case TestStates.ShouldSucceedScheduleRAF:
+ controller.clearDepthSensingData();
+ state = TestStates.ShouldFailScheduleRAF;
+ session.requestAnimationFrame(rafCb);
+ break;
+ case TestStates.ShouldFailScheduleRAF:
+ controller.setDepthSensingData(DEPTH_SENSING_DATA);
+ state = TestStates.ShouldSucceedTestDone;
+ session.requestAnimationFrame(rafCb);
+ break;
+ case TestStates.ShouldSucceedTestDone:
+ done = true;
+ break;
+ }
+ };
+
+ session.requestAnimationFrame(rafCb);
+
+ return t.step_wait(() => done);
+ });
+ };
+}; \ No newline at end of file
diff --git a/testing/web-platform/tests/webxr/depth-sensing/depth_sensing_notEnabled.https.html b/testing/web-platform/tests/webxr/depth-sensing/depth_sensing_notEnabled.https.html
new file mode 100644
index 0000000000..23bae35493
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/depth_sensing_notEnabled.https.html
@@ -0,0 +1,61 @@
+<!DOCTYPE html>
+<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 testFunctionCpu = function (session, controller, t) {
+ return session.requestReferenceSpace('viewer').then((viewerSpace) => {
+ let done = false;
+
+ session.requestAnimationFrame((time, frame) => {
+ const pose = frame.getViewerPose(viewerSpace);
+ for(const view of pose.views) {
+ assert_throws_dom("NotSupportedError", () => frame.getDepthInformation(view),
+ "getDepthInformation() should throw when depth sensing is disabled");
+ }
+
+ done = true;
+ });
+
+ return t.step_wait(() => done);
+ });
+};
+
+const testFunctionGpu = function (session, controller, t, sessionObjects) {
+ return session.requestReferenceSpace('viewer').then((viewerSpace) => {
+ let done = false;
+
+ const glBinding = new XRWebGLBinding(session, sessionObjects.gl);
+
+ session.requestAnimationFrame((time, frame) => {
+ const pose = frame.getViewerPose(viewerSpace);
+ for(const view of pose.views) {
+ t.step(() => {
+ assert_throws_dom("NotSupportedError", () => glBinding.getDepthInformation(view),
+ "getDepthInformation() should throw when depth sensing is disabled");
+ });
+ }
+
+ done = true;
+ });
+
+ return t.step_wait(() => done);
+ });
+};
+
+xr_session_promise_test(
+ "XRFrame.getDepthInformation() rejects if depth sensing is not enabled on a session",
+ testFunctionCpu,
+ IMMERSIVE_AR_DEVICE,
+ 'immersive-ar');
+
+xr_session_promise_test(
+ "XRWebGLBinding.getDepthInformation() rejects if depth sensing is not enabled on a session",
+ testFunctionGpu,
+ IMMERSIVE_AR_DEVICE,
+ 'immersive-ar');
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https.html b/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https.html
new file mode 100644
index 0000000000..018edf7693
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_dataUnavailable.https.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/webxr_util.js"></script>
+<script src="../../resources/webxr_test_asserts.js"></script>
+<script src="../../resources/webxr_test_constants.js"></script>
+<script src="../../resources/webxr_test_constants_fake_depth.js"></script>
+<script src="../dataUnavailableTests.js"></script>
+
+<script>
+
+const fakeDeviceInitParams = {
+ supportedModes: ["immersive-ar"],
+ views: VALID_VIEWS,
+ supportedFeatures: ALL_FEATURES,
+ depthSensingData: DEPTH_SENSING_DATA,
+};
+
+xr_session_promise_test("Ensures depth data is not available when cleared in the controller, `gpu-optimized`",
+ dataUnavailableTestFunctionGenerator(/*isCpuOptimized=*/false),
+ fakeDeviceInitParams,
+ 'immersive-ar', {
+ requiredFeatures: ['depth-sensing'],
+ depthSensing: VALID_DEPTH_CONFIG_GPU_USAGE,
+ });
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_inactiveFrame.https.html b/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_inactiveFrame.https.html
new file mode 100644
index 0000000000..6116f7a041
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_inactiveFrame.https.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/webxr_util.js"></script>
+<script src="../../resources/webxr_test_asserts.js"></script>
+<script src="../../resources/webxr_test_constants.js"></script>
+<script src="../../resources/webxr_test_constants_fake_depth.js"></script>
+<script src="../inactiveFrameTests.js"></script>
+
+<script>
+
+const fakeDeviceInitParams = {
+ supportedModes: ["immersive-ar"],
+ views: VALID_VIEWS,
+ supportedFeatures: ALL_FEATURES,
+};
+
+xr_session_promise_test("Ensures getDepthInformation() throws when not run in an active frame, `gpu-optimized`",
+ testFunctionGenerator(/*isCpuOptimized=*/false),
+ fakeDeviceInitParams,
+ 'immersive-ar', {
+ requiredFeatures: ['depth-sensing'],
+ depthSensing: VALID_DEPTH_CONFIG_GPU_USAGE,
+ });
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https.html b/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https.html
new file mode 100644
index 0000000000..9fc2e6a5f8
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_incorrectUsage.https.html
@@ -0,0 +1,46 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/webxr_util.js"></script>
+<script src="../../resources/webxr_test_asserts.js"></script>
+<script src="../../resources/webxr_test_constants.js"></script>
+<script src="../../resources/webxr_test_constants_fake_depth.js"></script>
+<script src="../incorrectUsageTests.js"></script>
+
+<script>
+
+const fakeDeviceInitParams = {
+ supportedModes: ["immersive-ar"],
+ views: VALID_VIEWS,
+ supportedFeatures: ALL_FEATURES,
+};
+
+const incorrectUsageTestFunctionTryGetCpuOnGpu = function (session, controller, t, sessionObjects) {
+ return session.requestReferenceSpace('viewer').then((viewerSpace) => {
+ let done = false;
+
+ session.requestAnimationFrame((time, frame) => {
+ const pose = frame.getViewerPose(viewerSpace);
+ for(const view of pose.views) {
+ t.step(() => {
+ assert_throws_dom("InvalidStateError", () => frame.getDepthInformation(view),
+ "XRFrame.getDepthInformation() should throw when depth sensing is in `gpu-optimized` usage mode");
+ });
+ }
+
+ done = true;
+ });
+
+ return t.step_wait(() => done);
+ });
+};
+
+xr_session_promise_test("Ensures XRCPUDepthInformation is not obtainable in `gpu-optimized` usage mode",
+ incorrectUsageTestFunctionTryGetCpuOnGpu,
+ fakeDeviceInitParams,
+ 'immersive-ar', {
+ requiredFeatures: ['depth-sensing'],
+ depthSensing: VALID_DEPTH_CONFIG_GPU_USAGE,
+ });
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https.html b/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https.html
new file mode 100644
index 0000000000..ecd0d479f7
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/gpu/depth_sensing_gpu_staleView.https.html
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="../../resources/webxr_util.js"></script>
+<script src="../../resources/webxr_test_asserts.js"></script>
+<script src="../../resources/webxr_test_constants.js"></script>
+<script src="../../resources/webxr_test_constants_fake_depth.js"></script>
+<script src="../staleViewsTests.js"></script>
+
+<script>
+
+const fakeDeviceInitParams = {
+ supportedModes: ["immersive-ar"],
+ views: VALID_VIEWS,
+ supportedFeatures: ALL_FEATURES,
+};
+
+xr_session_promise_test("Ensures getDepthInformation() throws when not run with stale XRView, `gpu-optimized`",
+ staleViewsTestFunctionGenerator(/*isCpuOptimized=*/false),
+ fakeDeviceInitParams,
+ 'immersive-ar', {
+ requiredFeatures: ['depth-sensing'],
+ depthSensing: VALID_DEPTH_CONFIG_GPU_USAGE,
+ });
+
+</script>
diff --git a/testing/web-platform/tests/webxr/depth-sensing/inactiveFrameTests.js b/testing/web-platform/tests/webxr/depth-sensing/inactiveFrameTests.js
new file mode 100644
index 0000000000..b310f01ef8
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/inactiveFrameTests.js
@@ -0,0 +1,36 @@
+'use strict';
+
+const inactiveFrameTestFunctionGenerator = function(isCpuOptimized) {
+ return (session, controller, t, sessionObjects) => {
+ return session.requestReferenceSpace('viewer').then((viewerSpace) => {
+ let callbacksKickedOff = false;
+ let callbackCounter = 0;
+
+ const glBinding = new XRWebGLBinding(session, sessionObjects.gl);
+
+ const rafCb = function(time, frame) {
+ const pose = frame.getViewerPose(viewerSpace);
+ for(const view of pose.views) {
+ const callback = () => {
+ t.step(() => {
+ assert_throws_dom("InvalidStateError",
+ () => isCpuOptimized ? frame.getDepthInformation(view)
+ : glBinding.getDepthInformation(view),
+ "getDepthInformation() should throw when ran outside RAF");
+ });
+ callbackCounter--;
+ }
+
+ t.step_timeout(callback, 10);
+ callbackCounter++;
+ }
+
+ callbacksKickedOff = true;
+ };
+
+ session.requestAnimationFrame(rafCb);
+
+ return t.step_wait(() => callbacksKickedOff && (callbackCounter == 0));
+ });
+ };
+};
diff --git a/testing/web-platform/tests/webxr/depth-sensing/staleViewsTests.js b/testing/web-platform/tests/webxr/depth-sensing/staleViewsTests.js
new file mode 100644
index 0000000000..b1f11c9651
--- /dev/null
+++ b/testing/web-platform/tests/webxr/depth-sensing/staleViewsTests.js
@@ -0,0 +1,39 @@
+'use strict';
+
+const staleViewsTestFunctionGenerator = function(isCpuOptimized) {
+ return (session, controller, t, sessionObjects) => {
+ let done = false;
+
+ const staleViews = new Set();
+
+ return session.requestReferenceSpace('viewer').then((viewerSpace) => {
+ const glBinding = new XRWebGLBinding(session, sessionObjects.gl);
+
+ const secondRafCb = function(time, frame) {
+ for(const view of staleViews) {
+ t.step(() => {
+ assert_throws_dom("InvalidStateError",
+ () => isCpuOptimized ? frame.getDepthInformation(view)
+ : glBinding.getDepthInformation(view),
+ "getDepthInformation() should throw when run with stale XRView");
+ });
+ }
+
+ done = true;
+ };
+
+ const firstRafCb = function(time, frame) {
+ const pose = frame.getViewerPose(viewerSpace);
+ for(const view of pose.views) {
+ staleViews.add(view);
+ }
+
+ session.requestAnimationFrame(secondRafCb);
+ };
+
+ session.requestAnimationFrame(firstRafCb);
+
+ return t.step_wait(() => done);
+ });
+ };
+}; \ No newline at end of file