Commit 194877e6 authored by Colin Blundell's avatar Colin Blundell Committed by Commit Bot

[WebLayer] Test behavior of intent launching in onLoad() properly

When I changed embedder-initiated navigations to be of type link rather
than user typing, I also changed the ExternalNavigationTest case that
tested handling of intents initiated via onLoad() in a page that is
reached via an embedder-initiated navigation to expect an intent being
launched rather than blocked. This makes sense since it is only for
navigations initiated by user typing that such intents would be blocked.
I should have also changed this test to expect that the visible URL
would revert to that of the original URL, since in this case WebLayer
eliminates the navigation entry that corresponds to the intent being
launched. I neglected to do this and the test itself didn't complain
because it wasn't set up to wait long enough for the navigation to the
page launching an intent to fully complete, including the elimination
of the corresponding navigation entry.

There is no production problem here; this is simply a matter of test
precision that nator@ uncovered.

Change-Id: If1443d202cffd0863af2600094bd46a2663bf2b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2279200Reviewed-by: default avatarMugdha Lakhani <nator@chromium.org>
Commit-Queue: Colin Blundell <blundell@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784794}
parent 90b5d759
...@@ -454,12 +454,15 @@ public class ExternalNavigationTest { ...@@ -454,12 +454,15 @@ public class ExternalNavigationTest {
* the external intent being launched due to the navigation being specified as being from a link * the external intent being launched due to the navigation being specified as being from a link
* with a user gesture (if the navigation were specified as being from user typing the intent * with a user gesture (if the navigation were specified as being from user typing the intent
* would be blocked due to Chrome's policy on not launching intents from user-typed navigations * would be blocked due to Chrome's policy on not launching intents from user-typed navigations
* without a redirect). * without a redirect). Also verifies that WebLayer eliminates the navigation entry that
* launched the intent, so that the user is back on the original URL (i.e., the URL before that
* of the page that launched the intent in onload().
*/ */
@Test @Test
@SmallTest @SmallTest
public void testExternalIntentViaOnLoadLaunched() throws Throwable { public void testExternalIntentViaOnLoadLaunched() throws Throwable {
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(ABOUT_BLANK_URL); String initialUrl = ABOUT_BLANK_URL;
InstrumentationActivity activity = mActivityTestRule.launchShellWithUrl(initialUrl);
IntentInterceptor intentInterceptor = new IntentInterceptor(); IntentInterceptor intentInterceptor = new IntentInterceptor();
activity.setIntentInterceptor(intentInterceptor); activity.setIntentInterceptor(intentInterceptor);
...@@ -467,13 +470,13 @@ public class ExternalNavigationTest { ...@@ -467,13 +470,13 @@ public class ExternalNavigationTest {
Tab tab = mActivityTestRule.getActivity().getTab(); Tab tab = mActivityTestRule.getActivity().getTab();
TestThreadUtils.runOnUiThreadBlocking( mActivityTestRule.navigateAndWait(url);
() -> { tab.getNavigationController().navigate(Uri.parse(url)); });
intentInterceptor.waitForIntent(); intentInterceptor.waitForIntent();
// The current URL should not have changed, and the intent should have been launched. // The intent should have been launched, and the user should now be back on the original
Assert.assertEquals(url, mActivityTestRule.getCurrentDisplayUrl()); // URL.
Assert.assertEquals(initialUrl, mActivityTestRule.getCurrentDisplayUrl());
Intent intent = intentInterceptor.mLastIntent; Intent intent = intentInterceptor.mLastIntent;
Assert.assertNotNull(intent); Assert.assertNotNull(intent);
Assert.assertEquals(INTENT_TO_CHROME_PACKAGE, intent.getPackage()); Assert.assertEquals(INTENT_TO_CHROME_PACKAGE, intent.getPackage());
......
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