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

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: leaner 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 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")));
« 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