Index: chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java |
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java |
index d40403d745a2a240504169124b6b29b104666730..22337dcc71b1f1fb708f54ead6c2d8ca20b3974d 100644 |
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java |
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java |
@@ -104,4 +104,43 @@ public class UrlUtilitiesTest extends InstrumentationTestCase { |
assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, false)); |
} |
+ @SmallTest |
+ public void testValidateIntentUrl() { |
+ String[] expectedTrue = { |
+ "intent://10010#Intent;scheme=tel;action=com.google.android.apps." |
+ + "authenticator.AUTHENTICATE;end", |
+ "intent://scan/#Intent;package=com.google.zxing.client.android;" |
+ + "scheme=zxing;end;", |
+ "intent://wump-hey.example.com/#Intent;package=com.example.wump;" |
+ + "scheme=yow;component=com.example.PUMPKIN;end;", |
+ "intent://wump_hey.example.com/#Intent;package=com.example.wump;" |
Yaron
2015/04/24 20:38:17
Please add a test with extras
|
+ + "scheme=eeek;action=frighten_children;end;" |
+ }; |
+ |
+ for (int i = 0; i < expectedTrue.length; ++i) { |
+ assertTrue(UrlUtilities.validateIntentUrl(expectedTrue[i])); |
+ } |
+ |
+ String[] expectedFalse = { |
+ // Junk after end. |
+ "intent://10010#Intent;scheme=tel;action=com.google.android.apps." |
+ + "authenticator.AUTHENTICATE;end','*');" |
+ + "alert(document.cookie);//", |
+ // component appears twice. |
+ "intent://wump-hey.example.com/#Intent;package=com.example.wump;" |
+ + "scheme=yow;component=com.example.PUMPKIN;" |
+ + "component=com.example.AVOCADO;end;", |
+ // scheme contains illegal character. |
+ "intent://wump-hey.example.com/#Intent;package=com.example.wump;" |
+ + "scheme=hello+goodbye;component=com.example.PUMPKIN;end;", |
+ // category contains illegal character. |
+ "intent://wump-hey.example.com/#Intent;package=com.example.wump;" |
+ + "category=42%_by_volume;end" |
+ }; |
+ |
+ for (int i = 0; i < expectedFalse.length; ++i) { |
+ assertFalse(UrlUtilities.validateIntentUrl(expectedFalse[i])); |
+ } |
+ } |
+ |
} |