summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/xrWebGLLayer_viewports.https.html
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/xrWebGLLayer_viewports.https.html
parentInitial commit. (diff)
downloadfirefox-43a97878ce14b72f0981164f87f2e35e14151312.tar.xz
firefox-43a97878ce14b72f0981164f87f2e35e14151312.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/xrWebGLLayer_viewports.https.html')
-rw-r--r--testing/web-platform/tests/webxr/xrWebGLLayer_viewports.https.html69
1 files changed, 69 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/xrWebGLLayer_viewports.https.html b/testing/web-platform/tests/webxr/xrWebGLLayer_viewports.https.html
new file mode 100644
index 0000000000..8654e9e587
--- /dev/null
+++ b/testing/web-platform/tests/webxr/xrWebGLLayer_viewports.https.html
@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/webxr_test_constants.js"></script>
+<script src="resources/webxr_util.js"></script>
+<script src="resources/webxr_test_asserts.js"></script>
+
+<script>
+
+let immersiveTestName = "XRWebGLLayer reports a valid viewports for immersive sessions";
+let inlineTestName = "XRWebGLLayer reports a valid viewports for inline sessions";
+
+let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
+
+let testFunction = function(session, fakeDeviceController, t) {
+ return session.requestReferenceSpace('viewer')
+ .then((space) => new Promise((resolve) => {
+ function onFrame(time, xrFrame) {
+ let viewer_pose = xrFrame.getViewerPose(space);
+
+ let layer = xrFrame.session.renderState.baseLayer;
+ for (view of viewer_pose.views) {
+ let viewport = layer.getViewport(view);
+
+ t.step(() => {
+ // Ensure the returned object is an XRViewport object
+ assert_not_equals(viewport, null);
+ assert_true(viewport instanceof XRViewport);
+
+ // Ensure the viewport dimensions are valid
+ assert_greater_than_equal(viewport.x, 0);
+ assert_greater_than_equal(viewport.y, 0);
+ assert_greater_than_equal(viewport.width, 1);
+ assert_greater_than_equal(viewport.height, 1);
+ });
+
+ // Ensure none of the viewports overlap
+ for (other of viewer_pose.views) {
+ if (view !== other) {
+ let otherport = layer.getViewport(other);
+ let no_overlap = (viewport.x + viewport.width <= otherport.x) ||
+ (otherport.x + otherport.width <= viewport.x) ||
+ (viewport.y + viewport.height <= otherport.y) ||
+ (otherport.y + otherport.height <= viewport.y);
+
+ t.step(() => {
+ assert_true(no_overlap, "Overlap between viewport " + view.eye + " and " + other.eye);
+ });
+ }
+ }
+ }
+
+ // Finished test.
+ resolve();
+ }
+
+ session.requestAnimationFrame(onFrame);
+ }));
+};
+
+xr_session_promise_test(immersiveTestName, testFunction,
+ fakeDeviceInitParams, 'immersive-vr');
+xr_session_promise_test(immersiveTestName + ' with secondary views requested', testFunction,
+ fakeDeviceInitParams, 'immersive-vr', {'optionalFeatures': ['secondary-views']});
+xr_session_promise_test(inlineTestName, testFunction,
+ fakeDeviceInitParams, 'inline');
+xr_session_promise_test(inlineTestName + ' with secondary views requested', testFunction,
+ fakeDeviceInitParams, 'inline', {'optionalFeatures': ['secondary-views']});
+</script>