Update web-platform-tests to revision 36acf7a01cb8ffbbafbd578229c5ad3fde2e47cc

This commit is contained in:
WPT Sync Bot 2019-07-11 10:25:27 +00:00
parent 305312e93b
commit 4499a0fbb6
151 changed files with 4858 additions and 2407 deletions

View file

@ -0,0 +1,43 @@
<!DOCTYPE html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="resources/webxr_util.js"></script>
<script src="resources/webxr_test_constants.js"></script>
<canvas id="webgl-canvas"></canvas>
<script>
let immersiveTestName = "XRSession resetpose from a device properly fires off " +
"the right events for immersive sessions";
let nonImmersiveTestName = "XRSession resetpose from a device properly fires off " +
"the right events for non-immersive sessions";
let watcherDone = new Event("watcherdone");
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let testFunction = function(session, fakeDeviceController, t) {
let resetPromise = session.requestReferenceSpace('local')
.then((refSpace) => {
let eventWatcher = new EventWatcher(
t, refSpace, ["reset", "watcherdone"]);
refSpace.addEventListener("reset", (event) => {
assert_equals(event.referenceSpace, refSpace);
refSpace.dispatchEvent(watcherDone);
}, false);
return eventWatcher.wait_for(["reset", "watcherdone"]);
});
fakeDeviceController.simulateResetPose();
// The triggered resetPose event should arrive after the next Animation Frame
session.requestAnimationFrame(() => {});
return resetPromise;
};
xr_session_promise_test(
immersiveTestName, testFunction, fakeDeviceInitParams, 'immersive-vr');
xr_session_promise_test(
nonImmersiveTestName, testFunction, fakeDeviceInitParams, 'inline');
</script>

View file

@ -37,16 +37,25 @@ const VALID_POINTER_OFFSET = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1];
const VALID_GRIP_WITH_POINTER_OFFSET =
[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 4, 3, 3, 1];
const VALID_STAGE_TRANSFORM =
[1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1.0, 1.65, -1.0, 1];
// A Valid Local to floor matrix/transform for when we don't care about specific
// values. Note that these should be identical, just different representations.
const VALID_LOCAL_TO_FLOOR_MATRIX = [1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
1, 1.65, -1, 1];
const VALID_LOCAL_TO_FLOOR_TRANSFORM = {
position: [1.0, 1.65, -1.0],
orientation: [0, 0, 0, 1]
};
const VALID_BOUNDS = [
{ x: 3.0, y: 0, z: -2.0 },
{ x: 3.5, y: 0, z: 0.0 },
{ x: 3.0, y: 0, z: 2.0 },
{ x: -3.0, y: 0, z: 2.0 },
{ x: -3.5, y: 0, z: 0.0 },
{ x: -3.0, y: 0, z: -2.0 }
{ x: 3.0, z: -2.0 },
{ x: 3.5, z: 0.0 },
{ x: 3.0, z: 2.0 },
{ x: -3.0, z: 2.0 },
{ x: -3.5, z: 0.0 },
{ x: -3.0, z: -2.0 }
];
const VALID_RESOLUTION = {

View file

@ -0,0 +1,63 @@
<!DOCTYPE html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="resources/webxr_util.js"></script>
<script src="resources/webxr_test_constants.js"></script>
<script src="resources/xr-test-asserts.js"></script>
<canvas></canvas>
<script>
let testName =
"'XRBoundedReferenceSpace updates properly when the changes are applied";
let fakeDeviceInitParams = {
supportsImmersive: true,
views: VALID_VIEWS,
viewerOrigin: IDENTITY_TRANSFORM,
localToFloorLevelTransform: VALID_LOCAL_TO_FLOOR_TRANSFORM
};
let testFunction = function(session, fakeDeviceController, t) {
return new Promise((resolve, reject) => {
session.requestReferenceSpace('bounded-floor')
.then((referenceSpace) => {
t.step(() => {
assert_unreached("Should not be able to get a bounded space until bounds set");
});
}).catch((err) => {
t.step(() => {
assert_equals(err.name, "NotSupportedError");
});
function onFrame(time, xrFrame) {
// After setting the bounds explicitly, we should be able to get a
// reference space
session.requestReferenceSpace('bounded-floor')
.then((referenceSpace) => {
t.step(() => {
assert_equals(referenceSpace.boundsGeometry.length, VALID_BOUNDS.length);
for (i = 0; i < VALID_BOUNDS.length; ++i) {
let valid_point = VALID_BOUNDS[i];
let bounds_point = referenceSpace.boundsGeometry[i];
assert_equals(valid_point.x, bounds_point.x);
assert_equals(bounds_point.y, 0.0);
assert_equals(valid_point.z, bounds_point.z);
assert_equals(bounds_point.w, 1.0);
}
});
resolve();
});
}
// Now set the bounds explicitly and check again on the next frame.
fakeDeviceController.setBoundsGeometry(VALID_BOUNDS);
session.requestAnimationFrame(onFrame);
});
});
};
xr_session_promise_test(testName, testFunction, fakeDeviceInitParams, 'immersive-vr');
</script>

View file

@ -0,0 +1,39 @@
<!DOCTYPE html>
<body>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="resources/webxr_util.js"></script>
<script src="resources/webxr_test_constants.js"></script>
<canvas></canvas>
<script>
const testName = "Immersive session ends when device is disconnected";
let watcherDone = new Event("watcherdone");
const fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let testFunction = function(session, testDeviceController, t) {
let sessionWatcher = new EventWatcher(t, session, ["end", "watcherdone"]);
let sessionPromise = sessionWatcher.wait_for(["end", "watcherdone"]);
let xrWatcher = new EventWatcher(t, navigator.xr, ["devicechange"]);
let xrPromise = xrWatcher.wait_for(["devicechange"]);
function onSessionEnd(event) {
t.step( () => {
assert_equals(event.session, session);
session.dispatchEvent(watcherDone);
});
}
session.addEventListener("end", onSessionEnd, false);
// The javascript needs to yield so that the event registration processes.
t.step_timeout(() => { testDeviceController.disconnect(); }, 0);
return Promise.all([sessionPromise, xrPromise]);
};
xr_session_promise_test(testName, testFunction,
fakeDeviceInitParams, 'immersive-vr');
</script>
</body>

View file

@ -0,0 +1,70 @@
<!DOCTYPE html>
<script src=/resources/testharness.js></script>
<script src=/resources/testharnessreport.js></script>
<script src="resources/webxr_util.js"></script>
<script src="resources/webxr_test_constants.js"></script>
<script src="resources/xr-test-asserts.js"></script>
<canvas></canvas>
<script>
let immersiveTestName = "'floor-level' XRStationaryReferenceSpace updates properly when " +
"the transform changes for immersive sessions";
let nonImmersiveTestName = "'floor-level' XRStationaryReferenceSpace updates properly when " +
"the transform changes for non-immersive sessions";
let fakeDeviceInitParams = TRACKED_IMMERSIVE_DEVICE;
let testFunction = function(session, fakeDeviceController, t) {
// Don't need to request a frame/allow the stage updates to propagate before
// requesting local-floor because if the stage transform is set it just won't
// be emulated on the first frame, and we wait a frame before checking.
return session.requestReferenceSpace('local-floor')
.then((referenceSpace) => new Promise((resolve, reject) => {
function onFirstFrame(time, xrFrame) {
// On the first frame where the pose has been initialized, the stage
// should be using an emulated frame of reference because it has no
// stageParameters yet. So the pose should be ~1.5 meters off the floor.
t.step( () => {
let pose = xrFrame.getViewerPose(referenceSpace);
let poseMatrix = pose.transform.matrix;
assert_approx_equals(poseMatrix[12], 0.0, FLOAT_EPSILON);
assert_greater_than(poseMatrix[13], 1.0);
assert_approx_equals(poseMatrix[14], 0.0, FLOAT_EPSILON);
fakeDeviceController.setLocalToFloorLevelTransform(VALID_LOCAL_TO_FLOOR_TRANSFORM);
// Need to request one animation frame for the new stage transform to
// propagate before we check that it's what we expect.
session.requestAnimationFrame(() => {
session.requestAnimationFrame(onFrame);
});
});
}
function onFrame(time, xrFrame) {
t.step( () => {
// Check that stage transform was updated.
let pose = xrFrame.getViewerPose(referenceSpace);
assert_not_equals(pose, null);
let poseMatrix = pose.transform.matrix;
assert_matrix_approx_equals(poseMatrix, VALID_LOCAL_TO_FLOOR_MATRIX, FLOAT_EPSILON);
});
// Finished.
resolve();
}
// Need to wait one frame for the removal to propagate before we check that
// everything is at the expected emulated position.
session.requestAnimationFrame(() => {
session.requestAnimationFrame(onFirstFrame);
});
}));
};
xr_session_promise_test(immersiveTestName, testFunction, fakeDeviceInitParams, 'immersive-vr');
xr_session_promise_test(nonImmersiveTestName, testFunction, fakeDeviceInitParams, 'inline');
</script>