summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/webxr/light-estimation
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/webxr/light-estimation
parentInitial commit. (diff)
downloadthunderbird-upstream.tar.xz
thunderbird-upstream.zip
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webxr/light-estimation')
-rw-r--r--testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_oldSession.https.html57
-rw-r--r--testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_staleFrame.https.html47
-rw-r--r--testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_valid.https.html104
-rw-r--r--testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_ended.https.html21
-rw-r--r--testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_notEnabled.https.html18
-rw-r--r--testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_valid.https.html27
-rw-r--r--testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html95
7 files changed, 369 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_oldSession.https.html b/testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_oldSession.https.html
new file mode 100644
index 0000000000..7a896aa9ff
--- /dev/null
+++ b/testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_oldSession.https.html
@@ -0,0 +1,57 @@
+<!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>
+ let testName = "getLightEstimate rejects if probe is from wrong session";
+ let testFunction = (session, controller, t, sessionObjects) => new Promise((resolve) => {
+ let staleLightProbe = null;
+ let newSession = null;
+
+ function onFrame(time, frame) {
+ t.step(() => {
+ // Attempting to get a lightEstimate with a probe created for a
+ // different session should throw an exception.
+ assert_throws_dom('InvalidStateError', () => frame.getLightEstimate(staleLightProbe));
+ });
+
+ // Cleanup the new session we made and then resolve.
+ resolve(newSession.end());
+ }
+
+ // Request a default lightProbe
+ let probeInit = {reflectionFormat: session.preferredReflectionFormat };
+ session.requestLightProbe(probeInit).then((probe) => {
+ staleLightProbe = probe;
+ return session.end();
+ }).then(() => {
+ // Need to request a new session.
+ navigator.xr.test.simulateUserActivation( () => {
+ navigator.xr.requestSession('immersive-ar', {'requiredFeatures': ['light-estimation']})
+ .then((session2) => {
+
+ let glLayer = new XRWebGLLayer(session2, sessionObjects.gl);
+ glLayer.context = sessionObjects.gl;
+ // Session must have a baseLayer or frame requests will be ignored.
+ session2.updateRenderState({
+ baseLayer: glLayer
+ });
+ newSession = session2;
+ newSession.requestAnimationFrame(onFrame);
+ });
+ });
+ });
+ });
+
+ xr_session_promise_test(
+ testName,
+ testFunction,
+ IMMERSIVE_AR_DEVICE,
+ 'immersive-ar',
+ {'requiredFeatures': ['light-estimation']});
+
+ </script>
+</body>
diff --git a/testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_staleFrame.https.html b/testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_staleFrame.https.html
new file mode 100644
index 0000000000..499a30d561
--- /dev/null
+++ b/testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_staleFrame.https.html
@@ -0,0 +1,47 @@
+<!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>
+ let testName = "Cannot get XrLightEstimate from stale frame";
+ let testFunction = (session, controller, t) => new Promise((resolve) => {
+ let lightProbe = null;
+ let staleFrame = null;
+
+ function onFrame(time, frame) {
+ // Try to get the light estimate (even if it's null), it shouldn't throw.
+ let estimate = frame.getLightEstimate(lightProbe);
+ staleFrame = frame;
+
+ t.step_timeout(afterFrame, 10);
+ }
+
+ function afterFrame() {
+ t.step(() => {
+ // Attempting to call a method on the frame outside the callback that
+ // originally provided it should cause it to throw an exception.
+ assert_throws_dom('InvalidStateError', () => staleFrame.getLightEstimate(lightProbe));
+ });
+
+ resolve();
+ }
+
+ // Request a default lightProbe
+ let probeInit = {reflectionFormat: session.preferredReflectionFormat};
+ session.requestLightProbe(probeInit).then((probe) => {
+ lightProbe = probe;
+ session.requestAnimationFrame(onFrame);
+ });
+ });
+
+ xr_session_promise_test(
+ testName,
+ testFunction,
+ IMMERSIVE_AR_DEVICE,
+ 'immersive-ar', {'requiredFeatures': ['light-estimation']});
+
+ </script>
+</body>
diff --git a/testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_valid.https.html b/testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_valid.https.html
new file mode 100644
index 0000000000..68c5d841fc
--- /dev/null
+++ b/testing/web-platform/tests/webxr/light-estimation/xrFrame_getLightEstimate_valid.https.html
@@ -0,0 +1,104 @@
+<!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_asserts.js"></script>
+ <script src="../resources/webxr_test_constants.js"></script>
+
+ <script>
+ let testName = "Can get XRLightEstimates during frame";
+ let fakeDeviceInitParams = IMMERSIVE_AR_DEVICE;
+
+ let fakeEstimateCoefficients = [
+ 0.01, 0.02, 0.03,
+ 0.04, 0.05, 0.06,
+ 0.07, 0.08, 0.09,
+ 0.10, 0.11, 0.12,
+ 0.13, 0.14, 0.15,
+ 0.16, 0.17, 0.18,
+ 0.19, 0.20, 0.21,
+ 0.22, 0.23, 0.24,
+ 0.25, 0.26, 0.27
+ ];
+
+ let fakeDirectionInit = { x: 1.0, y: 0.0, z: 0.0, w: 0.0 };
+ let fakeIntensityInit = { x: 0.0, y: 0.0, z: 1.0, w: 1.0 };
+
+ let testFunction = (session, controller, t) => new Promise((resolve) => {
+ let lightProbe = null;
+ function onFrameWithNoLightEstimation(time, frame) {
+ let estimate = frame.getLightEstimate(lightProbe);
+ t.step(() => {
+ assert_equals(estimate, null);
+ });
+
+ controller.setLightEstimate({
+ sphericalHarmonicsCoefficients: fakeEstimateCoefficients
+ });
+
+ requestSkipAnimationFrame(session, onFrameWithCoefficients);
+ }
+
+ function onFrameWithCoefficients(time, frame) {
+ let estimate = frame.getLightEstimate(lightProbe);
+ t.step(() => {
+ assert_not_equals(estimate, null);
+ assert_equals(estimate.sphericalHarmonicsCoefficients.length, 27);
+ assert_point_approx_equals(estimate.primaryLightDirection, { x: 0.0, y: 1.0, z: 0.0, w: 0.0 });
+ assert_point_approx_equals(estimate.primaryLightIntensity, { x: 0.0, y: 0.0, z: 0.0, w: 1.0 });
+ });
+
+ controller.setLightEstimate({
+ sphericalHarmonicsCoefficients: fakeEstimateCoefficients,
+ primaryLightDirection: fakeDirectionInit,
+ });
+
+ requestSkipAnimationFrame(session, onFrameWithDirection);
+ }
+
+ function onFrameWithDirection(time, frame) {
+ let estimate = frame.getLightEstimate(lightProbe);
+ t.step(() => {
+ assert_not_equals(estimate, null);
+ assert_equals(estimate.sphericalHarmonicsCoefficients.length, 27);
+ assert_point_approx_equals(estimate.primaryLightDirection, fakeDirectionInit);
+ assert_point_approx_equals(estimate.primaryLightIntensity, { x: 0.0, y: 0.0, z: 0.0, w: 1.0 });
+ });
+
+ controller.setLightEstimate({
+ sphericalHarmonicsCoefficients: fakeEstimateCoefficients,
+ primaryLightDirection: fakeDirectionInit,
+ primaryLightIntensity: fakeIntensityInit
+ });
+
+ requestSkipAnimationFrame(session, onFrameWithDirectionAndIntensity);
+ }
+
+ function onFrameWithDirectionAndIntensity(time, frame) {
+ let estimate = frame.getLightEstimate(lightProbe);
+ t.step(() => {
+ assert_not_equals(estimate, null);
+ assert_equals(estimate.sphericalHarmonicsCoefficients.length, 27);
+ assert_point_approx_equals(estimate.primaryLightDirection, fakeDirectionInit);
+ assert_point_approx_equals(estimate.primaryLightIntensity, fakeIntensityInit);
+ });
+
+ resolve();
+ }
+
+ // Request a default lightProbe
+ session.requestLightProbe({reflectionFormat: session.preferredReflectionFormat }).then((probe) => {
+ lightProbe = probe;
+ session.requestAnimationFrame(onFrameWithNoLightEstimation);
+ });
+ });
+
+ xr_session_promise_test(
+ testName,
+ testFunction,
+ IMMERSIVE_AR_DEVICE,
+ 'immersive-ar', {'requiredFeatures': ['light-estimation']});
+
+ </script>
+</body>
diff --git a/testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_ended.https.html b/testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_ended.https.html
new file mode 100644
index 0000000000..cc046499f9
--- /dev/null
+++ b/testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_ended.https.html
@@ -0,0 +1,21 @@
+<!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>
+ xr_session_promise_test(
+ "getLightProbe rejects on an ended session",
+ (session, controller, t) => {
+ return session.end().then(() => {
+ return promise_rejects_dom(t, "InvalidStateError", session.requestLightProbe())
+ })
+ },
+ IMMERSIVE_AR_DEVICE,
+ 'immersive-ar',
+ {'requiredFeatures': ['light-estimation']});
+
+ </script>
+</body>
diff --git a/testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_notEnabled.https.html b/testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_notEnabled.https.html
new file mode 100644
index 0000000000..23fe1c6ec5
--- /dev/null
+++ b/testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_notEnabled.https.html
@@ -0,0 +1,18 @@
+<!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>
+ let fakeDeviceInitParams = IMMERSIVE_AR_DEVICE;
+
+ xr_session_promise_test(
+ "getLightProbe rejects if not enabled on session",
+ (session, controller, t) => promise_rejects_dom(t, "NotSupportedError", session.requestLightProbe()),
+ IMMERSIVE_AR_DEVICE,
+ 'immersive-ar');
+
+ </script>
+</body>
diff --git a/testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_valid.https.html b/testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_valid.https.html
new file mode 100644
index 0000000000..074c7fd1dc
--- /dev/null
+++ b/testing/web-platform/tests/webxr/light-estimation/xrSession_getLightProbe_valid.https.html
@@ -0,0 +1,27 @@
+<!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>
+ let testName = "Can create valid XRLightProbe objects";
+
+ function testFunction(session, controller, t) {
+ // Request a default lightProbe
+ let defaultProbe = session.requestLightProbe();
+ let srgba8Probe = session.requestLightProbe({reflectionFormat: "srgba8"});
+ let preferredProbe = session.requestLightProbe({reflectionFormat: session.preferredReflectionFormat });
+
+ return Promise.all([defaultProbe, srgba8Probe, preferredProbe]);
+ }
+
+ xr_session_promise_test(
+ testName,
+ testFunction,
+ IMMERSIVE_AR_DEVICE,
+ 'immersive-ar', {'requiredFeatures': ['light-estimation']});
+
+ </script>
+</body>
diff --git a/testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html b/testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html
new file mode 100644
index 0000000000..a68a0f2b51
--- /dev/null
+++ b/testing/web-platform/tests/webxr/light-estimation/xrWebGLBinding_getReflectionCubeMap.https.html
@@ -0,0 +1,95 @@
+<!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>
+ let testName = "Test that getReflectionCubeMap returns or throws appropriately without a reflection map.";
+
+ let testFunction = (session, controller, t, sessionObjects) => new Promise((resolve) => {
+ let halfFloatExt = sessionObjects.gl.getExtension('OES_texture_half_float');
+ // The preferredReflectionFormat used below is set to "rgba16f" by default.
+ // This means half float textures must be supported in order to run this test
+ if (!halfFloatExt) {
+ resolve(session.end());
+ } else {
+ let debug = xr_debug.bind(this, 'testFunction');
+ let lightProbe1 = null;
+ let binding1 = new XRWebGLBinding(session, sessionObjects.gl);
+
+ // Request a default lightProbe
+ session.requestLightProbe({reflectionFormat: session.preferredReflectionFormat }).then((probe) => {
+ // Stash and end session.
+ lightProbe1 = probe;
+
+ debug("Querying first pair");
+ t.step(() => {
+ assert_equals(
+ binding1.getReflectionCubeMap(lightProbe1),
+ null,
+ "Active binding and light probe shouldn't throw when requesting cube map");
+ });
+
+ return session.end();
+ }).then(() => {
+ // Need to request a new session.
+ navigator.xr.test.simulateUserActivation( () => {
+ navigator.xr.requestSession('immersive-ar', { 'requiredFeatures': ['light-estimation'] })
+ .then((newSession) => {
+ let newBinding = new XRWebGLBinding(newSession, sessionObjects.gl);
+ newSession.requestLightProbe({ reflectionFormat: newSession.preferredReflectionFormat }).then((newProbe) => {
+ t.step(() => {
+ debug("Querying second pair");
+ assert_equals(
+ newBinding.getReflectionCubeMap(newProbe),
+ null,
+ "Newly created binding and light probe shouldn't throw");
+
+ debug("Querying old pair");
+ assert_throws_dom(
+ "InvalidStateError",
+ () => binding1.getReflectionCubeMap(lightProbe1),
+ "Binding created with an ended session should throw InvalidStateError");
+ debug("Querying mismatched pair");
+ assert_throws_dom(
+ "InvalidStateError",
+ () => newBinding.getReflectionCubeMap(lightProbe1),
+ "Querying binding with a probe with a different backing session should throw InvalidStateError");
+ });
+ debug("losing context");
+
+ // Trigger a context loss and verify that we are unable to get the reflectionCubeMap.
+ let lose_context_ext = sessionObjects.gl.getExtension('WEBGL_lose_context');
+
+ sessionObjects.gl.canvas.addEventListener('webglcontextlost', (ev) => {
+ ev.preventDefault();
+
+ t.step(() => {
+ assert_throws_dom(
+ "InvalidStateError",
+ () => newBinding.getReflectionCubeMap(newProbe),
+ "Querying for reflection cube map on a binding with context loss should throw InvalidStateError");
+ });
+
+ resolve(newSession.end());
+ });
+
+ lose_context_ext.loseContext();
+ }); // Request second light probe
+ }); // Request second session
+ }); // SimulateUserActivation
+ }); // .then on session end
+ } // halfFloatExt
+ }); // testFunction
+
+ xr_session_promise_test(
+ testName,
+ testFunction,
+ IMMERSIVE_AR_DEVICE,
+ 'immersive-ar',
+ {'requiredFeatures': ['light-estimation']});
+
+ </script>
+</body>