blob: 7e8222bd86df4871d37936378afb6b62a4ea05f7 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/device/vr/public/mojom/vr_service.mojom.js"></script>
<script src="../external/wpt/resources/chromium/webxr-test.js"></script>
<script src="../xr/resources/xr-test-utils.js"></script>
<canvas id="webgl-canvas"></canvas>
<script>
let testName = "XRSession requestAnimationFrame must fail if the session has "
+ "no baseLayer";
let fakeDeviceInitParams = { supportsImmersive:true };
let requestSessionOptions = [
{ mode: 'immersive-vr' },
{ mode: 'inline' }
];
let testFunction = (session) => new Promise((resolve, reject) => {
// Session must have a baseLayer or frame requests will be ignored.
let webglLayer = new XRWebGLLayer(session, gl);
function onEarlyFrame(time, vrFrame) {
// We shouldn't be allowed to reach this callback with no baseLayer
assert_equals(session.renderState.baseLayer, webglLayer);
resolve();
}
// This callback shouldn't go through, since the session doesn't
// have a baseLayer when this call is made.
let handle = session.requestAnimationFrame(onEarlyFrame);
// Should still give us a valid handle, though.
assert_not_equals(handle, 0);
// Wait for a bit and set the baseLayer.
setTimeout(() => {
// Once the base layer is set the previously registered callback should run.
session.updateRenderState({
baseLayer: webglLayer,
outputContext: getOutputContext()
});
}, 300);
});
xr_session_promise_test(
testFunction, fakeDeviceInitParams, requestSessionOptions, testName);
</script>