| <!doctype html> |
| <!-- |
| Tests that WebXR 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/webxr_boilerplate.js"></script> |
| <script> |
| var t = async_test("Test pose data in unfocused tab"); |
| var pose = null; |
| let counter = 0; |
| |
| function stepCheckFrameDataWhileFocusedTab() { |
| function onAnimationFrame(session, frame) { |
| // 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++; |
| return; |
| } |
| onMagicWindowXRFrameCallback = null; |
| pose = frame.getDevicePose(sessionInfos[sessionTypes.MAGIC_WINDOW].currentFrameOfRef); |
| t.step( () => { |
| assert_true(pose != null, |
| "getDevicePose returned a non-null object"); |
| assert_true(pose instanceof XRDevicePose, |
| "getDevicePose returned an XRDevicePose") |
| }); |
| finishJavaScriptStep(); |
| } |
| // Make sure at least one rAF call has happened so we get valid data |
| onMagicWindowXRFrameCallback = onAnimationFrame; |
| } |
| |
| function stepCheckFrameDataWhileNonFocusedTab() { |
| // Unlike WebVR, WebXR doesn't fire rAFs when in a different tab |
| onMagicWindowXRFrameCallback = function() { |
| t.step( () => { |
| assert_unreached("Magic window fired rAF while in a different tab"); |
| }); |
| } |
| window.setTimeout( () => { |
| t.done(); |
| }, 1000); |
| } |
| </script> |
| </body> |
| </html> |