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

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

Issue 288693002: ServiceWorker: * is only wildcard at end of scope URLs (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: 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 7667d8bfdc25fef30b2dfb748405717160aa5bfd..c21484510c377aa0d047c73a8112de75046a41bc 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,18 @@ TEST(ServiceWorkerUtilsTest, ScopeMatches) {
ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches(
GURL("http://www.example.com/?"), GURL("http://www.example.com/?")));
+ // '*' 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")));

Powered by Google App Engine
This is Rietveld 408576698