| <!doctype html> |
| <!-- |
| Tests that WebVR doesn't update frame data when the tab is not focused |
| --> |
| <html> |
| <head> |
| <link rel="stylesheet" type="text/css" href="../resources/webxr_e2e.css"> |
| </head> |
| <body> |
| <canvas id="webgl-canvas"></canvas> |
| <script src="../../../../../../third_party/blink/web_tests/resources/testharness.js"></script> |
| <script src="../resources/webxr_e2e.js"></script> |
| <script src="../resources/webvr_boilerplate.js"></script> |
| <script> |
| var t = async_test("Test pose data in unfocused tab"); |
| var fd = null; |
| let counter = 0; |
| |
| function stepCheckFrameDataWhileFocusedTab() { |
| function onAnimationFrame() { |
| // TODO(bsheedy): This is a workaround for crbug.com/787196. Either |
| // remove the workaround once fixed or remove this todo. |
| // Let several animation frames get triggered so we're sure to have a |
| // pose |
| if (counter <= 2) { |
| counter++; |
| vrDisplay.requestAnimationFrame(onAnimationFrame); |
| return; |
| } |
| fd = new VRFrameData(); |
| t.step( () => { |
| assert_true(vrDisplay.getFrameData(fd), |
| "getFrameData says it updated the object"); |
| assert_true(fd != null, |
| "frame data is no longer null"); |
| assert_true(fd.pose != null, |
| "frame data's pose is non-null"); |
| }); |
| finishJavaScriptStep(); |
| } |
| // Make sure at least one rAF call has happened so we get valid data |
| vrDisplay.requestAnimationFrame(onAnimationFrame); |
| } |
| |
| function stepCheckFrameDataWhileNonFocusedTab() { |
| t.step_func_done( () => { |
| assert_false(vrDisplay.getFrameData(fd), |
| "getFrameData shouldn't provide new data when tab not focused"); |
| })(); |
| } |
| </script> |
| </body> |
| </html> |