| <!DOCTYPE html> |
| <script src="../resources/testharness.js"></script> |
| <script src="../resources/testharnessreport.js"></script> |
| <script src="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="resources/mock-vr-service.js"></script> |
| <canvas id="webgl-canvas"></canvas> |
| <script src="resources/presentation-setup.js"></script> |
| <script> |
| let fakeDisplays = fakeVRDisplays(); |
| |
| // This test verifies that an application can hand off from window.rAF |
| // to vrDisplay.rAF, specifically where there is no pending vrDisplay.rAF |
| // at the time presentation starts. |
| // |
| // Caveat: This does *not* suffice to fully verify the current Android/GVR |
| // implementation. In the real implementation, the normal window VSync events |
| // (including window.rAF processing tied to them) are shut down, but in the |
| // layout test they continue running. So it's possible for this test to pass |
| // even though the scenario doesn't work in the real implementation. Keeping |
| // it as a layout test anyway as a sanity check - if this fails, we definitely |
| // have a problem. |
| |
| vr_test( (t) => { |
| return navigator.getVRDisplays().then( (displays) => { |
| let display = displays[0]; |
| |
| let usingDisplayRAF = false; |
| |
| function onAnimationFrame() { |
| if (display.isPresenting) { |
| if (usingDisplayRAF) { |
| t.done(); |
| } |
| |
| usingDisplayRAF = true; |
| display.requestAnimationFrame(onAnimationFrame); |
| } else { |
| window.requestAnimationFrame(onAnimationFrame); |
| } |
| } |
| |
| runWithUserGesture( () => { |
| display.requestPresent([{ source : webglCanvas }]).then( () => { |
| t.step( () => { |
| assert_true(display.isPresenting); |
| }, "Display should be presenting"); |
| }, (err) => { |
| t.step( () => { |
| assert_unreached(err); |
| }, "requestPresent rejected"); |
| }); |
| }); |
| |
| window.requestAnimationFrame(onAnimationFrame); |
| }, (err) => { |
| t.step( () => { |
| assert_unreached("getVRDisplays rejected"); |
| }); |
| t.done(); |
| }); |
| }, [fakeDisplays["Pixel"]], |
| "requestAnimationFrame properly switches from window to vrDisplay"); |
| |
| </script> |