diff options
-rw-r--r-- | components/script/dom/fakexrdevice.rs | 31 | ||||
-rw-r--r-- | components/script/dom/webidls/FakeXRDevice.webidl | 8 | ||||
-rw-r--r-- | components/script/dom/xrtest.rs | 16 | ||||
-rw-r--r-- | tests/wpt/mozilla/meta/MANIFEST.json | 6 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/webxr/create_session.html | 7 | ||||
-rw-r--r-- | tests/wpt/mozilla/tests/webxr/obtain_frame.html | 2 |
6 files changed, 30 insertions, 40 deletions
diff --git a/components/script/dom/fakexrdevice.rs b/components/script/dom/fakexrdevice.rs index 885d05894ce..070ba5fa89c 100644 --- a/components/script/dom/fakexrdevice.rs +++ b/components/script/dom/fakexrdevice.rs @@ -54,16 +54,10 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<(MockVRView, MockVRView)> _ => return Err(Error::NotSupported), }; - // can be removed once https://github.com/servo/servo/issues/23640 is fixed - let (position_l, position_r) = match (&left.viewOffset.position, &right.viewOffset.position) { - (&Some(ref l), &Some(ref r)) => (l, r), - _ => return Err(Error::Type("Must specify position".into())), - }; - if left.projectionMatrix.len() != 16 || right.projectionMatrix.len() != 16 || - position_l.len() != 3 || - position_r.len() != 3 + left.viewOffset.position.len() != 3 || + right.viewOffset.position.len() != 3 { return Err(Error::Type("Incorrectly sized array".into())); } @@ -77,9 +71,9 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<(MockVRView, MockVRView)> let mut offset_l = [0.; 3]; let mut offset_r = [0.; 3]; - let v: Vec<_> = position_l.iter().map(|x| **x).collect(); + let v: Vec<_> = left.viewOffset.position.iter().map(|x| **x).collect(); offset_l.copy_from_slice(&v); - let v: Vec<_> = position_r.iter().map(|x| **x).collect(); + let v: Vec<_> = right.viewOffset.position.iter().map(|x| **x).collect(); offset_r.copy_from_slice(&v); let left = MockVRView { projection: proj_l, @@ -93,25 +87,14 @@ pub fn get_views(views: &[FakeXRViewInit]) -> Fallible<(MockVRView, MockVRView)> } pub fn get_origin(origin: &FakeXRRigidTransformInit) -> Fallible<([f32; 3], [f32; 4])> { - // can be removed once https://github.com/servo/servo/issues/23640 is fixed - let position = if let Some(ref position) = origin.position { - position - } else { - return Err(Error::Type("Missing position field".into())); - }; - let orientation = if let Some(ref orientation) = origin.orientation { - orientation - } else { - return Err(Error::Type("Missing orientation field".into())); - }; - if position.len() != 4 || orientation.len() != 4 { + if origin.position.len() != 3 || origin.orientation.len() != 4 { return Err(Error::Type("Incorrectly sized array".into())); } let mut p = [0.; 3]; let mut o = [0.; 4]; - let v: Vec<_> = position.iter().map(|x| **x).collect(); + let v: Vec<_> = origin.position.iter().map(|x| **x).collect(); p.copy_from_slice(&v[0..3]); - let v: Vec<_> = orientation.iter().map(|x| **x).collect(); + let v: Vec<_> = origin.orientation.iter().map(|x| **x).collect(); o.copy_from_slice(&v); Ok((p, o)) diff --git a/components/script/dom/webidls/FakeXRDevice.webidl b/components/script/dom/webidls/FakeXRDevice.webidl index d151ce12166..5e310c4d75f 100644 --- a/components/script/dom/webidls/FakeXRDevice.webidl +++ b/components/script/dom/webidls/FakeXRDevice.webidl @@ -14,8 +14,7 @@ interface FakeXRDevice { // Promise<void> disconnect(); // Sets the origin of the viewer - // dict must be optional because of https://github.com/servo/servo/issues/23640 - [Throws] void setViewerOrigin(optional FakeXRRigidTransformInit origin, optional boolean emulatedPosition = false); + [Throws] void setViewerOrigin(FakeXRRigidTransformInit origin, optional boolean emulatedPosition = false); // // Simulates devices focusing and blurring sessions. // void simulateVisibilityChange(XRVisibilityState); @@ -53,7 +52,6 @@ dictionary FakeXRBoundsPoint { }; dictionary FakeXRRigidTransformInit { - // should be required, see https://github.com/servo/servo/issues/23640 - sequence<float> position; - sequence<float> orientation; + required sequence<float> position; + required sequence<float> orientation; }; diff --git a/components/script/dom/xrtest.rs b/components/script/dom/xrtest.rs index 7f0b8a43ef9..6808ce262cd 100644 --- a/components/script/dom/xrtest.rs +++ b/components/script/dom/xrtest.rs @@ -52,12 +52,16 @@ impl XRTestMethods for XRTest { return p; } - let origin = match get_origin(&init.viewerOrigin) { - Ok(origin) => origin, - Err(e) => { - p.reject_error(e); - return p; - }, + let origin = if let Some(ref o) = init.viewerOrigin { + match get_origin(&o) { + Ok(origin) => origin, + Err(e) => { + p.reject_error(e); + return p; + }, + } + } else { + Default::default() }; let views = match get_views(&init.views) { diff --git a/tests/wpt/mozilla/meta/MANIFEST.json b/tests/wpt/mozilla/meta/MANIFEST.json index c32bb3cf8d4..9d98e1d36c5 100644 --- a/tests/wpt/mozilla/meta/MANIFEST.json +++ b/tests/wpt/mozilla/meta/MANIFEST.json @@ -19683,15 +19683,15 @@ "testharness" ], "webxr/create_session.html": [ - "306ab85d3b1b914d2dd7c11a3b03dccd990148ae", + "ddec5add27b84e8e2febe3789d326f1e9fb7f508", "testharness" ], "webxr/obtain_frame.html": [ - "99d8fd1ef152e4030444c3ca42482d28c3e855d3", + "e2b4424d5779baedf6bdb50f1b3151336f31a4cb", "testharness" ], "webxr/resources/webxr-util.js": [ - "b644ba72ac801bc8f659e9678d31ab23db0b7281", + "554c1c183d3710e54dc60704dad0aac542ffd67c", "support" ] }, diff --git a/tests/wpt/mozilla/tests/webxr/create_session.html b/tests/wpt/mozilla/tests/webxr/create_session.html index 306ab85d3b1..ddec5add27b 100644 --- a/tests/wpt/mozilla/tests/webxr/create_session.html +++ b/tests/wpt/mozilla/tests/webxr/create_session.html @@ -2,11 +2,16 @@ <head> <script src="/resources/testharness.js"></script> <script src="/resources/testharnessreport.js"></script> + <script src="./resources/webxr-util.js"></script> </head> <body> <script> async_test(function(t) { - navigator.xr.test.simulateDeviceConnection({supportsImmersive: true}).then((m) => { + navigator.xr.test.simulateDeviceConnection({ + supportsImmersive: true, + views: TEST_VIEWS, + viewerOrigin: {position: [0.5, 0.1, 0.1], orientation: [1, 0, 0, 1] } + }).then((m) => { return navigator.xr.requestSession({mode: "immersive-vr"}) }).then(() => t.done()); }); diff --git a/tests/wpt/mozilla/tests/webxr/obtain_frame.html b/tests/wpt/mozilla/tests/webxr/obtain_frame.html index d4ebadeda76..e2b4424d577 100644 --- a/tests/wpt/mozilla/tests/webxr/obtain_frame.html +++ b/tests/wpt/mozilla/tests/webxr/obtain_frame.html @@ -14,7 +14,7 @@ let mock = await navigator.xr.test.simulateDeviceConnection({ supportsImmersive: true, views: TEST_VIEWS, - viewerOrigin: {position: [0.5, 0.1, 0.1, 1], orientation: [1, 0, 0, 1] } + viewerOrigin: {position: [0.5, 0.1, 0.1], orientation: [1, 0, 0, 1] } }); let session = await navigator.xr.requestSession({mode: "immersive-vr"}); await session.updateRenderState({"baseLayer": new XRWebGLLayer(session, gl, {})}); |