Commit 64dafe84 authored by bsheedy's avatar bsheedy Committed by Commit Bot

Add VR regression test for 821443

Adds a test that exits the VR browser while JavaScript dialogs and
permission prompts are displayed and ensures that the browser does not
crash.

Bug: 822480
Change-Id: Ie0f1f2be5575ecd0bd30cf12f83c51404d90c169
Reviewed-on: https://chromium-review.googlesource.com/965385Reviewed-by: default avatarMichael Thiessen <mthiesse@chromium.org>
Commit-Queue: Brian Sheedy <bsheedy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#544909}
parent 88631930
...@@ -1015,6 +1015,11 @@ public class VrShellImpl ...@@ -1015,6 +1015,11 @@ public class VrShellImpl
return mPresentationView; return mPresentationView;
} }
@VisibleForTesting
public boolean isDisplayingDialogView() {
return mVrUiViewContainer.getChildCount() > 0;
}
@Override @Override
public void showSoftInput(boolean show) { public void showSoftInput(boolean show) {
assert mNativeVrShell != 0; assert mNativeVrShell != 0;
......
...@@ -49,6 +49,7 @@ import org.chromium.chrome.test.util.ActivityUtils; ...@@ -49,6 +49,7 @@ import org.chromium.chrome.test.util.ActivityUtils;
import org.chromium.content.browser.test.util.Criteria; import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper; import org.chromium.content.browser.test.util.CriteriaHelper;
import org.chromium.content.browser.test.util.DOMUtils; import org.chromium.content.browser.test.util.DOMUtils;
import org.chromium.content.browser.test.util.JavaScriptUtils;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
import java.util.List; import java.util.List;
...@@ -457,4 +458,35 @@ public class VrShellTransitionTest { ...@@ -457,4 +458,35 @@ public class VrShellTransitionTest {
} }
}); });
} }
/**
* Tests that exiting VR while a permission prompt or JavaScript dialog is being displayed
* does not cause a browser crash. Regression test for https://crbug.com/821443.
*/
@Test
@Restriction(RESTRICTION_TYPE_VIEWER_DAYDREAM)
@LargeTest
@CommandLineFlags.Add("enable-features=VrBrowsingNativeAndroidUi")
public void testExitVrWithPromptDisplayed() throws InterruptedException, TimeoutException {
mVrTestFramework.loadUrlAndAwaitInitialization(
VrTestFramework.getHtmlTestFile("test_navigation_2d_page"), PAGE_LOAD_TIMEOUT_S);
// Test JavaScript dialogs.
Assert.assertTrue(TransitionUtils.forceEnterVr());
TransitionUtils.waitForVrEntry(POLL_TIMEOUT_LONG_MS);
// Alerts block JavaScript execution until they're closed, so we can't use the normal
// runJavaScriptOrFail, as that will time out.
JavaScriptUtils.executeJavaScript(mVrTestFramework.getFirstTabWebContents(),
"alert('Please no crash')");
TransitionUtils.waitForNativeUiPrompt(POLL_TIMEOUT_LONG_MS);
TransitionUtils.forceExitVr();
// Test permission prompts.
Assert.assertTrue(TransitionUtils.forceEnterVr());
TransitionUtils.waitForVrEntry(POLL_TIMEOUT_LONG_MS);
VrTestFramework.runJavaScriptOrFail("navigator.getUserMedia({video: true}, ()=>{}, ()=>{})",
POLL_TIMEOUT_SHORT_MS, mVrTestFramework.getFirstTabWebContents());
TransitionUtils.waitForNativeUiPrompt(POLL_TIMEOUT_LONG_MS);
TransitionUtils.forceExitVr();
}
} }
...@@ -23,6 +23,7 @@ import org.chromium.chrome.browser.vr_shell.VrClassesWrapperImpl; ...@@ -23,6 +23,7 @@ import org.chromium.chrome.browser.vr_shell.VrClassesWrapperImpl;
import org.chromium.chrome.browser.vr_shell.VrDaydreamApi; import org.chromium.chrome.browser.vr_shell.VrDaydreamApi;
import org.chromium.chrome.browser.vr_shell.VrIntentUtils; import org.chromium.chrome.browser.vr_shell.VrIntentUtils;
import org.chromium.chrome.browser.vr_shell.VrShellDelegate; import org.chromium.chrome.browser.vr_shell.VrShellDelegate;
import org.chromium.chrome.browser.vr_shell.VrShellImpl;
import org.chromium.chrome.browser.vr_shell.VrTestFramework; import org.chromium.chrome.browser.vr_shell.VrTestFramework;
import org.chromium.content.browser.test.util.Criteria; import org.chromium.content.browser.test.util.Criteria;
import org.chromium.content.browser.test.util.CriteriaHelper; import org.chromium.content.browser.test.util.CriteriaHelper;
...@@ -222,4 +223,18 @@ public class TransitionUtils { ...@@ -222,4 +223,18 @@ public class TransitionUtils {
} }
}); });
} }
/**
* Waits until either a JavaScript dialog or permission prompt is being displayed using the
* Android native UI in the VR browser.
*/
public static void waitForNativeUiPrompt(final int timeout) {
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@Override
public boolean isSatisfied() {
VrShellImpl vrShell = (VrShellImpl) TestVrShellDelegate.getVrShellForTesting();
return vrShell.isDisplayingDialogView();
}
}, timeout, POLL_CHECK_INTERVAL_SHORT_MS);
}
} }
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