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 7667d8bfdc25fef30b2dfb748405717160aa5bfd..d6e0ba1a02c12f6f136810d468b4862836919038 100644 |
--- a/content/browser/service_worker/service_worker_utils_unittest.cc |
+++ b/content/browser/service_worker/service_worker_utils_unittest.cc |
@@ -30,6 +30,7 @@ TEST(ServiceWorkerUtilsTest, ScopeMatches) { |
ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
GURL("http://www.example.com/"), GURL("http://www.example.com/x"))); |
+ // '?' is not a wildcard. |
ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
GURL("http://www.example.com/?"), GURL("http://www.example.com/x"))); |
ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
@@ -39,6 +40,30 @@ TEST(ServiceWorkerUtilsTest, ScopeMatches) { |
ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( |
GURL("http://www.example.com/?"), GURL("http://www.example.com/?"))); |
+ // Query string is part of the resource. |
+ ASSERT_TRUE( |
+ ServiceWorkerUtils::ScopeMatches(GURL("http://www.example.com/?a=b"), |
+ GURL("http://www.example.com/?a=b"))); |
+ ASSERT_TRUE( |
+ ServiceWorkerUtils::ScopeMatches(GURL("http://www.example.com/?a=*"), |
+ GURL("http://www.example.com/?a=b"))); |
+ ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( |
+ GURL("http://www.example.com/*"), GURL("http://www.example.com/?a=b"))); |
+ ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
+ GURL("http://www.example.com/"), GURL("http://www.example.com/?a=b"))); |
+ |
+ // '*' only has special meaning in terminal position. |
+ ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( |
+ GURL("http://www.example.com/*/x"), GURL("http://www.example.com/*/x"))); |
+ ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
+ GURL("http://www.example.com/*/x"), GURL("http://www.example.com/a/x"))); |
+ ASSERT_FALSE( |
+ ServiceWorkerUtils::ScopeMatches(GURL("http://www.example.com/*/x/*"), |
+ GURL("http://www.example.com/a/x/b"))); |
+ ASSERT_TRUE( |
+ ServiceWorkerUtils::ScopeMatches(GURL("http://www.example.com/*/x/*"), |
+ GURL("http://www.example.com/*/x/b"))); |
+ |
// URLs canonicalize \ to / so this is equivalent to "...//*" and "...//x" |
ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( |
GURL("http://www.example.com/\\*"), GURL("http://www.example.com/\\x"))); |