From 9a04a37c1cdd0f6f5fe5feca45f9468701fa3799 Mon Sep 17 00:00:00 2001 From: Manish Goregaokar Date: Tue, 14 Jan 2020 18:09:28 +0530 Subject: [PATCH] Gate reference space creation on requested features --- components/script/dom/xr.rs | 2 ++ components/script/dom/xrsession.rs | 17 ++++++++++++++++- ...equestReferenceSpace_features.https.html.ini | 7 ------- 3 files changed, 18 insertions(+), 8 deletions(-) delete mode 100644 tests/wpt/metadata/webxr/xrSession_requestReferenceSpace_features.https.html.ini diff --git a/components/script/dom/xr.rs b/components/script/dom/xr.rs index ab9c2c8264d..46bcc46b090 100644 --- a/components/script/dom/xr.rs +++ b/components/script/dom/xr.rs @@ -185,6 +185,8 @@ impl XRMethods for XR { let mut optional_features = vec![]; let cx = global.get_cx(); + // We are supposed to include "viewer" and on immersive devices "local" + // by default here, but this is handled directly in requestReferenceSpace() if let Some(ref r) = init.requiredFeatures { for feature in r { unsafe { diff --git a/components/script/dom/xrsession.rs b/components/script/dom/xrsession.rs index e822a69eb8e..3f7f09baa9c 100644 --- a/components/script/dom/xrsession.rs +++ b/components/script/dom/xrsession.rs @@ -559,10 +559,25 @@ impl XRSessionMethods for XRSession { p.reject_error(Error::NotSupported) }, ty => { + if ty != XRReferenceSpaceType::Viewer && + (!self.is_immersive() || ty != XRReferenceSpaceType::Local) + { + let s = ty.as_str(); + if self + .session + .borrow() + .granted_features() + .iter() + .find(|f| &**f == s) + .is_none() + { + p.reject_error(Error::NotSupported); + return p; + } + } p.resolve_native(&XRReferenceSpace::new(&self.global(), self, ty)); }, } - p } diff --git a/tests/wpt/metadata/webxr/xrSession_requestReferenceSpace_features.https.html.ini b/tests/wpt/metadata/webxr/xrSession_requestReferenceSpace_features.https.html.ini deleted file mode 100644 index 42ddb3aa092..00000000000 --- a/tests/wpt/metadata/webxr/xrSession_requestReferenceSpace_features.https.html.ini +++ /dev/null @@ -1,7 +0,0 @@ -[xrSession_requestReferenceSpace_features.https.html] - [Immersive session rejects local-floor space if not requested] - expected: FAIL - - [Non-immersive session rejects local space if not requested] - expected: FAIL -