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

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

Issue 304423004: ServiceWorker: Scope should match url in longest-prefix-match way (won't commit) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix compile error 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
« no previous file with comments | « content/browser/service_worker/service_worker_utils.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..ed8e83cfff969e779c9060ef5a739f8526925d83 100644
--- a/content/browser/service_worker/service_worker_utils_unittest.cc
+++ b/content/browser/service_worker/service_worker_utils_unittest.cc
@@ -69,4 +69,32 @@ TEST(ServiceWorkerUtilsTest, ScopeMatches) {
GURL("http://www.example.com/\\*"), GURL("http://www.example.com/\\x")));
}
+TEST(ServiceWorkerUtilsTest, FindLongestScopeMatch) {
+ GURL url("http://www.example.com/xxx");
+ size_t pos = 0;
+
+ std::vector<GURL> scopes;
+ scopes.push_back(GURL("http://www.example.com/*"));
+ scopes.push_back(GURL("http://www.example.com/x*"));
+ scopes.push_back(GURL("http://www.example.com/xx*"));
+
+ // Should be matched with "/xx*".
+ ASSERT_TRUE(ServiceWorkerUtils::FindLongestScopeMatch(scopes, url, &pos));
+ ASSERT_EQ(2u, pos);
+ pos = 0;
+
+ scopes.push_back(GURL("http://www.example.com/xxx"));
+
+ // Should be matched with "/xxx".
+ ASSERT_TRUE(ServiceWorkerUtils::FindLongestScopeMatch(scopes, url, &pos));
+ ASSERT_EQ(3u, pos);
+ pos = 0;
+
+ scopes.push_back(GURL("http://www.example.com/xxx*"));
+
+ // Should be matched with "/xxx*".
+ ASSERT_TRUE(ServiceWorkerUtils::FindLongestScopeMatch(scopes, url, &pos));
+ ASSERT_EQ(4u, pos);
+}
+
} // namespace content
« no previous file with comments | « content/browser/service_worker/service_worker_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698