| OLD | NEW | 
|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #include "content/browser/service_worker/service_worker_utils.h" | 5 #include "content/browser/service_worker/service_worker_utils.h" | 
| 6 #include "testing/gtest/include/gtest/gtest.h" | 6 #include "testing/gtest/include/gtest/gtest.h" | 
| 7 | 7 | 
| 8 namespace content { | 8 namespace content { | 
| 9 | 9 | 
| 10 TEST(ServiceWorkerUtilsTest, ScopeMatches) { | 10 TEST(ServiceWorkerUtilsTest, ScopeMatches) { | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 62                                        GURL("http://www.example.com/a/x/b"))); | 62                                        GURL("http://www.example.com/a/x/b"))); | 
| 63   ASSERT_TRUE( | 63   ASSERT_TRUE( | 
| 64       ServiceWorkerUtils::ScopeMatches(GURL("http://www.example.com/*/x/*"), | 64       ServiceWorkerUtils::ScopeMatches(GURL("http://www.example.com/*/x/*"), | 
| 65                                        GURL("http://www.example.com/*/x/b"))); | 65                                        GURL("http://www.example.com/*/x/b"))); | 
| 66 | 66 | 
| 67   // URLs canonicalize \ to / so this is equivalent to  "...//*" and "...//x" | 67   // URLs canonicalize \ to / so this is equivalent to  "...//*" and "...//x" | 
| 68   ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( | 68   ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( | 
| 69       GURL("http://www.example.com/\\*"), GURL("http://www.example.com/\\x"))); | 69       GURL("http://www.example.com/\\*"), GURL("http://www.example.com/\\x"))); | 
| 70 } | 70 } | 
| 71 | 71 | 
|  | 72 TEST(ServiceWorkerUtilsTest, FindLongestScopeMatch) { | 
|  | 73   LongestScopeMatcher matcher(GURL("http://www.example.com/xxx")); | 
|  | 74 | 
|  | 75   // "/xx*" should be matched longest. | 
|  | 76   ASSERT_TRUE(matcher.MatchLongest(GURL("http://www.example.com/x*"))); | 
|  | 77   ASSERT_FALSE(matcher.MatchLongest(GURL("http://www.example.com/*"))); | 
|  | 78   ASSERT_TRUE(matcher.MatchLongest(GURL("http://www.example.com/xx*"))); | 
|  | 79 | 
|  | 80   // "/xxx" has the same length with "/xx*" and shouldn't be matched longest. | 
|  | 81   // TODO(nhiroki): Should we prioritize "/xxx" over "/xx*"? | 
|  | 82   ASSERT_FALSE(matcher.MatchLongest(GURL("http://www.example.com/xxx"))); | 
|  | 83 | 
|  | 84   // "xxx*" should be matched longer than "/xx*". | 
|  | 85   ASSERT_TRUE(matcher.MatchLongest(GURL("http://www.example.com/xxx*"))); | 
|  | 86 | 
|  | 87   ASSERT_FALSE(matcher.MatchLongest(GURL("http://www.example.com/xxxx*"))); | 
|  | 88 } | 
|  | 89 | 
| 72 }  // namespace content | 90 }  // namespace content | 
| OLD | NEW | 
|---|