Commit 06a28bb3 authored by bsheedy's avatar bsheedy Committed by Commit Bot

Add VR regression test for 799999

Adds a VR instrumentation test to catch future occurrences of
crbug.com/799999. This was a bug where going from VR browser -> WebVR
-> VR browser -> WebVR would cause WebVR's requestAnimationFrame to
stop working.

Bug: 800024
Change-Id: Ia9ad57f25f666515bad93350d383c85bfb449fe7
Reviewed-on: https://chromium-review.googlesource.com/858498
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Reviewed-by: default avatarKlaus Weidner <klausw@chromium.org>
Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Cr-Commit-Position: refs/heads/master@{#528382}
parent f9301536
......@@ -252,4 +252,36 @@ public class VrShellTransitionTest {
Assert.assertTrue(VrTestFramework.pollJavaScriptBoolean(
javascript, POLL_TIMEOUT_LONG_MS, mVrTestFramework.getFirstTabWebContents()));
}
/**
* Tests that entering WebVR presentation from the VR browser, exiting presentation, and
* re-entering presentation works. This is a regression test for crbug.com/799999.
*/
@Test
@CommandLineFlags.Add("enable-webvr")
@Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
@MediumTest
public void testWebVrReEntryFromVrBrowser() throws InterruptedException, TimeoutException {
VrTransitionUtils.forceEnterVr();
VrTransitionUtils.waitForVrEntry(POLL_TIMEOUT_LONG_MS);
EmulatedVrController controller = new EmulatedVrController(mVrTestRule.getActivity());
mVrTestFramework.loadUrlAndAwaitInitialization(
VrTestFramework.getHtmlTestFile("test_webvr_reentry_from_vr_browser"),
PAGE_LOAD_TIMEOUT_S);
VrTransitionUtils.enterPresentationOrFail(mVrTestFramework.getFirstTabCvc());
VrTestFramework.executeStepAndWait(
"stepVerifyFirstPresent()", mVrTestFramework.getFirstTabWebContents());
// The bug does not reproduce with vrDisplay.exitPresent(), so use the controller to exit.
controller.pressReleaseAppButton();
VrTestFramework.executeStepAndWait(
"stepVerifyMagicWindow()", mVrTestFramework.getFirstTabWebContents());
VrTransitionUtils.enterPresentationOrFail(mVrTestFramework.getFirstTabCvc());
VrTestFramework.executeStepAndWait(
"stepVerifySecondPresent()", mVrTestFramework.getFirstTabWebContents());
VrTestFramework.endTest(mVrTestFramework.getFirstTabWebContents());
}
}
......@@ -26,7 +26,7 @@ View.
});
index = e.gamepad.index;
});
onAnimationFrameCallback = function() {
onPresentingAnimationFrameCallback = function() {
if (index == -1) return;
if (!canStartTest) return;
var gp = navigator.getGamepads()[index];
......
......@@ -16,13 +16,13 @@ focus, that the presenting frame still receives input.
var t = async_test("Focus is locked to presentation");
var rafCount = 0;
window.onfocus = function() {
onAnimationFrameCallback = null;
onPresentingAnimationFrameCallback = null;
setTimeout(function() {
document.getElementById('externalframe').contentWindow.focus();
}, 1000);
};
window.onblur = function() {
onAnimationFrameCallback = function() {
onPresentingAnimationFrameCallback = function() {
if (rafCount == 3) {
t.done();
}
......
<!doctype html>
<!--
Tests that WebVR continues to work (rAFs continue to fire) after re-entering
presentation from the VR browser.
-->
<html>
<head>
<link rel="stylesheet" type="text/css" href="../resources/webvr_e2e.css">
</head>
<body>
<canvas id="webgl-canvas"></canvas>
<script src="../../../../../../third_party/WebKit/LayoutTests/resources/testharness.js"></script>
<script src="../resources/webvr_e2e.js"></script>
<script src="../resources/webvr_boilerplate.js"></script>
<script>
var t = async_test("rAFs continue to fire after presentation re-entry");
function stepVerifyFirstPresent() {
onPresentingAnimationFrameCallback = () => {
onPresentingAnimationFrameCallback = null;
finishJavaScriptStep();
};
}
function stepVerifyMagicWindow() {
onMagicWindowAnimationFrameCallback = () => {
onMagicWindowAnimationFrameCallback = null;
finishJavaScriptStep();
};
}
function stepVerifySecondPresent() {
onPresentingAnimationFrameCallback = () => {
t.done();
};
}
</script>
</body>
</html>
\ No newline at end of file
......@@ -12,14 +12,12 @@ WebVR page without any code specific to one test
<script src="../resources/webvr_boilerplate.js"></script>
<script>
var has_submitted = false;
onAnimationFrameCallback = function() {
if (vrDisplay.isPresenting) {
if (has_submitted) {
shouldSubmitFrame = false;
finishJavaScriptStep();
}
has_submitted = true;
onPresentingAnimationFrameCallback = function() {
if (has_submitted) {
shouldSubmitFrame = false;
finishJavaScriptStep();
}
has_submitted = true;
};
</script>
</body>
......
......@@ -18,7 +18,8 @@ var glAttribs = {
var gl = webglCanvas.getContext("webgl", glAttribs);
var vrDisplay = null;
var frameData = null;
var onAnimationFrameCallback = null;
var onMagicWindowAnimationFrameCallback = null;
var onPresentingAnimationFrameCallback = null;
var shouldSubmitFrame = true;
function onResize() {
......@@ -51,7 +52,9 @@ function onAnimationFrame(t) {
vrDisplay.requestAnimationFrame(onAnimationFrame);
// If presenting, set canvas to blue. Otherwise, red.
if (vrDisplay.isPresenting) {
if (onAnimationFrameCallback) onAnimationFrameCallback();
if (onPresentingAnimationFrameCallback) {
onPresentingAnimationFrameCallback();
}
vrDisplay.getFrameData(frameData);
gl.clearColor(0.0, 0.0, 1.0, 1.0);
......@@ -63,6 +66,9 @@ function onAnimationFrame(t) {
if (shouldSubmitFrame) vrDisplay.submitFrame();
} else {
if (onMagicWindowAnimationFrameCallback) {
onMagicWindowAnimationFrameCallback();
}
gl.clearColor(1.0, 0.0, 0.0, 1.0);
gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment