Index: chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java |
index 36416efe16ae43ac4098e987a48ab101f77f5ee6..d9eda2f556236f00fb0cadd12c3ad1256d4f1193 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/customtabs/ClientManagerTest.java |
@@ -5,6 +5,7 @@ |
package org.chromium.chrome.browser.customtabs; |
import android.content.Context; |
+import android.net.Uri; |
import android.os.Process; |
import android.support.customtabs.CustomTabsSessionToken; |
import android.support.test.InstrumentationRegistry; |
@@ -16,10 +17,12 @@ import org.junit.Rule; |
import org.junit.Test; |
import org.junit.runner.RunWith; |
+import org.chromium.base.ContextUtils; |
import org.chromium.base.metrics.RecordHistogram; |
import org.chromium.base.test.BaseJUnit4ClassRunner; |
import org.chromium.base.test.util.MetricsUtils; |
import org.chromium.base.test.util.RetryOnFailure; |
+import org.chromium.chrome.browser.IntentHandler; |
import org.chromium.content.browser.test.NativeLibraryTestRule; |
/** Tests for ClientManager. */ |
@@ -154,6 +157,31 @@ public class ClientManagerTest { |
@Test |
@SmallTest |
+ public void testPostMessageOriginVerification() { |
+ Assert.assertTrue( |
+ mClientManager.newSession(mSession, mUid, null, new PostMessageHandler(mSession))); |
+ // Should always start with no origin. |
+ Assert.assertNull(mClientManager.getPostMessageOriginForSessionForTesting(mSession)); |
+ |
+ // With no prepopulated origins, this verification should fail. |
+ mClientManager.verifyAndInitializeWithPostMessageOriginForSession(mSession, Uri.parse(URL)); |
+ Assert.assertNull(mClientManager.getPostMessageOriginForSessionForTesting(mSession)); |
+ |
+ // If there is a prepopulated origin, we should get a syncronous verification. |
Benoit L
2017/04/07 15:04:54
nit: Synchronous.
Yusuf
2017/04/07 23:38:41
Done.
|
+ OriginVerifier.prePopulateVerifiedOriginForTesting( |
+ ContextUtils.getApplicationContext().getPackageName(), Uri.parse(URL)); |
+ mClientManager.verifyAndInitializeWithPostMessageOriginForSession(mSession, Uri.parse(URL)); |
+ Uri verifiedOrigin = mClientManager.getPostMessageOriginForSessionForTesting(mSession); |
+ Assert.assertNotNull(verifiedOrigin); |
+ Assert.assertEquals(IntentHandler.ANDROID_APP_REFERRER_SCHEME, verifiedOrigin.getScheme()); |
+ |
+ // initializeWithPostMessageOriginForSession should override without checking origin. |
+ mClientManager.initializeWithPostMessageOriginForSession(mSession, null); |
+ Assert.assertNull(mClientManager.getPostMessageOriginForSessionForTesting(mSession)); |
+ } |
+ |
+ @Test |
+ @SmallTest |
public void testFirstLowConfidencePredictionIsNotThrottled() { |
Context context = InstrumentationRegistry.getInstrumentation() |
.getTargetContext() |