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

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

Issue 2636103002: [WebAPKs] Show minibar when WebAPK navigates outside scope specified in Web Manifest (Closed)
Patch Set: Merge branch 'master' into minibar Created 3 years, 11 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.util; 5 package org.chromium.chrome.browser.util;
6 6
7 import android.support.test.filters.SmallTest; 7 import android.support.test.filters.SmallTest;
8 8
9 import org.chromium.content.browser.test.NativeLibraryTestBase; 9 import org.chromium.content.browser.test.NativeLibraryTestBase;
10 10
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 "intent://wump-hey.example.com/#Intent;package=com.example.wump; " 136 "intent://wump-hey.example.com/#Intent;package=com.example.wump; "
137 + "category=42%_by_volume;end")); 137 + "category=42%_by_volume;end"));
138 // Incorrectly URL-encoded. 138 // Incorrectly URL-encoded.
139 assertFalse(UrlUtilities.validateIntentUrl( 139 assertFalse(UrlUtilities.validateIntentUrl(
140 "intent://testing/#Intent;package=cybergoat.noodle.crumpet;" 140 "intent://testing/#Intent;package=cybergoat.noodle.crumpet;"
141 + "component=wump.noodle/Crumpet;i.pumpkinCount%%3D=42;" 141 + "component=wump.noodle/Crumpet;i.pumpkinCount%%3D=42;"
142 + "S.goat=⋚end")); 142 + "S.goat=⋚end"));
143 } 143 }
144 144
145 @SmallTest 145 @SmallTest
146 public void testIsUrlWithinScope() {
147 String scope = "http://www.example.com/sub";
148 assertTrue(UrlUtilities.isUrlWithinScope(scope, scope));
149 assertTrue(UrlUtilities.isUrlWithinScope(scope + "/path", scope));
150 assertTrue(UrlUtilities.isUrlWithinScope(scope + "/a b", scope + "/a%20b /path"));
151
152 assertFalse(UrlUtilities.isUrlWithinScope("https://www.example.com/sub", scope));
153 assertFalse(UrlUtilities.isUrlWithinScope(scope, scope + "/inner"));
154 assertFalse(UrlUtilities.isUrlWithinScope(scope + "/this", scope + "/dif ferent"));
155 assertFalse(UrlUtilities.isUrlWithinScope("http://awesome.example.com", "http://example.com"));
Maria 2017/01/18 17:11:08 long line?
156 assertFalse(UrlUtilities.isUrlWithinScope(
157 "https://www.google.com.evil.com", "https://www.google.com"));
158 }
159
160 @SmallTest
146 public void testUrlsMatchIgnoringFragments() { 161 public void testUrlsMatchIgnoringFragments() {
147 String url = "http://www.example.com/path"; 162 String url = "http://www.example.com/path";
148 assertTrue(UrlUtilities.urlsMatchIgnoringFragments(url, url)); 163 assertTrue(UrlUtilities.urlsMatchIgnoringFragments(url, url));
149 assertTrue(UrlUtilities.urlsMatchIgnoringFragments(url + "#fragment", ur l)); 164 assertTrue(UrlUtilities.urlsMatchIgnoringFragments(url + "#fragment", ur l));
150 assertTrue(UrlUtilities.urlsMatchIgnoringFragments(url + "#fragment", ur l + "#fragment2")); 165 assertTrue(UrlUtilities.urlsMatchIgnoringFragments(url + "#fragment", ur l + "#fragment2"));
151 assertTrue(UrlUtilities.urlsMatchIgnoringFragments("HTTP://www.example.c om/path" 166 assertTrue(UrlUtilities.urlsMatchIgnoringFragments("HTTP://www.example.c om/path"
152 + "#fragment", 167 + "#fragment",
153 url + "#fragment2")); 168 url + "#fragment2"));
154 assertFalse(UrlUtilities.urlsMatchIgnoringFragments( 169 assertFalse(UrlUtilities.urlsMatchIgnoringFragments(
155 url + "#fragment", "http://example.com:443/path#fragment")); 170 url + "#fragment", "http://example.com:443/path#fragment"));
156 } 171 }
157 172
158 @SmallTest 173 @SmallTest
159 public void testUrlsFragmentsDiffer() { 174 public void testUrlsFragmentsDiffer() {
160 String url = "http://www.example.com/path"; 175 String url = "http://www.example.com/path";
161 assertFalse(UrlUtilities.urlsFragmentsDiffer(url, url)); 176 assertFalse(UrlUtilities.urlsFragmentsDiffer(url, url));
162 assertTrue(UrlUtilities.urlsFragmentsDiffer(url + "#fragment", url)); 177 assertTrue(UrlUtilities.urlsFragmentsDiffer(url + "#fragment", url));
163 } 178 }
164 } 179 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698