diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/webxr/layers | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/webxr/layers')
3 files changed, 149 insertions, 0 deletions
diff --git a/testing/web-platform/tests/webxr/layers/META.yml b/testing/web-platform/tests/webxr/layers/META.yml new file mode 100644 index 0000000000..117c1adf02 --- /dev/null +++ b/testing/web-platform/tests/webxr/layers/META.yml @@ -0,0 +1 @@ +spec: https://immersive-web.github.io/layers/ diff --git a/testing/web-platform/tests/webxr/layers/xrSession_updateRenderState.https.html b/testing/web-platform/tests/webxr/layers/xrSession_updateRenderState.https.html new file mode 100644 index 0000000000..52f4b087bc --- /dev/null +++ b/testing/web-platform/tests/webxr/layers/xrSession_updateRenderState.https.html @@ -0,0 +1,65 @@ +<!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> + + function testUpdateRenderState(xrSession, deviceController, t, { gl, glLayer }) { + return new Promise((resolve, reject) => { + const baseLayer = new XRWebGLLayer(xrSession, gl); + const singleLayer = [ + new XRWebGLLayer(xrSession, gl), + ]; + const multipleLayers = [ + new XRWebGLLayer(xrSession, gl), + new XRWebGLLayer(xrSession, gl) + ]; + const duplicateLayers = [ + baseLayer, + new XRWebGLLayer(xrSession, gl), + baseLayer + ]; + const layersFeatureEnabled = xrSession.enabledFeatures.includes('layers'); + + t.step(() => { + assert_throws_dom('NotSupportedError', () => xrSession.updateRenderState({ baseLayer, layers: singleLayer }), "XRSession should throw an error when updating render state with both a baseLayer and layers set."); + }); + + t.step(() => { + const updateRenderStateMultilayer = () => xrSession.updateRenderState({ layers: multipleLayers }); + if (layersFeatureEnabled) { + try { + updateRenderStateMultilayer(); + } catch (err) { + reject("XRSession should support render state with multiple layers if the layers feature is enabled."); + } + } else { + assert_throws_dom('NotSupportedError', updateRenderStateMultilayer, "XRSession should be able to updateRenderState with multiple layers only if the layers feature is enabled."); + } + }); + + if (layersFeatureEnabled) { + t.step(() => { + assert_throws_js(TypeError, () => xrSession.updateRenderState({ layers: duplicateLayers }), "XRSession should throw a TypeError when updating render state with duplicate layers."); + }); + } + + t.step(() => { + navigator.xr.requestSession('inline', {}).then((otherSession) => { + const otherSessionLayer = [ new XRWebGLLayer(otherSession, gl) ]; + assert_throws_js(TypeError, () => xrSession.updateRenderState({ layers: otherSessionLayer }), "XRSession should throw a TypeError when updating render state with a layer created for a different session."); + resolve(); + }); + }); + }); + } + + xr_session_promise_test("Ensure XRSession throws appropriate errors when updating render state without layers feature enabled", + testUpdateRenderState, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr', {}); + + xr_session_promise_test("Ensure XRSession throws appropriate errors when updating render state with layers feature enabled", + testUpdateRenderState, TRACKED_IMMERSIVE_DEVICE, 'immersive-vr', { requiredFeatures: ['layers'] }); + +</script> diff --git a/testing/web-platform/tests/webxr/layers/xrWebGLBinding_constructor.https.html b/testing/web-platform/tests/webxr/layers/xrWebGLBinding_constructor.https.html new file mode 100644 index 0000000000..b3457cf320 --- /dev/null +++ b/testing/web-platform/tests/webxr/layers/xrWebGLBinding_constructor.https.html @@ -0,0 +1,83 @@ +<!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> + +function testConstructor(t, gl) { + return navigator.xr.test.simulateDeviceConnection(TRACKED_IMMERSIVE_DEVICE) + .then(() => { + return navigator.xr.requestSession('inline') + .then((session) => { + try { + let webglLayerIncompatible = new XRWebGLBinding(session, gl); + assert_unreached("XRWebGLBinding should fail when created with an inline session."); + } catch (err) { + assert_equals(err.name, "InvalidStateError", "Should get InvalidStateError for creating with inline session."); + } + }); + }) + .then(() => { + return new Promise((resolve) => { + navigator.xr.test.simulateUserActivation(() => { + let xrSession = null; + navigator.xr.requestSession('immersive-vr') + .then((session) => { + xrSession = session; + t.step_func(() => { + try { + let webglLayerIncompatible = new XRWebGLBinding(xrSession, gl); + assert_unreached("XRWebGLBinding should fail when created with a context that is not XRCompatible.") + } catch (err) { + assert_equals(err.name, "InvalidStateError", "Should get InvalidStateError for non-XRCompatible context."); + } + }) + + return gl.makeXRCompatible(); + }).then(() => { + try { + let webglLayerGood = new XRWebGLBinding(xrSession, gl); + } catch (err) { + reject("XRWebGLBinding should not fail with valid arguments."); + } + + let lose_context_ext = gl.getExtension('WEBGL_lose_context'); + + gl.canvas.addEventListener('webglcontextlost', (ev) => { + ev.preventDefault(); + + try { + let webglLayerBadContext = new XRWebGLBinding(xrSession, gl); + reject("XRWebGLBinding should fail when created with a lost context."); + } catch (err) { + assert_equals(err.name, 'InvalidStateError', "Should get InvalidStateError for lost context."); + t.step_timeout(() => { lose_context_ext.restoreContext(); }, 100); + } + }); + + gl.canvas.addEventListener('webglcontextrestored', (ev) => { + resolve(xrSession.end().then(() => { + try { + let webglLayerBadSession = new XRWebGLBinding(xrSession, gl); + assert_unreached("XRWebGLBinding should fail when created with an ended session."); + } catch (err) { + assert_equals(err.name, 'InvalidStateError', "Should get InvalidStateError when passed an ended session."); + } + })); + }); + + lose_context_ext.loseContext(); + }); + }); + }); + }); +} +xr_promise_test("Ensure that XRWebGLBinding's constructor throws appropriate errors using webgl", + testConstructor, null, 'webgl'); + +xr_promise_test("Ensure that XRWebGLBinding's constructor throws appropriate errors using webgl2", + testConstructor, null, 'webgl2'); + +</script> |