| 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/common/service_worker/service_worker_utils.h" | 5 #include "content/common/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 namespace { | 10 namespace { |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 GURL("http://www.example.com/"), GURL("http://www.example.com/"))); | 31 GURL("http://www.example.com/"), GURL("http://www.example.com/"))); |
| 32 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( | 32 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( |
| 33 GURL("http://www.example.com/"), | 33 GURL("http://www.example.com/"), |
| 34 GURL("http://www.example.com/page.html"))); | 34 GURL("http://www.example.com/page.html"))); |
| 35 | 35 |
| 36 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( | 36 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
| 37 GURL("http://www.example.com/"), GURL("https://www.example.com/"))); | 37 GURL("http://www.example.com/"), GURL("https://www.example.com/"))); |
| 38 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( | 38 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
| 39 GURL("http://www.example.com/"), | 39 GURL("http://www.example.com/"), |
| 40 GURL("https://www.example.com/page.html"))); | 40 GURL("https://www.example.com/page.html"))); |
| 41 ASSERT_TRUE(ServiceWorkerUtils::ScopeMatches( |
| 42 GURL("http://www.example.com/"), GURL("http://www.example.com/#a"))); |
| 41 | 43 |
| 42 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(GURL("http://www.example.com/"), | 44 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches(GURL("http://www.example.com/"), |
| 43 GURL("http://www.foo.com/"))); | 45 GURL("http://www.foo.com/"))); |
| 44 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( | 46 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
| 45 GURL("http://www.example.com/"), GURL("https://www.foo.com/page.html"))); | 47 GURL("http://www.example.com/"), GURL("https://www.foo.com/page.html"))); |
| 46 | 48 |
| 47 // '*' is not a wildcard. | 49 // '*' is not a wildcard. |
| 48 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( | 50 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
| 49 GURL("http://www.example.com/*"), GURL("http://www.example.com/x"))); | 51 GURL("http://www.example.com/*"), GURL("http://www.example.com/x"))); |
| 50 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( | 52 ASSERT_FALSE(ServiceWorkerUtils::ScopeMatches( |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 | 388 |
| 387 // Empty string resolves to max scope of "http://www.example.com/sw.js". | 389 // Empty string resolves to max scope of "http://www.example.com/sw.js". |
| 388 EXPECT_FALSE(IsPathRestrictionSatisfiedWithServiceWorkerAllowedHeader( | 390 EXPECT_FALSE(IsPathRestrictionSatisfiedWithServiceWorkerAllowedHeader( |
| 389 GURL("http://example.com/"), GURL("http://example.com/sw.js"), "")); | 391 GURL("http://example.com/"), GURL("http://example.com/sw.js"), "")); |
| 390 EXPECT_TRUE(IsPathRestrictionSatisfiedWithServiceWorkerAllowedHeader( | 392 EXPECT_TRUE(IsPathRestrictionSatisfiedWithServiceWorkerAllowedHeader( |
| 391 GURL("http://example.com/sw.js/hi"), GURL("http://example.com/sw.js"), | 393 GURL("http://example.com/sw.js/hi"), GURL("http://example.com/sw.js"), |
| 392 "")); | 394 "")); |
| 393 } | 395 } |
| 394 | 396 |
| 395 } // namespace content | 397 } // namespace content |
| OLD | NEW |