OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <script src="../resources/testharness.js"></script> |
| 3 <script src="../resources/testharnessreport.js"></script> |
| 4 <script src="../resources/mojo-helpers.js"></script> |
| 5 <script src="resources/fake-vr-displays.js"></script> |
| 6 <script src="resources/mock-vr-service.js"></script> |
| 7 <canvas id="webgl-canvas"></canvas> |
| 8 <script src="resources/presentation-setup.js"></script> |
| 9 <script> |
| 10 let fakeDisplays = fakeVRDisplays(); |
| 11 |
| 12 // This test verifies that an application can hand off from window.rAF |
| 13 // to vrDisplay.rAF, specifically where there is no pending vrDisplay.rAF |
| 14 // at the time presentation starts. |
| 15 // |
| 16 // Caveat: This does *not* suffice to fully verify the current Android/GVR |
| 17 // implementation. In the real implementation, the normal window VSync events |
| 18 // (including window.rAF processing tied to them) are shut down, but in the |
| 19 // layout test they continue running. So it's possible for this test to pass |
| 20 // even though the scenario doesn't work in the real implementation. Keeping |
| 21 // it as a layout test anyway as a sanity check - if this fails, we definitely |
| 22 // have a problem. |
| 23 |
| 24 vr_test( (t) => { |
| 25 return navigator.getVRDisplays().then( (displays) => { |
| 26 let display = displays[0]; |
| 27 |
| 28 let usingDisplayRAF = false; |
| 29 |
| 30 function onAnimationFrame() { |
| 31 if (display.isPresenting) { |
| 32 if (usingDisplayRAF) { |
| 33 t.done(); |
| 34 } |
| 35 |
| 36 usingDisplayRAF = true; |
| 37 display.requestAnimationFrame(onAnimationFrame); |
| 38 } else { |
| 39 window.requestAnimationFrame(onAnimationFrame); |
| 40 } |
| 41 } |
| 42 |
| 43 runWithUserGesture( () => { |
| 44 display.requestPresent([{ source : webglCanvas }]).then( () => { |
| 45 t.step( () => { |
| 46 assert_true(display.isPresenting); |
| 47 }, "Display should be presenting"); |
| 48 }, (err) => { |
| 49 t.step( () => { |
| 50 assert_unreached(err); |
| 51 }, "requestPresent rejected"); |
| 52 }); |
| 53 }); |
| 54 |
| 55 window.requestAnimationFrame(onAnimationFrame); |
| 56 }, (err) => { |
| 57 t.step( () => { |
| 58 assert_unreached("getVRDisplays rejected"); |
| 59 }); |
| 60 t.done(); |
| 61 }); |
| 62 }, [fakeDisplays["Pixel"]], |
| 63 "requestAnimationFrame properly switches from window to vrDisplay"); |
| 64 |
| 65 </script> |
OLD | NEW |