diff options
author | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 20:26:04 +0000 |
---|---|---|
committer | michaeln@google.com <michaeln@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-11-12 20:26:04 +0000 |
commit | f06b43b8bf588d08631f5d3dc196fd9c0e9df3c7 (patch) | |
tree | c9ac43bc050ff591959e9ff4fd542bde192c708a /webkit | |
parent | dcd23fee75c291fe9b5e7019e3ee31694442ff9e (diff) | |
download | chromium_src-f06b43b8bf588d08631f5d3dc196fd9c0e9df3c7.zip chromium_src-f06b43b8bf588d08631f5d3dc196fd9c0e9df3c7.tar.gz chromium_src-f06b43b8bf588d08631f5d3dc196fd9c0e9df3c7.tar.bz2 |
* Fix a bug with the applicationCache.status return value. The wrong status value was visible via applicationCache.status after a swap because we sample GetStatus() before swappable_cache_ was cleared out.
* Pull the plug on support for file:// urls in DEBUG builds for now.
TEST=added to appcache_host_unittest.cc
BUG=none
Review URL: http://codereview.chromium.org/385071
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@31818 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/appcache/appcache_host.cc | 3 | ||||
-rw-r--r-- | webkit/appcache/appcache_host_unittest.cc | 16 | ||||
-rw-r--r-- | webkit/appcache/appcache_interfaces.cc | 8 |
3 files changed, 22 insertions, 5 deletions
diff --git a/webkit/appcache/appcache_host.cc b/webkit/appcache/appcache_host.cc index ab1ff6d..c79aba0 100644 --- a/webkit/appcache/appcache_host.cc +++ b/webkit/appcache/appcache_host.cc @@ -338,6 +338,7 @@ void AppCacheHost::AssociateCache(AppCache* cache) { } associated_cache_ = cache; + SetSwappableCache(cache ? cache->owning_group() : NULL); if (cache) { cache->AssociateHost(this); @@ -345,8 +346,6 @@ void AppCacheHost::AssociateCache(AppCache* cache) { } else { frontend_->OnCacheSelected(host_id_, kNoCacheId, UNCACHED); } - - SetSwappableCache(cache ? cache->owning_group() : NULL); } } // namespace appcache diff --git a/webkit/appcache/appcache_host_unittest.cc b/webkit/appcache/appcache_host_unittest.cc index 5e36eef..b92443c 100644 --- a/webkit/appcache/appcache_host_unittest.cc +++ b/webkit/appcache/appcache_host_unittest.cc @@ -26,7 +26,9 @@ class AppCacheHostTest : public testing::Test { public: MockFrontend() : last_host_id_(-222), last_cache_id_(-222), - last_status_(appcache::OBSOLETE) { + last_status_(appcache::OBSOLETE), + last_status_changed_(appcache::OBSOLETE), + last_event_id_(appcache::OBSOLETE_EVENT) { } virtual void OnCacheSelected(int host_id, int64 cache_id , @@ -38,15 +40,19 @@ class AppCacheHostTest : public testing::Test { virtual void OnStatusChanged(const std::vector<int>& host_ids, appcache::Status status) { + last_status_changed_ = status; } virtual void OnEventRaised(const std::vector<int>& host_ids, appcache::EventID event_id) { + last_event_id_ = event_id; } int last_host_id_; int64 last_cache_id_; appcache::Status last_status_; + appcache::Status last_status_changed_; + appcache::EventID last_event_id_; }; void GetStatusCallback(Status status, void* param) { @@ -153,7 +159,6 @@ TEST_F(AppCacheHostTest, ForeignEntry) { EXPECT_FALSE(host.is_selection_pending()); } - TEST_F(AppCacheHostTest, FailedCacheLoad) { // Reset our mock frontend mock_frontend_.last_cache_id_ = -333; @@ -240,8 +245,15 @@ TEST_F(AppCacheHostTest, SetSwappableCache) { host.SetSwappableCache(group1); EXPECT_EQ(cache1, host.swappable_cache_.get()); + mock_frontend_.last_host_id_ = -222; // to verify we received OnCacheSelected + host.AssociateCache(cache1); EXPECT_FALSE(host.swappable_cache_.get()); // was same as associated cache + EXPECT_EQ(appcache::IDLE, host.GetStatus()); + // verify OnCacheSelected was called + EXPECT_EQ(host.host_id(), mock_frontend_.last_host_id_); + EXPECT_EQ(cache1->cache_id(), mock_frontend_.last_cache_id_); + EXPECT_EQ(appcache::IDLE, mock_frontend_.last_status_); AppCache* cache2 = new AppCache(&service_, 222); cache2->set_complete(true); diff --git a/webkit/appcache/appcache_interfaces.cc b/webkit/appcache/appcache_interfaces.cc index d48f342..4ee686a 100644 --- a/webkit/appcache/appcache_interfaces.cc +++ b/webkit/appcache/appcache_interfaces.cc @@ -22,7 +22,13 @@ const char kHttpHEADMethod[] = "HEAD"; bool IsSchemeSupported(const GURL& url) { bool supported = url.SchemeIs(kHttpScheme) || url.SchemeIs(kHttpsScheme); #ifndef NDEBUG - supported |= url.SchemeIsFile(); + // TODO(michaeln): It would be really nice if this could optionally work for + // file urls too to help web developers experiment and test their apps, + // perhaps enabled via a cmd line flag or some other developer tool setting. + // Unfortunately file scheme URLRequest don't produce the same signalling + // (200 response codes, headers) as http URLRequests, so this doesn't work + // just yet. + // supported |= url.SchemeIsFile(); #endif return supported; } |