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

Side by Side Diff: content/browser/service_worker/service_worker_utils_unittest.cc

Issue 259893002: ServiceWorker: Additional scope-matching test cases (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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) {
11 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( 11 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches(
12 GURL("http://www.example.com/*"), GURL("http://www.example.com/"))); 12 GURL("http://www.example.com/*"), GURL("http://www.example.com/")));
13 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( 13 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches(
14 GURL("http://www.example.com/*"), 14 GURL("http://www.example.com/*"),
15 GURL("http://www.example.com/page.html"))); 15 GURL("http://www.example.com/page.html")));
16 16
17 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( 17 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(
18 GURL("http://www.example.com/*"), GURL("https://www.example.com/"))); 18 GURL("http://www.example.com/*"), GURL("https://www.example.com/")));
19 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( 19 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(
20 GURL("http://www.example.com/*"), 20 GURL("http://www.example.com/*"),
21 GURL("https://www.example.com/page.html"))); 21 GURL("https://www.example.com/page.html")));
22 22
23 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( 23 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(
24 GURL("http://www.example.com/*"), GURL("http://www.foo.com/"))); 24 GURL("http://www.example.com/*"), GURL("http://www.foo.com/")));
25 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( 25 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(
26 GURL("http://www.example.com/*"), GURL("https://www.foo.com/page.html"))); 26 GURL("http://www.example.com/*"), GURL("https://www.foo.com/page.html")));
27
28 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches(
29 GURL("http://www.example.com/"), GURL("http://www.example.com/")));
30 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(
31 GURL("http://www.example.com/"), GURL("http://www.example.com/x")));
32
33 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(
34 GURL("http://www.example.com/?"), GURL("http://www.example.com/x")));
35 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(
36 GURL("http://www.example.com/?"), GURL("http://www.example.com/")));
37 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(
38 GURL("http://www.example.com/?"), GURL("http://www.example.com/xx")));
39 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches(
40 GURL("http://www.example.com/?"), GURL("http://www.example.com/?")));
41
42 // URLs canonicalize \ to / so this is equivalent to "...//*" and "...//x"
43 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches(
44 GURL("http://www.example.com/\\*"), GURL("http://www.example.com/\\x")));
27 } 45 }
28 46
29 } // namespace content 47 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698