blob: 2d6b605620074f9279fd1a2be84a2d2fc5e36950 [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> let legacy_vr_test = true; </script>
<script src="../external/wpt/resources/chromium/webxr-test.js"></script>
<script src="resources/vr-test-utils.js "></script>
<script src="resources/test-constants.js"></script>
<script>
let fakeDisplays = fakeVRDisplays();
vr_test( (t, device_controller) => {
return navigator.getVRDisplays().then( (displays) => {
let display = displays[0];
let counter = 0;
let rAFTime = 0;
function onWindowAnimationFrame1(time) {
window.requestAnimationFrame(onWindowAnimationFrame1);
rAFTime = time;
t.step(function() {
assert_equals(counter % 4, 0);
});
counter++;
}
function onDisplayAnimationFrame1(time) {
display.requestAnimationFrame(onDisplayAnimationFrame1);
t.step(function() {
assert_equals(time, rAFTime);
assert_equals(counter % 4, 1);
});
counter++;
}
function onDisplayAnimationFrame2(time) {
display.requestAnimationFrame(onDisplayAnimationFrame2);
t.step(function() {
assert_equals(time, rAFTime);
assert_equals(counter % 4, 2);
});
counter++;
}
function onWindowAnimationFrame2(time) {
window.requestAnimationFrame(onWindowAnimationFrame2);
t.step(function() {
assert_equals(time, rAFTime);
assert_equals(counter % 4, 3);
});
if (counter == 15) {
t.done();
}
counter++;
}
function onFirstAnimationFrame() {
window.requestAnimationFrame(onWindowAnimationFrame1);
display.requestAnimationFrame(onDisplayAnimationFrame1);
display.requestAnimationFrame(onDisplayAnimationFrame2);
window.requestAnimationFrame(onWindowAnimationFrame2);
}
// Ensure that there's a non-null pose available for the mock framework to
// return, and wait for one rAF callback to let it propagate. This is a
// workaround for delayed promise execution in the mocking framework.
device_controller.setPose(VALID_POSE);
display.requestAnimationFrame(onFirstAnimationFrame);
}, (err) => {
t.step( () => {
assert_unreached("getVRDisplays rejected");
});
t.done();
});
}, [fakeDisplays["Pixel"]],
"display and window rAF callbacks fire together");
</script>