diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-13 02:00:53 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-13 02:00:53 +0000 |
commit | e2cadec89844f232f4b8887e85cfb72182d49107 (patch) | |
tree | b387565d11df7aabfbd4c8b30b780b620bf0f9cf /webkit/appcache/appcache_unittest.cc | |
parent | 91f10325d9835d204cbe88693f79221b3b402931 (diff) | |
download | chromium_src-e2cadec89844f232f4b8887e85cfb72182d49107.zip chromium_src-e2cadec89844f232f4b8887e85cfb72182d49107.tar.gz chromium_src-e2cadec89844f232f4b8887e85cfb72182d49107.tar.bz2 |
AppCache INTERCEPT namespace.
- Add support for a custom CHROMIUM CACHE MANIFEST signature. Other browsers should ignore files with this signature.
- Parse intercept namespace entries out of the new CHROMIUM-INTERCEPT manifest section. Other browsers should ignore this entire section.
- Store and retrieve the new kind of namespace records in the database layer.
- Upgrade existing databases to the new schema.
- Look for matches in the new namespaces when handling main and sub resource requests.
- Add unit tests.
BUG=101565
Review URL: http://codereview.chromium.org/8396013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@114151 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/appcache/appcache_unittest.cc')
-rw-r--r-- | webkit/appcache/appcache_unittest.cc | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/webkit/appcache/appcache_unittest.cc b/webkit/appcache/appcache_unittest.cc index ecb29fe..2b1bb83 100644 --- a/webkit/appcache/appcache_unittest.cc +++ b/webkit/appcache/appcache_unittest.cc @@ -88,18 +88,19 @@ TEST(AppCacheTest, InitializeWithManifest) { manifest.explicit_urls.insert("http://one.com"); manifest.explicit_urls.insert("http://two.com"); manifest.fallback_namespaces.push_back( - FallbackNamespace(GURL("http://fb1.com"), GURL("http://fbone.com"))); + Namespace(FALLBACK_NAMESPACE, GURL("http://fb1.com"), + GURL("http://fbone.com"))); manifest.online_whitelist_namespaces.push_back(GURL("http://w1.com")); manifest.online_whitelist_namespaces.push_back(GURL("http://w2.com")); manifest.online_whitelist_all = true; cache->InitializeWithManifest(&manifest); - const std::vector<FallbackNamespace>& fallbacks = + const std::vector<Namespace>& fallbacks = cache->fallback_namespaces_; size_t expected = 1; EXPECT_EQ(expected, fallbacks.size()); - EXPECT_EQ(GURL("http://fb1.com"), fallbacks[0].first); - EXPECT_EQ(GURL("http://fbone.com"), fallbacks[0].second); + EXPECT_EQ(GURL("http://fb1.com"), fallbacks[0].namespace_url); + EXPECT_EQ(GURL("http://fbone.com"), fallbacks[0].target_url); const std::vector<GURL>& whitelist = cache->online_whitelist_namespaces_; expected = 2; EXPECT_EQ(expected, whitelist.size()); @@ -129,23 +130,36 @@ TEST(AppCacheTest, FindResponseForRequest) { "http://blah/online_namespace/explicit"); const GURL kFallbackTestUrl1("http://blah/fallback_namespace/1"); const GURL kFallbackTestUrl2("http://blah/fallback_namespace/longer2"); - const GURL kOnlineNamespaceWithinFallback( - "http://blah/fallback_namespace/1/online"); + const GURL kInterceptNamespace("http://blah/intercept_namespace/"); + const GURL kInterceptNamespaceWithinFallback( + "http://blah/fallback_namespace/intercept_namespace/"); + const GURL kInterceptNamespaceEntry("http://blah/intercept_entry"); + const GURL kOnlineNamespaceWithinOtherNamespaces( + "http://blah/fallback_namespace/intercept_namespace/1/online"); const int64 kFallbackResponseId1 = 1; const int64 kFallbackResponseId2 = 2; const int64 kManifestResponseId = 3; const int64 kForeignExplicitResponseId = 4; const int64 kExplicitInOnlineNamespaceResponseId = 5; + const int64 kInterceptResponseId = 6; Manifest manifest; manifest.online_whitelist_namespaces.push_back(kOnlineNamespaceUrl); manifest.online_whitelist_namespaces.push_back( - kOnlineNamespaceWithinFallback); + kOnlineNamespaceWithinOtherNamespaces); manifest.fallback_namespaces.push_back( - FallbackNamespace(kFallbackNamespaceUrl1, kFallbackEntryUrl1)); + Namespace(FALLBACK_NAMESPACE, kFallbackNamespaceUrl1, + kFallbackEntryUrl1)); manifest.fallback_namespaces.push_back( - FallbackNamespace(kFallbackNamespaceUrl2, kFallbackEntryUrl2)); + Namespace(FALLBACK_NAMESPACE, kFallbackNamespaceUrl2, + kFallbackEntryUrl2)); + manifest.intercept_namespaces.push_back( + Namespace(INTERCEPT_NAMESPACE, kInterceptNamespace, + kInterceptNamespaceEntry)); + manifest.intercept_namespaces.push_back( + Namespace(INTERCEPT_NAMESPACE, kInterceptNamespaceWithinFallback, + kInterceptNamespaceEntry)); // Create a cache with some namespaces and entries. scoped_refptr<AppCache> cache(new AppCache(&service, 1234)); @@ -167,6 +181,9 @@ TEST(AppCacheTest, FindResponseForRequest) { kExplicitInOnlineNamespaceUrl, AppCacheEntry(AppCacheEntry::EXPLICIT, kExplicitInOnlineNamespaceResponseId)); + cache->AddEntry( + kInterceptNamespaceEntry, + AppCacheEntry(AppCacheEntry::INTERCEPT, kInterceptResponseId)); cache->set_complete(true); // See that we get expected results from FindResponseForRequest @@ -239,7 +256,7 @@ TEST(AppCacheTest, FindResponseForRequest) { fallback_entry = AppCacheEntry(); // reset - found = cache->FindResponseForRequest(kOnlineNamespaceWithinFallback, + found = cache->FindResponseForRequest(kOnlineNamespaceWithinOtherNamespaces, &entry, &fallback_entry, &fallback_namespace, &network_namespace); EXPECT_TRUE(found); EXPECT_FALSE(entry.has_response_id()); @@ -249,12 +266,30 @@ TEST(AppCacheTest, FindResponseForRequest) { fallback_entry = AppCacheEntry(); // reset found = cache->FindResponseForRequest( - kOnlineNamespaceWithinFallback.Resolve("online_resource"), + kOnlineNamespaceWithinOtherNamespaces.Resolve("online_resource"), &entry, &fallback_entry, &fallback_namespace, &network_namespace); EXPECT_TRUE(found); EXPECT_FALSE(entry.has_response_id()); EXPECT_FALSE(fallback_entry.has_response_id()); EXPECT_TRUE(network_namespace); + + found = cache->FindResponseForRequest( + kInterceptNamespace.Resolve("intercept_me"), + &entry, &fallback_entry, &fallback_namespace, &network_namespace); + EXPECT_TRUE(found); + EXPECT_EQ(kInterceptResponseId, entry.response_id()); + EXPECT_FALSE(fallback_entry.has_response_id()); + EXPECT_FALSE(network_namespace); + + entry = AppCacheEntry(); // reset + + found = cache->FindResponseForRequest( + kInterceptNamespaceWithinFallback.Resolve("intercept_me"), + &entry, &fallback_entry, &fallback_namespace, &network_namespace); + EXPECT_TRUE(found); + EXPECT_EQ(kInterceptResponseId, entry.response_id()); + EXPECT_FALSE(fallback_entry.has_response_id()); + EXPECT_FALSE(network_namespace); } } // namespace appacache |