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>
This commit is contained in:
Taym Haddadi 2024-10-16 17:12:37 +01:00 committed by GitHub
parent cde6931f4b
commit 2115267328
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 26 additions and 6 deletions

View file

@ -5,7 +5,7 @@
// https://immersive-web.github.io/layers/#XRWebGLBindingtype
[SecureContext, Exposed=Window, Pref="dom.webxr.layers.enabled"]
interface XRWebGLBinding {
constructor(XRSession session, XRWebGLRenderingContext context);
[Throws] constructor(XRSession session, XRWebGLRenderingContext context);
// readonly attribute double nativeProjectionScaleFactor;

View file

@ -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 contexts XR compatible boolean is false.
Ok(XRWebGLBinding::new(
global, proto, session, &context, can_gc,
))
}
/// <https://immersive-web.github.io/layers/#dom-xrwebglbinding-createprojectionlayer>

View file

@ -1,7 +1,7 @@
[xrWebGLBinding_constructor.https.html]
expected: ERROR
[Ensure that XRWebGLBinding's constructor throws appropriate errors using webgl2]
expected: FAIL
expected: NOTRUN
[Ensure that XRWebGLBinding's constructor throws appropriate errors using webgl]
expected: FAIL
expected: TIMEOUT