Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(131)

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java

Issue 2829943002: Redirecting off-origin navigations in PWAs to CCT. (Closed)
Patch Set: Relaxed the WebApkIntegrationTest Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
index afa5078c503317197ce212e0abd4d253d9f32af9..d066d4c0d3a9aed2d94af77dfc5c3b51c02b6570 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/webapps/WebApkIntegrationTest.java
@@ -18,8 +18,10 @@ import org.chromium.base.test.util.CommandLineFlags;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.RetryOnFailure;
import org.chromium.base.test.util.ScalableTimeout;
+import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ChromeSwitches;
import org.chromium.chrome.browser.ShortcutHelper;
+import org.chromium.chrome.browser.customtabs.CustomTabActivity;
import org.chromium.chrome.test.ChromeActivityTestRule;
import org.chromium.chrome.test.ChromeJUnit4ClassRunner;
import org.chromium.chrome.test.util.ChromeTabUtils;
@@ -37,6 +39,9 @@ public class WebApkIntegrationTest {
public final ChromeActivityTestRule<WebApkActivity> mActivityTestRule =
new ChromeActivityTestRule<>(WebApkActivity.class);
+ @Rule
+ public final TopActivityListener activityListener = new TopActivityListener();
+
private static final long STARTUP_TIMEOUT = ScalableTimeout.scaleTimeout(10000);
private EmbeddedTestServer mTestServer;
@@ -48,9 +53,11 @@ public class WebApkIntegrationTest {
intent.putExtra(WebApkConstants.EXTRA_WEBAPK_PACKAGE_NAME, webApkPackageName);
intent.putExtra(ShortcutHelper.EXTRA_URL, startUrl);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
- mActivityTestRule.setActivity(
+
+ WebApkActivity webApkActivity =
(WebApkActivity) InstrumentationRegistry.getInstrumentation().startActivitySync(
- intent));
+ intent);
+ mActivityTestRule.setActivity(webApkActivity);
InstrumentationRegistry.getInstrumentation().waitForIdleSync();
CriteriaHelper.pollInstrumentationThread(new Criteria() {
@@ -94,9 +101,24 @@ public class WebApkIntegrationTest {
@LargeTest
@Feature({"WebApk"})
@RetryOnFailure
- public void testLaunch() throws InterruptedException {
+ public void testLaunchAndNavigateOffOrigin() throws Exception {
startWebApkActivity("org.chromium.webapk.test",
mTestServer.getURL("/chrome/test/data/android/test.html"));
waitUntilSplashscreenHides();
+
+ // We navigate outside origin and expect Custom Tab to open on top of WebApkActivity.
+ mActivityTestRule.runJavaScriptCodeInCurrentTab(
+ "window.top.location = 'https://www.google.com/'");
+
+ CriteriaHelper.pollUiThread(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ ChromeActivity activity = (ChromeActivity) activityListener.getMostRecentActivity();
+ return activity instanceof CustomTabActivity
+ && activity.getActivityTab() != null
+ // Dropping the TLD as Google can redirect to a local site.
+ && activity.getActivityTab().getUrl().startsWith("https://www.google.");
+ }
+ });
}
}

Powered by Google App Engine
This is Rietveld 408576698