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

Unified Diff: content/browser/service_worker/service_worker_utils_unittest.cc

Issue 294593002: ServiceWorker: Support longest-prefix-match for registration scope (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 6 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: content/browser/service_worker/service_worker_utils_unittest.cc
diff --git a/content/browser/service_worker/service_worker_utils_unittest.cc b/content/browser/service_worker/service_worker_utils_unittest.cc
index d6e0ba1a02c12f6f136810d468b4862836919038..3b6f55402f870a8f18526038794a6d4846da8fad 100644
--- a/content/browser/service_worker/service_worker_utils_unittest.cc
+++ b/content/browser/service_worker/service_worker_utils_unittest.cc
@@ -69,4 +69,22 @@ TEST(ServiceWorkerUtilsTest, ScopeMatches) {
GURL("http://www.example.com/\\*"), GURL("http://www.example.com/\\x")));
}
+TEST(ServiceWorkerUtilsTest, FindLongestScopeMatch) {
+ LongestScopeMatcher matcher(GURL("http://www.example.com/xxx"));
+
+ // "/xx*" should be matched longest.
+ ASSERT_TRUE(matcher.MatchLongest(GURL("http://www.example.com/x*")));
+ ASSERT_FALSE(matcher.MatchLongest(GURL("http://www.example.com/*")));
+ ASSERT_TRUE(matcher.MatchLongest(GURL("http://www.example.com/xx*")));
+
+ // "/xxx" has the same length with "/xx*" and shouldn't be matched longest.
+ // TODO(nhiroki): Should we prioritize "/xxx" over "/xx*"?
+ ASSERT_FALSE(matcher.MatchLongest(GURL("http://www.example.com/xxx")));
+
+ // "xxx*" should be matched longer than "/xx*".
+ ASSERT_TRUE(matcher.MatchLongest(GURL("http://www.example.com/xxx*")));
+
+ ASSERT_FALSE(matcher.MatchLongest(GURL("http://www.example.com/xxxx*")));
+}
+
} // namespace content

Powered by Google App Engine
This is Rietveld 408576698