| Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappNavigationTest.java
|
| diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappNavigationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappNavigationTest.java
|
| index e7e96e3981a3be8c16abb453cbc2043f0370ddd9..664cc877a8d9d1d73d0c88924c36cf177d4efcf1 100644
|
| --- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappNavigationTest.java
|
| +++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebappNavigationTest.java
|
| @@ -24,7 +24,9 @@ import org.chromium.chrome.browser.ChromeSwitches;
|
| import org.chromium.chrome.browser.ChromeTabbedActivity;
|
| import org.chromium.chrome.browser.ShortcutHelper;
|
| import org.chromium.chrome.browser.customtabs.CustomTabActivity;
|
| +import org.chromium.chrome.browser.externalnav.ExternalNavigationHandler.OverrideUrlLoadingResult;
|
| import org.chromium.chrome.browser.firstrun.FirstRunStatus;
|
| +import org.chromium.chrome.browser.tab.InterceptNavigationDelegateImpl;
|
| import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
|
| import org.chromium.chrome.test.util.browser.contextmenu.ContextMenuUtils;
|
| import org.chromium.content.browser.test.util.DOMUtils;
|
| @@ -37,6 +39,7 @@ import org.chromium.ui.base.PageTransition;
|
| @RunWith(ChromeJUnit4ClassRunner.class)
|
| @CommandLineFlags.Add({ChromeSwitches.DISABLE_FIRST_RUN_EXPERIENCE})
|
| public class WebappNavigationTest {
|
| + private static final String YOUTUBE_URL = "https://www.youtube.com/watch?v=EYmjoW4vIX8";
|
| private static final String OFF_ORIGIN_URL = "https://www.google.com/";
|
| private static final String WEB_APP_PATH = "/chrome/test/data/banners/manifest_test_page.html";
|
| private static final String IN_SCOPE_PAGE_PATH =
|
| @@ -194,6 +197,45 @@ public class WebappNavigationTest {
|
| Assert.assertTrue(tabbedChrome.getActivityTab().getUrl().startsWith("https://www.google."));
|
| }
|
|
|
| + @Test
|
| + @SmallTest
|
| + @Feature({"Webapps"})
|
| + public void testRegularLinkToExternalApp() throws Exception {
|
| + runWebappActivityAndWaitForIdle(mActivityTestRule.createIntent());
|
| +
|
| + InterceptNavigationDelegateImpl navigationDelegate =
|
| + mActivityTestRule.getActivity().getActivityTab().getInterceptNavigationDelegate();
|
| +
|
| + addAnchor("testLink", YOUTUBE_URL, "_self");
|
| + DOMUtils.clickNode(
|
| + mActivityTestRule.getActivity().getActivityTab().getContentViewCore(), "testLink");
|
| +
|
| + activityListener.waitForExternalApp();
|
| + Assert.assertEquals(OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT,
|
| + navigationDelegate.getLastOverrideUrlLoadingResultForTests());
|
| + }
|
| +
|
| + @Test
|
| + @SmallTest
|
| + @Feature({"Webapps"})
|
| + public void testNewTabLinkToExternalApp() throws Exception {
|
| + runWebappActivityAndWaitForIdle(mActivityTestRule.createIntent());
|
| +
|
| + addAnchor("testLink", YOUTUBE_URL, "_blank");
|
| + DOMUtils.clickNode(
|
| + mActivityTestRule.getActivity().getActivityTab().getContentViewCore(), "testLink");
|
| +
|
| + // For _blank anchors, we open the CustomTab which does the redirecting if necessary.
|
| + CustomTabActivity customTab = activityListener.waitFor(CustomTabActivity.class);
|
| +
|
| + activityListener.waitForExternalApp();
|
| +
|
| + InterceptNavigationDelegateImpl navigationDelegate =
|
| + customTab.getActivityTab().getInterceptNavigationDelegate();
|
| + Assert.assertEquals(OverrideUrlLoadingResult.OVERRIDE_WITH_EXTERNAL_INTENT,
|
| + navigationDelegate.getLastOverrideUrlLoadingResultForTests());
|
| + }
|
| +
|
| private void runWebappActivityAndWaitForIdle(Intent intent) throws Exception {
|
| mActivityTestRule.startWebappActivity(
|
| intent.putExtra(ShortcutHelper.EXTRA_URL, mTestServer.getURL(WEB_APP_PATH)));
|
|
|