| 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
|
|
|