diff options
author | Taym Haddadi <haddadi.taym@gmail.com> | 2024-10-16 17:12:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-16 16:12:37 +0000 |
commit | 21152673282b7ac03cee5d97d46fe368b379a297 (patch) | |
tree | 5072cfdf06455ec98a457608e9ddba6145145f67 /components/script/dom/xrwebglbinding.rs | |
parent | cde6931f4bcb6832d3fbd37c3930b63e759cc279 (diff) | |
download | servo-21152673282b7ac03cee5d97d46fe368b379a297.tar.gz servo-21152673282b7ac03cee5d97d46fe368b379a297.zip |
Add missing XRWebGLBinding constructor spec steps (#33731)
* Add missing XRWebGLBinding constructor spec steps
Signed-off-by: Taym <haddadi.taym@gmail.com>
* Update test expectation
Signed-off-by: Taym <haddadi.taym@gmail.com>
---------
Signed-off-by: Taym <haddadi.taym@gmail.com>
Diffstat (limited to 'components/script/dom/xrwebglbinding.rs')
-rw-r--r-- | components/script/dom/xrwebglbinding.rs | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/components/script/dom/xrwebglbinding.rs b/components/script/dom/xrwebglbinding.rs index 6e05543d2f9..145937c0227 100644 --- a/components/script/dom/xrwebglbinding.rs +++ b/components/script/dom/xrwebglbinding.rs @@ -7,6 +7,7 @@ use js::rust::HandleObject; use crate::dom::bindings::codegen::Bindings::XRViewBinding::XREye; use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::XRWebGLBinding_Binding::XRWebGLBindingMethods; +use crate::dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContext_Binding::WebGLRenderingContextMethods; use crate::dom::bindings::codegen::Bindings::XRWebGLBindingBinding::{ XRCubeLayerInit, XRCylinderLayerInit, XREquirectLayerInit, XRProjectionLayerInit, XRQuadLayerInit, XRTextureType, @@ -69,14 +70,33 @@ impl XRWebGLBindingMethods for XRWebGLBinding { can_gc: CanGc, session: &XRSession, context: WebGLRenderingContextOrWebGL2RenderingContext, - ) -> DomRoot<XRWebGLBinding> { + ) -> Fallible<DomRoot<XRWebGLBinding>> { let context = match context { WebGLRenderingContextOrWebGL2RenderingContext::WebGLRenderingContext(ctx) => ctx, WebGLRenderingContextOrWebGL2RenderingContext::WebGL2RenderingContext(ctx) => { ctx.base_context() }, }; - XRWebGLBinding::new(global, proto, session, &context, can_gc) + // Step 2 + if session.is_ended() { + return Err(Error::InvalidState); + } + + // step 3 + if context.IsContextLost() { + return Err(Error::InvalidState); + } + + // Step 4 + if !session.is_immersive() { + return Err(Error::InvalidState); + }; + + // Step 5 throw an InvalidStateError If context’s XR compatible boolean is false. + + Ok(XRWebGLBinding::new( + global, proto, session, &context, can_gc, + )) } /// <https://immersive-web.github.io/layers/#dom-xrwebglbinding-createprojectionlayer> |