Skip to content

Commit

Permalink
Gate reference space creation on requested features
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Jan 22, 2020
1 parent 8cc7c51 commit 9a04a37
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions components/script/dom/xr.rs
Expand Up @@ -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 {
Expand Down
17 changes: 16 additions & 1 deletion components/script/dom/xrsession.rs
Expand Up @@ -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
}

Expand Down

This file was deleted.

0 comments on commit 9a04a37

Please sign in to comment.