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

Side by Side Diff: chrome/android/javatests/src/org/chromium/chrome/browser/UrlUtilitiesTest.java

Issue 1059413004: Add a validator for intent:// URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.chrome.browser; 5 package org.chromium.chrome.browser;
6 6
7 import android.test.InstrumentationTestCase; 7 import android.test.InstrumentationTestCase;
8 import android.test.suitebuilder.annotation.SmallTest; 8 import android.test.suitebuilder.annotation.SmallTest;
9 9
10 import org.chromium.base.test.util.Feature; 10 import org.chromium.base.test.util.Feature;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 97
98 uri = URI.create("chrome://settings:443"); 98 uri = URI.create("chrome://settings:443");
99 assertEquals("chrome://settings:443", UrlUtilities.getOriginForDisplay(u ri, true)); 99 assertEquals("chrome://settings:443", UrlUtilities.getOriginForDisplay(u ri, true));
100 assertEquals("settings:443", UrlUtilities.getOriginForDisplay(uri, false )); 100 assertEquals("settings:443", UrlUtilities.getOriginForDisplay(uri, false ));
101 101
102 uri = URI.create("about:blank"); 102 uri = URI.create("about:blank");
103 assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, true)) ; 103 assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, true)) ;
104 assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, false) ); 104 assertEquals("about:blank", UrlUtilities.getOriginForDisplay(uri, false) );
105 } 105 }
106 106
107 @SmallTest
108 public void testValidateIntentUrl() {
109 String[] expectedTrue = {
110 "intent://10010#Intent;scheme=tel;action=com.google.android.apps."
111 + "authenticator.AUTHENTICATE;end",
112 "intent://scan/#Intent;package=com.google.zxing.client.android;"
113 + "scheme=zxing;end;"
114 };
115
116 for (int i = 0; i < expectedTrue.length; ++i) {
117 assertTrue(UrlUtilities.validateIntentUrl(expectedTrue[i]));
118 }
119
120 String[] expectedFalse = {
121 "intent://10010#Intent;scheme=tel;action=com.google.android.apps."
122 + "authenticator.AUTHENTICATE;end','*');"
Yaron 2015/04/24 16:04:18 There's a lot of other validation that is currentl
palmer 2015/04/24 18:05:22 Definitely. Adding more tests now. The above was w
123 + "alert(document.cookie);//"
124 };
125
126 for (int i = 0; i < expectedFalse.length; ++i) {
127 assertFalse(UrlUtilities.validateIntentUrl(expectedFalse[i]));
128 }
129 }
130
107 } 131 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698