| 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 <script> |
| 8 let fakeDisplays = fakeVRDisplays(); |
| 9 |
| 10 vr_test( (t) => { |
| 11 return navigator.getVRDisplays().then( (displays) => { |
| 12 let display = displays[0]; |
| 13 let canFinish = false; |
| 14 let counter = 0; |
| 15 |
| 16 function onAnimationFrame() { |
| 17 // Intentionally display.rAF at the beginning, ensuring that there's an |
| 18 // outstanding callback when t.done() is called. This is to make sure it |
| 19 // doesn't cause any unexpected behavior like it did with |
| 20 // crbug.com/679401 |
| 21 display.requestAnimationFrame(onAnimationFrame); |
| 22 if (counter > 10) { |
| 23 t.done(); |
| 24 } |
| 25 if (counter > 0) { |
| 26 counter++; |
| 27 } |
| 28 if (canFinish) { |
| 29 canFinish = false; |
| 30 counter++; |
| 31 } |
| 32 } |
| 33 |
| 34 let handle = display.requestAnimationFrame(onAnimationFrame); |
| 35 display.cancelAnimationFrame(0); |
| 36 display.cancelAnimationFrame(-1); |
| 37 display.cancelAnimationFrame(handle + 1); |
| 38 display.cancelAnimationFrame(handle - 1); |
| 39 display.cancelAnimationFrame(0.5); |
| 40 display.cancelAnimationFrame(null); |
| 41 canFinish = true; |
| 42 }, (err) => { |
| 43 t.step( () => { |
| 44 assert_unreached("getVRDisplays rejected"); |
| 45 }); |
| 46 t.done(); |
| 47 }); |
| 48 }, [fakeDisplays["Pixel"]], |
| 49 "cancelAnimationFrame does not have unexpected behavior when given invalid handl
es"); |
| 50 |
| 51 </script> |
| OLD | NEW |