mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-11-11 13:48:23 +02:00
Automatic update from web-platform-tests Add XRSession.viewerSpace and refactor XRFrame.getPose Also check if XRFrame is an animation frame in XRFrame.getViewerPose Instead of adding methods like GetInputSource() and ReturnTargetRay() to XRSpace, there are 3 new classes derived from XRSpace: XRViewerSpace, XRTargetRaySpace, and XRGripSpace. Instances of those classes can be passed as the first argument to XRFrame.getPose to trigger the spec-required behavior for those special cases. XRSpace has a virtual method called getPose which handles the core logic of XRFrame.getPose. That avoids having a bunch of extra checks in the XRFrame.getPose method itself. Bug: 928466 Change-Id: Ib4eeafe8f88b1d2ea2c2685b0112cbbd27f1b653 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1526788 Commit-Queue: Jacob DeWitt <jacde@chromium.org> Reviewed-by: Brandon Jones <bajones@chromium.org> Reviewed-by: Klaus Weidner <klausw@chromium.org> Cr-Commit-Position: refs/heads/master@{#642157} -- wpt-commits: 8f5d4a75c2831d59962250d4c4bb6dd22385f833 wpt-pr: 15909
56 lines
No EOL
2 KiB
HTML
56 lines
No EOL
2 KiB
HTML
<!DOCTYPE html>
|
|
<body>
|
|
<script src=/resources/testharness.js></script>
|
|
<script src=/resources/testharnessreport.js></script>
|
|
<script src="resources/webxr_util.js"></script>
|
|
<canvas></canvas>
|
|
|
|
<script>
|
|
let immersiveTestName = "XRFrame methods throw exceptions outside of the " +
|
|
"requestAnimationFrame callback for immersive sessions";
|
|
let nonImmersiveTestName = "XRFrame methods throw exceptions outside of the " +
|
|
"requestAnimationFrame callback for non-immersive sessions";
|
|
|
|
let fakeDeviceInitParams = { supportsImmersive:true };
|
|
|
|
let immersiveSessionOptions = { mode: 'immersive-vr' };
|
|
let nonImmersiveSessionOptions = { outputContext: getOutputContext() };
|
|
|
|
let testFunction = (testSession, testController, t) => new Promise((resolve) => {
|
|
let staleFrame = null;
|
|
let currentReferenceSpace = null;
|
|
|
|
function onFrame(time, xrFrame) {
|
|
t.step(() => {
|
|
assert_true(xrFrame instanceof XRFrame);
|
|
});
|
|
|
|
staleFrame = xrFrame;
|
|
step_timeout(afterFrame, 0);
|
|
}
|
|
|
|
function afterFrame() {
|
|
t.step(() => {
|
|
// Attempting to call a method on the frame outside the callback that
|
|
// originally provided it should cause it to throw an exception.
|
|
assert_throws('InvalidStateError', () => staleFrame.getViewerPose(currentReferenceSpace));
|
|
assert_throws('InvalidStateError', () => staleFrame.getPose(testSession.viewerSpace, currentReferenceSpace));
|
|
});
|
|
|
|
// Test does not complete until the this function has executed.
|
|
resolve();
|
|
}
|
|
|
|
testSession.requestReferenceSpace({ type: 'stationary', subtype: 'eye-level' }).then((referenceSpace) => {
|
|
currentReferenceSpace = referenceSpace;
|
|
testSession.requestAnimationFrame(onFrame);
|
|
});
|
|
});
|
|
|
|
xr_session_promise_test(immersiveTestName, testFunction,
|
|
fakeDeviceInitParams, immersiveSessionOptions);
|
|
xr_session_promise_test(nonImmersiveTestName, testFunction,
|
|
fakeDeviceInitParams, nonImmersiveSessionOptions);
|
|
|
|
</script>
|
|
</body> |