| 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/browser/appcache/appcache.h" |
| 6 #include "content/browser/appcache/appcache_host.h" |
| 5 #include "content/browser/appcache/mock_appcache_service.h" | 7 #include "content/browser/appcache/mock_appcache_service.h" |
| 6 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 7 #include "webkit/browser/appcache/appcache.h" | |
| 8 #include "webkit/browser/appcache/appcache_host.h" | |
| 9 | |
| 10 using appcache::AppCache; | |
| 11 using appcache::AppCacheDatabase; | |
| 12 using appcache::AppCacheEntry; | |
| 13 using appcache::AppCacheFrontend; | |
| 14 using appcache::AppCacheGroup; | |
| 15 using appcache::AppCacheHost; | |
| 16 using appcache::AppCacheInfo; | |
| 17 using appcache::AppCacheErrorDetails; | |
| 18 using appcache::AppCacheEventID; | |
| 19 using appcache::APPCACHE_FALLBACK_NAMESPACE; | |
| 20 using appcache::APPCACHE_INTERCEPT_NAMESPACE; | |
| 21 using appcache::AppCacheLogLevel; | |
| 22 using appcache::Manifest; | |
| 23 using appcache::Namespace; | |
| 24 using appcache::NamespaceVector; | |
| 25 using appcache::APPCACHE_NETWORK_NAMESPACE; | |
| 26 using appcache::PARSE_MANIFEST_ALLOWING_INTERCEPTS; | |
| 27 using appcache::PARSE_MANIFEST_PER_STANDARD; | |
| 28 using appcache::AppCacheStatus; | |
| 29 | 9 |
| 30 namespace content { | 10 namespace content { |
| 31 | 11 |
| 32 namespace { | 12 namespace { |
| 33 | 13 |
| 34 class MockAppCacheFrontend : public AppCacheFrontend { | 14 class MockAppCacheFrontend : public AppCacheFrontend { |
| 35 public: | 15 public: |
| 36 virtual void OnCacheSelected(int host_id, const AppCacheInfo& info) OVERRIDE { | 16 virtual void OnCacheSelected(int host_id, const AppCacheInfo& info) OVERRIDE { |
| 37 } | 17 } |
| 38 virtual void OnStatusChanged(const std::vector<int>& host_ids, | 18 virtual void OnStatusChanged(const std::vector<int>& host_ids, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 | 105 |
| 126 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); | 106 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); |
| 127 EXPECT_TRUE(cache->fallback_namespaces_.empty()); | 107 EXPECT_TRUE(cache->fallback_namespaces_.empty()); |
| 128 EXPECT_TRUE(cache->online_whitelist_namespaces_.empty()); | 108 EXPECT_TRUE(cache->online_whitelist_namespaces_.empty()); |
| 129 EXPECT_FALSE(cache->online_whitelist_all_); | 109 EXPECT_FALSE(cache->online_whitelist_all_); |
| 130 | 110 |
| 131 Manifest manifest; | 111 Manifest manifest; |
| 132 manifest.explicit_urls.insert("http://one.com"); | 112 manifest.explicit_urls.insert("http://one.com"); |
| 133 manifest.explicit_urls.insert("http://two.com"); | 113 manifest.explicit_urls.insert("http://two.com"); |
| 134 manifest.fallback_namespaces.push_back( | 114 manifest.fallback_namespaces.push_back( |
| 135 Namespace(APPCACHE_FALLBACK_NAMESPACE, GURL("http://fb1.com"), | 115 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, GURL("http://fb1.com"), |
| 136 GURL("http://fbone.com"), true)); | 116 GURL("http://fbone.com"), true)); |
| 137 manifest.online_whitelist_namespaces.push_back( | 117 manifest.online_whitelist_namespaces.push_back( |
| 138 Namespace(APPCACHE_NETWORK_NAMESPACE, GURL("http://w1.com"), GURL(), false
)); | 118 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, GURL("http://w1.com"), |
| 119 GURL(), false)); |
| 139 manifest.online_whitelist_namespaces.push_back( | 120 manifest.online_whitelist_namespaces.push_back( |
| 140 Namespace(APPCACHE_NETWORK_NAMESPACE, GURL("http://w2.com"), GURL(), false
)); | 121 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, GURL("http://w2.com"), |
| 122 GURL(), false)); |
| 141 manifest.online_whitelist_all = true; | 123 manifest.online_whitelist_all = true; |
| 142 | 124 |
| 143 cache->InitializeWithManifest(&manifest); | 125 cache->InitializeWithManifest(&manifest); |
| 144 const std::vector<Namespace>& fallbacks = | 126 const std::vector<AppCacheNamespace>& fallbacks = |
| 145 cache->fallback_namespaces_; | 127 cache->fallback_namespaces_; |
| 146 size_t expected = 1; | 128 size_t expected = 1; |
| 147 EXPECT_EQ(expected, fallbacks.size()); | 129 EXPECT_EQ(expected, fallbacks.size()); |
| 148 EXPECT_EQ(GURL("http://fb1.com"), fallbacks[0].namespace_url); | 130 EXPECT_EQ(GURL("http://fb1.com"), fallbacks[0].namespace_url); |
| 149 EXPECT_EQ(GURL("http://fbone.com"), fallbacks[0].target_url); | 131 EXPECT_EQ(GURL("http://fbone.com"), fallbacks[0].target_url); |
| 150 EXPECT_TRUE(fallbacks[0].is_pattern); | 132 EXPECT_TRUE(fallbacks[0].is_pattern); |
| 151 const NamespaceVector& whitelist = cache->online_whitelist_namespaces_; | 133 const AppCacheNamespaceVector& whitelist = |
| 134 cache->online_whitelist_namespaces_; |
| 152 expected = 2; | 135 expected = 2; |
| 153 EXPECT_EQ(expected, whitelist.size()); | 136 EXPECT_EQ(expected, whitelist.size()); |
| 154 EXPECT_EQ(GURL("http://w1.com"), whitelist[0].namespace_url); | 137 EXPECT_EQ(GURL("http://w1.com"), whitelist[0].namespace_url); |
| 155 EXPECT_EQ(GURL("http://w2.com"), whitelist[1].namespace_url); | 138 EXPECT_EQ(GURL("http://w2.com"), whitelist[1].namespace_url); |
| 156 EXPECT_TRUE(cache->online_whitelist_all_); | 139 EXPECT_TRUE(cache->online_whitelist_all_); |
| 157 | 140 |
| 158 // Ensure collections in manifest were taken over by the cache rather than | 141 // Ensure collections in manifest were taken over by the cache rather than |
| 159 // copied. | 142 // copied. |
| 160 EXPECT_TRUE(manifest.fallback_namespaces.empty()); | 143 EXPECT_TRUE(manifest.fallback_namespaces.empty()); |
| 161 EXPECT_TRUE(manifest.online_whitelist_namespaces.empty()); | 144 EXPECT_TRUE(manifest.online_whitelist_namespaces.empty()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 186 | 169 |
| 187 const int64 kFallbackResponseId1 = 1; | 170 const int64 kFallbackResponseId1 = 1; |
| 188 const int64 kFallbackResponseId2 = 2; | 171 const int64 kFallbackResponseId2 = 2; |
| 189 const int64 kManifestResponseId = 3; | 172 const int64 kManifestResponseId = 3; |
| 190 const int64 kForeignExplicitResponseId = 4; | 173 const int64 kForeignExplicitResponseId = 4; |
| 191 const int64 kExplicitInOnlineNamespaceResponseId = 5; | 174 const int64 kExplicitInOnlineNamespaceResponseId = 5; |
| 192 const int64 kInterceptResponseId = 6; | 175 const int64 kInterceptResponseId = 6; |
| 193 | 176 |
| 194 Manifest manifest; | 177 Manifest manifest; |
| 195 manifest.online_whitelist_namespaces.push_back( | 178 manifest.online_whitelist_namespaces.push_back( |
| 196 Namespace(APPCACHE_NETWORK_NAMESPACE, kOnlineNamespaceUrl, | 179 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, kOnlineNamespaceUrl, |
| 197 GURL(), false)); | 180 GURL(), false)); |
| 198 manifest.online_whitelist_namespaces.push_back( | 181 manifest.online_whitelist_namespaces.push_back( |
| 199 Namespace(APPCACHE_NETWORK_NAMESPACE, | 182 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, |
| 200 kOnlineNamespaceWithinOtherNamespaces, | 183 kOnlineNamespaceWithinOtherNamespaces, GURL(), false)); |
| 201 GURL(), false)); | |
| 202 manifest.fallback_namespaces.push_back( | 184 manifest.fallback_namespaces.push_back( |
| 203 Namespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl1, | 185 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl1, |
| 204 kFallbackEntryUrl1, false)); | 186 kFallbackEntryUrl1, false)); |
| 205 manifest.fallback_namespaces.push_back( | 187 manifest.fallback_namespaces.push_back( |
| 206 Namespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl2, | 188 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackNamespaceUrl2, |
| 207 kFallbackEntryUrl2, false)); | 189 kFallbackEntryUrl2, false)); |
| 208 manifest.intercept_namespaces.push_back( | 190 manifest.intercept_namespaces.push_back( |
| 209 Namespace(APPCACHE_INTERCEPT_NAMESPACE, kInterceptNamespace, | 191 AppCacheNamespace(APPCACHE_INTERCEPT_NAMESPACE, kInterceptNamespace, |
| 210 kInterceptNamespaceEntry, false)); | 192 kInterceptNamespaceEntry, false)); |
| 211 manifest.intercept_namespaces.push_back( | 193 manifest.intercept_namespaces.push_back( |
| 212 Namespace(APPCACHE_INTERCEPT_NAMESPACE, kInterceptNamespaceWithinFallback, | 194 AppCacheNamespace(APPCACHE_INTERCEPT_NAMESPACE, |
| 213 kInterceptNamespaceEntry, false)); | 195 kInterceptNamespaceWithinFallback, kInterceptNamespaceEntry, false)); |
| 214 | 196 |
| 215 // Create a cache with some namespaces and entries. | 197 // Create a cache with some namespaces and entries. |
| 216 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); | 198 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); |
| 217 cache->InitializeWithManifest(&manifest); | 199 cache->InitializeWithManifest(&manifest); |
| 218 cache->AddEntry( | 200 cache->AddEntry( |
| 219 kFallbackEntryUrl1, | 201 kFallbackEntryUrl1, |
| 220 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId1)); | 202 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId1)); |
| 221 cache->AddEntry( | 203 cache->AddEntry( |
| 222 kFallbackEntryUrl2, | 204 kFallbackEntryUrl2, |
| 223 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId2)); | 205 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId2)); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 378 MockAppCacheService service; | 360 MockAppCacheService service; |
| 379 | 361 |
| 380 // Setup an appcache with an intercept namespace that uses pattern matching. | 362 // Setup an appcache with an intercept namespace that uses pattern matching. |
| 381 const GURL kInterceptNamespaceBase("http://blah/intercept_namespace/"); | 363 const GURL kInterceptNamespaceBase("http://blah/intercept_namespace/"); |
| 382 const GURL kInterceptPatternNamespace( | 364 const GURL kInterceptPatternNamespace( |
| 383 kInterceptNamespaceBase.Resolve("*.hit*")); | 365 kInterceptNamespaceBase.Resolve("*.hit*")); |
| 384 const GURL kInterceptNamespaceEntry("http://blah/intercept_resource"); | 366 const GURL kInterceptNamespaceEntry("http://blah/intercept_resource"); |
| 385 const int64 kInterceptResponseId = 1; | 367 const int64 kInterceptResponseId = 1; |
| 386 Manifest manifest; | 368 Manifest manifest; |
| 387 manifest.intercept_namespaces.push_back( | 369 manifest.intercept_namespaces.push_back( |
| 388 Namespace(APPCACHE_INTERCEPT_NAMESPACE, kInterceptPatternNamespace, | 370 AppCacheNamespace(APPCACHE_INTERCEPT_NAMESPACE, |
| 389 kInterceptNamespaceEntry, true)); | 371 kInterceptPatternNamespace, kInterceptNamespaceEntry, true)); |
| 390 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); | 372 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); |
| 391 cache->InitializeWithManifest(&manifest); | 373 cache->InitializeWithManifest(&manifest); |
| 392 cache->AddEntry( | 374 cache->AddEntry( |
| 393 kInterceptNamespaceEntry, | 375 kInterceptNamespaceEntry, |
| 394 AppCacheEntry(AppCacheEntry::INTERCEPT, kInterceptResponseId)); | 376 AppCacheEntry(AppCacheEntry::INTERCEPT, kInterceptResponseId)); |
| 395 cache->set_complete(true); | 377 cache->set_complete(true); |
| 396 | 378 |
| 397 // See that the pattern match works. | 379 // See that the pattern match works. |
| 398 bool found = false; | 380 bool found = false; |
| 399 AppCacheEntry entry; | 381 AppCacheEntry entry; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 MockAppCacheService service; | 431 MockAppCacheService service; |
| 450 | 432 |
| 451 // Setup an appcache with a fallback namespace that uses pattern matching. | 433 // Setup an appcache with a fallback namespace that uses pattern matching. |
| 452 const GURL kFallbackNamespaceBase("http://blah/fallback_namespace/"); | 434 const GURL kFallbackNamespaceBase("http://blah/fallback_namespace/"); |
| 453 const GURL kFallbackPatternNamespace( | 435 const GURL kFallbackPatternNamespace( |
| 454 kFallbackNamespaceBase.Resolve("*.hit*")); | 436 kFallbackNamespaceBase.Resolve("*.hit*")); |
| 455 const GURL kFallbackNamespaceEntry("http://blah/fallback_resource"); | 437 const GURL kFallbackNamespaceEntry("http://blah/fallback_resource"); |
| 456 const int64 kFallbackResponseId = 1; | 438 const int64 kFallbackResponseId = 1; |
| 457 Manifest manifest; | 439 Manifest manifest; |
| 458 manifest.fallback_namespaces.push_back( | 440 manifest.fallback_namespaces.push_back( |
| 459 Namespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackPatternNamespace, | 441 AppCacheNamespace(APPCACHE_FALLBACK_NAMESPACE, kFallbackPatternNamespace, |
| 460 kFallbackNamespaceEntry, true)); | 442 kFallbackNamespaceEntry, true)); |
| 461 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); | 443 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); |
| 462 cache->InitializeWithManifest(&manifest); | 444 cache->InitializeWithManifest(&manifest); |
| 463 cache->AddEntry( | 445 cache->AddEntry( |
| 464 kFallbackNamespaceEntry, | 446 kFallbackNamespaceEntry, |
| 465 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId)); | 447 AppCacheEntry(AppCacheEntry::FALLBACK, kFallbackResponseId)); |
| 466 cache->set_complete(true); | 448 cache->set_complete(true); |
| 467 | 449 |
| 468 // See that the pattern match works. | 450 // See that the pattern match works. |
| 469 bool found = false; | 451 bool found = false; |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 519 | 501 |
| 520 TEST(AppCacheTest, FindNetworkNamespacePatternResponseForRequest) { | 502 TEST(AppCacheTest, FindNetworkNamespacePatternResponseForRequest) { |
| 521 MockAppCacheService service; | 503 MockAppCacheService service; |
| 522 | 504 |
| 523 // Setup an appcache with a network namespace that uses pattern matching. | 505 // Setup an appcache with a network namespace that uses pattern matching. |
| 524 const GURL kNetworkNamespaceBase("http://blah/network_namespace/"); | 506 const GURL kNetworkNamespaceBase("http://blah/network_namespace/"); |
| 525 const GURL kNetworkPatternNamespace( | 507 const GURL kNetworkPatternNamespace( |
| 526 kNetworkNamespaceBase.Resolve("*.hit*")); | 508 kNetworkNamespaceBase.Resolve("*.hit*")); |
| 527 Manifest manifest; | 509 Manifest manifest; |
| 528 manifest.online_whitelist_namespaces.push_back( | 510 manifest.online_whitelist_namespaces.push_back( |
| 529 Namespace(APPCACHE_NETWORK_NAMESPACE, kNetworkPatternNamespace, | 511 AppCacheNamespace(APPCACHE_NETWORK_NAMESPACE, kNetworkPatternNamespace, |
| 530 GURL(), true)); | 512 GURL(), true)); |
| 531 manifest.online_whitelist_all = false; | 513 manifest.online_whitelist_all = false; |
| 532 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); | 514 scoped_refptr<AppCache> cache(new AppCache(service.storage(), 1234)); |
| 533 cache->InitializeWithManifest(&manifest); | 515 cache->InitializeWithManifest(&manifest); |
| 534 cache->set_complete(true); | 516 cache->set_complete(true); |
| 535 | 517 |
| 536 // See that the pattern match works. | 518 // See that the pattern match works. |
| 537 bool found = false; | 519 bool found = false; |
| 538 AppCacheEntry entry; | 520 AppCacheEntry entry; |
| 539 AppCacheEntry fallback_entry; | 521 AppCacheEntry fallback_entry; |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 cache->GetFallbackEntryUrl(GURL("http://foo.com/"))); | 619 cache->GetFallbackEntryUrl(GURL("http://foo.com/"))); |
| 638 EXPECT_EQ(1 + 2 + 3, cache->cache_size()); | 620 EXPECT_EQ(1 + 2 + 3, cache->cache_size()); |
| 639 EXPECT_EQ(APPCACHE_NETWORK_NAMESPACE, | 621 EXPECT_EQ(APPCACHE_NETWORK_NAMESPACE, |
| 640 cache->online_whitelist_namespaces_[0].type); | 622 cache->online_whitelist_namespaces_[0].type); |
| 641 EXPECT_TRUE(cache->online_whitelist_namespaces_[0].is_pattern); | 623 EXPECT_TRUE(cache->online_whitelist_namespaces_[0].is_pattern); |
| 642 EXPECT_EQ(kWhitelistUrl, | 624 EXPECT_EQ(kWhitelistUrl, |
| 643 cache->online_whitelist_namespaces_[0].namespace_url); | 625 cache->online_whitelist_namespaces_[0].namespace_url); |
| 644 } | 626 } |
| 645 | 627 |
| 646 TEST(AppCacheTest, IsNamespaceMatch) { | 628 TEST(AppCacheTest, IsNamespaceMatch) { |
| 647 Namespace prefix; | 629 AppCacheNamespace prefix; |
| 648 prefix.namespace_url = GURL("http://foo.com/prefix"); | 630 prefix.namespace_url = GURL("http://foo.com/prefix"); |
| 649 prefix.is_pattern = false; | 631 prefix.is_pattern = false; |
| 650 EXPECT_TRUE(prefix.IsMatch( | 632 EXPECT_TRUE(prefix.IsMatch( |
| 651 GURL("http://foo.com/prefix_and_anothing_goes"))); | 633 GURL("http://foo.com/prefix_and_anothing_goes"))); |
| 652 EXPECT_FALSE(prefix.IsMatch( | 634 EXPECT_FALSE(prefix.IsMatch( |
| 653 GURL("http://foo.com/nope"))); | 635 GURL("http://foo.com/nope"))); |
| 654 | 636 |
| 655 Namespace bar_no_star; | 637 AppCacheNamespace bar_no_star; |
| 656 bar_no_star.namespace_url = GURL("http://foo.com/bar"); | 638 bar_no_star.namespace_url = GURL("http://foo.com/bar"); |
| 657 bar_no_star.is_pattern = true; | 639 bar_no_star.is_pattern = true; |
| 658 EXPECT_TRUE(bar_no_star.IsMatch( | 640 EXPECT_TRUE(bar_no_star.IsMatch( |
| 659 GURL("http://foo.com/bar"))); | 641 GURL("http://foo.com/bar"))); |
| 660 EXPECT_FALSE(bar_no_star.IsMatch( | 642 EXPECT_FALSE(bar_no_star.IsMatch( |
| 661 GURL("http://foo.com/bar/nope"))); | 643 GURL("http://foo.com/bar/nope"))); |
| 662 | 644 |
| 663 Namespace bar_star; | 645 AppCacheNamespace bar_star; |
| 664 bar_star.namespace_url = GURL("http://foo.com/bar/*"); | 646 bar_star.namespace_url = GURL("http://foo.com/bar/*"); |
| 665 bar_star.is_pattern = true; | 647 bar_star.is_pattern = true; |
| 666 EXPECT_TRUE(bar_star.IsMatch( | 648 EXPECT_TRUE(bar_star.IsMatch( |
| 667 GURL("http://foo.com/bar/"))); | 649 GURL("http://foo.com/bar/"))); |
| 668 EXPECT_TRUE(bar_star.IsMatch( | 650 EXPECT_TRUE(bar_star.IsMatch( |
| 669 GURL("http://foo.com/bar/should_match"))); | 651 GURL("http://foo.com/bar/should_match"))); |
| 670 EXPECT_FALSE(bar_star.IsMatch( | 652 EXPECT_FALSE(bar_star.IsMatch( |
| 671 GURL("http://foo.com/not_bar/should_not_match"))); | 653 GURL("http://foo.com/not_bar/should_not_match"))); |
| 672 | 654 |
| 673 Namespace star_bar_star; | 655 AppCacheNamespace star_bar_star; |
| 674 star_bar_star.namespace_url = GURL("http://foo.com/*/bar/*"); | 656 star_bar_star.namespace_url = GURL("http://foo.com/*/bar/*"); |
| 675 star_bar_star.is_pattern = true; | 657 star_bar_star.is_pattern = true; |
| 676 EXPECT_TRUE(star_bar_star.IsMatch( | 658 EXPECT_TRUE(star_bar_star.IsMatch( |
| 677 GURL("http://foo.com/any/bar/should_match"))); | 659 GURL("http://foo.com/any/bar/should_match"))); |
| 678 EXPECT_TRUE(star_bar_star.IsMatch( | 660 EXPECT_TRUE(star_bar_star.IsMatch( |
| 679 GURL("http://foo.com/any/bar/"))); | 661 GURL("http://foo.com/any/bar/"))); |
| 680 EXPECT_FALSE(star_bar_star.IsMatch( | 662 EXPECT_FALSE(star_bar_star.IsMatch( |
| 681 GURL("http://foo.com/any/not_bar/no_match"))); | 663 GURL("http://foo.com/any/not_bar/no_match"))); |
| 682 | 664 |
| 683 Namespace query_star_edit; | 665 AppCacheNamespace query_star_edit; |
| 684 query_star_edit.namespace_url = GURL("http://foo.com/query?id=*&verb=edit*"); | 666 query_star_edit.namespace_url = GURL("http://foo.com/query?id=*&verb=edit*"); |
| 685 query_star_edit.is_pattern = true; | 667 query_star_edit.is_pattern = true; |
| 686 EXPECT_TRUE(query_star_edit.IsMatch( | 668 EXPECT_TRUE(query_star_edit.IsMatch( |
| 687 GURL("http://foo.com/query?id=1234&verb=edit&option=blue"))); | 669 GURL("http://foo.com/query?id=1234&verb=edit&option=blue"))); |
| 688 EXPECT_TRUE(query_star_edit.IsMatch( | 670 EXPECT_TRUE(query_star_edit.IsMatch( |
| 689 GURL("http://foo.com/query?id=12345&option=blue&verb=edit"))); | 671 GURL("http://foo.com/query?id=12345&option=blue&verb=edit"))); |
| 690 EXPECT_FALSE(query_star_edit.IsMatch( | 672 EXPECT_FALSE(query_star_edit.IsMatch( |
| 691 GURL("http://foo.com/query?id=12345&option=blue&verb=print"))); | 673 GURL("http://foo.com/query?id=12345&option=blue&verb=print"))); |
| 692 EXPECT_TRUE(query_star_edit.IsMatch( | 674 EXPECT_TRUE(query_star_edit.IsMatch( |
| 693 GURL("http://foo.com/query?id=123&verb=print&verb=edit"))); | 675 GURL("http://foo.com/query?id=123&verb=print&verb=edit"))); |
| 694 | 676 |
| 695 Namespace star_greediness; | 677 AppCacheNamespace star_greediness; |
| 696 star_greediness.namespace_url = GURL("http://foo.com/*/b"); | 678 star_greediness.namespace_url = GURL("http://foo.com/*/b"); |
| 697 star_greediness.is_pattern = true; | 679 star_greediness.is_pattern = true; |
| 698 EXPECT_TRUE(star_greediness.IsMatch( | 680 EXPECT_TRUE(star_greediness.IsMatch( |
| 699 GURL("http://foo.com/a/b"))); | 681 GURL("http://foo.com/a/b"))); |
| 700 EXPECT_TRUE(star_greediness.IsMatch( | 682 EXPECT_TRUE(star_greediness.IsMatch( |
| 701 GURL("http://foo.com/a/wxy/z/b"))); | 683 GURL("http://foo.com/a/wxy/z/b"))); |
| 702 EXPECT_TRUE(star_greediness.IsMatch( | 684 EXPECT_TRUE(star_greediness.IsMatch( |
| 703 GURL("http://foo.com/a/b/b"))); | 685 GURL("http://foo.com/a/b/b"))); |
| 704 EXPECT_TRUE(star_greediness.IsMatch( | 686 EXPECT_TRUE(star_greediness.IsMatch( |
| 705 GURL("http://foo.com/b/b"))); | 687 GURL("http://foo.com/b/b"))); |
| 706 EXPECT_TRUE(star_greediness.IsMatch( | 688 EXPECT_TRUE(star_greediness.IsMatch( |
| 707 GURL("http://foo.com/a/b/b/b/b/b"))); | 689 GURL("http://foo.com/a/b/b/b/b/b"))); |
| 708 EXPECT_TRUE(star_greediness.IsMatch( | 690 EXPECT_TRUE(star_greediness.IsMatch( |
| 709 GURL("http://foo.com/a/b/b/b/a/b"))); | 691 GURL("http://foo.com/a/b/b/b/a/b"))); |
| 710 EXPECT_TRUE(star_greediness.IsMatch( | 692 EXPECT_TRUE(star_greediness.IsMatch( |
| 711 GURL("http://foo.com/a/b/01234567890abcdef/b"))); | 693 GURL("http://foo.com/a/b/01234567890abcdef/b"))); |
| 712 EXPECT_TRUE(star_greediness.IsMatch( | 694 EXPECT_TRUE(star_greediness.IsMatch( |
| 713 GURL("http://foo.com/a/b/01234567890abcdef/b01234567890abcdef/b"))); | 695 GURL("http://foo.com/a/b/01234567890abcdef/b01234567890abcdef/b"))); |
| 714 EXPECT_TRUE(star_greediness.IsMatch( | 696 EXPECT_TRUE(star_greediness.IsMatch( |
| 715 GURL("http://foo.com/a/b/01234567890abcdef_eat_some_more_characters_" | 697 GURL("http://foo.com/a/b/01234567890abcdef_eat_some_more_characters_" |
| 716 "/and_even_more_for_the_heck_of_it/01234567890abcdef/b"))); | 698 "/and_even_more_for_the_heck_of_it/01234567890abcdef/b"))); |
| 717 } | 699 } |
| 718 | 700 |
| 719 } // namespace content | 701 } // namespace content |
| OLD | NEW |