blob: c9c124f441a4aefb719e886c3aa06a8f900dff59 [file] [log] [blame]
<!DOCTYPE html>
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="../vr/resources/fake-vr-displays.js"></script>
<script src="file:///gen/layout_test_data/mojo/public/js/mojo_bindings.js"></script>
<script src="file:///gen/device/vr/vr_service.mojom.js"></script>
<script src="../vr/resources/mock-vr-service.js"></script>
<canvas id="webgl-canvas"></canvas>
<script src="../vr/resources/presentation-setup.js"></script>
<script>
let fakeDisplays = fakeVRDisplays();
xr_session_test( (t, session) => {
// Session must have a baseLayer or frame requests will be ignored.
session.baseLayer = new XRWebGLLayer(session, gl);
let counter = 0;
function onFrame(time, vrFrame) {
// Intentionally session.requestAnimationFrame at the beginning, ensuring that
// there's an outstanding callback when t.done() is called. This is to make
// sure it doesn't cause any unexpected behavior like it did with
// crbug.com/679401
session.requestAnimationFrame(onFrame);
if (counter > 10) {
t.done();
}
counter++;
}
let handle = session.requestAnimationFrame(onFrame);
session.cancelAnimationFrame(0);
session.cancelAnimationFrame(-1);
session.cancelAnimationFrame(handle + 1);
session.cancelAnimationFrame(handle - 1);
session.cancelAnimationFrame(0.5);
session.cancelAnimationFrame(null);
}, fakeDisplays["Pixel"], { exclusive: true },
"XRSession cancelAnimationFrame does not have unexpected behavior when given invalid handles");
</script>