Update web-platform-tests to revision 3f9178031eec5374c9a7d5709a7e11ba4a1955ed

This commit is contained in:
WPT Sync Bot 2018-07-22 21:05:03 -04:00
parent 4997ec26c2
commit a5af9a106a
192 changed files with 3943 additions and 1927 deletions

View file

@ -1,3 +1,25 @@
// These tests rely on the User Agent providing an implementation of the
// WebXR Testing API (https://github.com/immersive-web/webxr-test-api).
//
// In Chromium-based browsers, this implementation is provided by a JavaScript
// shim in order to reduce the amount of test-only code shipped to users. To
// enable these tests the browser must be run with these options:
//
// --enable-blink-features=MojoJS,MojoJSTest
function xr_promise_test(func, name, properties) {
promise_test(async (t) => {
// Perform any required test setup:
if (window.XRTest === undefined) {
// Chrome setup
await loadChromiumResources;
}
return func(t);
}, name, properties);
}
// This functions calls a callback with each API object as specified
// by https://immersive-web.github.io/webxr/spec/latest/, allowing
// checks to be made on all ojects.
@ -25,4 +47,32 @@ function forEachWebxrObject(callback) {
callback(window.XRStageBoundsPoint, 'XRStageBoundsPoint');
callback(window.XRSessionEvent, 'XRSessionEvent');
callback(window.XRCoordinateSystemEvent, 'XRCoordinateSystemEvent');
}
}
// Code for loading test api in chromium.
let loadChromiumResources = Promise.resolve().then(() => {
if (!MojoInterfaceInterceptor) {
// Do nothing on non-Chromium-based browsers or when the Mojo bindings are
// not present in the global namespace.
return;
}
let chain = Promise.resolve();
['/gen/layout_test_data/mojo/public/js/mojo_bindings.js',
'/gen/ui/gfx/geometry/mojo/geometry.mojom.js',
'/gen/mojo/public/mojom/base/time.mojom.js',
'/gen/device/vr/public/mojom/vr_service.mojom.js',
'/resources/chromium/webxr-test.js', '/resources/testdriver.js',
'/resources/testdriver-vendor.js',
].forEach(path => {
let script = document.createElement('script');
script.src = path;
script.async = false;
chain = chain.then(() => new Promise(resolve => {
script.onload = () => resolve();
}));
document.head.appendChild(script);
});
return chain;
});

View file

@ -0,0 +1,91 @@
<!DOCTYPE html>
<body>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="resources/webxr_util.js"></script>
<canvas id="webgl-canvas"></canvas>
<script>
const identityMatrix = new Float32Array([
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
]);
const rightFakeXRViewInit =
{eye:"right", projectionMatrix: identityMatrix, viewMatrix: identityMatrix};
const leftFakeXRViewInit =
{eye:"left", projectionMatrix: identityMatrix, viewMatrix: identityMatrix};
const immersiveFakeXRDeviceInit = { supportsImmersive:true };
const webglCanvas = document.getElementById('webgl-canvas');
let gl = webglCanvas.getContext('webgl', { alpha: false, antialias: false });
let testDevice;
let testDeviceController;
let testSession;
xr_promise_test(
(t) => XRTest.simulateDeviceConnection(immersiveFakeXRDeviceInit)
.then((controller) => {
testDeviceController = controller;
return navigator.xr.requestDevice();
})
.then((device) => {
testDevice = device;
return gl.setCompatibleXRDevice(device);
})
.then(() => new Promise((resolve, reject) => {
// Perform the session request in a user gesture.
XRTest.simulateUserActivation(() => {
testDevice.requestSession({ immersive: true })
.then((session) => {
testSession = session;
return session.requestFrameOfReference('eye-level');
})
.then((frameOfRef) => {
// Session must have a baseLayer or frame requests will be ignored.
testSession.baseLayer = new XRWebGLLayer(testSession, gl);
function onFrame(time, xrFrame) {
assert_true(xrFrame instanceof XRFrame);
assert_not_equals(xrFrame.views, null);
assert_equals(xrFrame.views.length, 2);
let devicePose = xrFrame.getDevicePose(frameOfRef);
assert_not_equals(devicePose, null);
for(let i = 0; i < identityMatrix.length; i++) {
assert_equals(devicePose.poseModelMatrix[i], identityMatrix[i]);
}
assert_not_equals(devicePose.getViewMatrix(xrFrame.views[0]), null);
assert_equals(devicePose.getViewMatrix(xrFrame.views[0]).length, 16);
assert_not_equals(devicePose.getViewMatrix(xrFrame.views[1]), null);
assert_equals(devicePose.getViewMatrix(xrFrame.views[1]).length, 16);
// Test does not complete until the returned promise resolves.
resolve();
}
testDeviceController.setXRPresentationFrameData(
identityMatrix,
[rightFakeXRViewInit, leftFakeXRViewInit]
);
testSession.requestAnimationFrame(onFrame);
}).catch((err) => {
reject("Session was rejected with error: "+err);
});
});
})
),
"RequestAnimationFrame resolves with good data"
);
</script>
</body>