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

Side by Side Diff: webkit/appcache/appcache_request_handler_unittest.cc

Issue 6727006: Select a more appropiate appcache based on the opener or the parent of the new document. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 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
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <stack> 5 #include <stack>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/threading/thread.h" 10 #include "base/threading/thread.h"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 EXPECT_EQ(kNoCacheId, cache_id); 216 EXPECT_EQ(kNoCacheId, cache_id);
217 EXPECT_EQ(GURL(), manifest_url); 217 EXPECT_EQ(GURL(), manifest_url);
218 218
219 AppCacheURLRequestJob* fallback_job; 219 AppCacheURLRequestJob* fallback_job;
220 fallback_job = handler_->MaybeLoadFallbackForRedirect( 220 fallback_job = handler_->MaybeLoadFallbackForRedirect(
221 request_.get(), GURL("http://blah/redirect")); 221 request_.get(), GURL("http://blah/redirect"));
222 EXPECT_FALSE(fallback_job); 222 EXPECT_FALSE(fallback_job);
223 fallback_job = handler_->MaybeLoadFallbackForResponse(request_.get()); 223 fallback_job = handler_->MaybeLoadFallbackForResponse(request_.get());
224 EXPECT_FALSE(fallback_job); 224 EXPECT_FALSE(fallback_job);
225 225
226 EXPECT_TRUE(host_->preferred_manifest_url().is_empty());
227
226 TestFinished(); 228 TestFinished();
227 } 229 }
228 230
229 // MainResource_Hit -------------------------------------------------- 231 // MainResource_Hit --------------------------------------------------
230 232
231 void MainResource_Hit() { 233 void MainResource_Hit() {
232 PushNextTask(NewRunnableMethod( 234 PushNextTask(NewRunnableMethod(
233 this, &AppCacheRequestHandlerTest::Verify_MainResource_Hit)); 235 this, &AppCacheRequestHandlerTest::Verify_MainResource_Hit));
234 236
235 request_.reset(new MockURLRequest(GURL("http://blah/"))); 237 request_.reset(new MockURLRequest(GURL("http://blah/")));
(...skipping 21 matching lines...) Expand all
257 int64 cache_id = kNoCacheId; 259 int64 cache_id = kNoCacheId;
258 GURL manifest_url; 260 GURL manifest_url;
259 handler_->GetExtraResponseInfo(&cache_id, &manifest_url); 261 handler_->GetExtraResponseInfo(&cache_id, &manifest_url);
260 EXPECT_EQ(1, cache_id); 262 EXPECT_EQ(1, cache_id);
261 EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url); 263 EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url);
262 264
263 AppCacheURLRequestJob* fallback_job; 265 AppCacheURLRequestJob* fallback_job;
264 fallback_job = handler_->MaybeLoadFallbackForResponse(request_.get()); 266 fallback_job = handler_->MaybeLoadFallbackForResponse(request_.get());
265 EXPECT_FALSE(fallback_job); 267 EXPECT_FALSE(fallback_job);
266 268
269 EXPECT_EQ(GURL("http://blah/manifest/"),
270 host_->preferred_manifest_url());
271
267 TestFinished(); 272 TestFinished();
268 } 273 }
269 274
270 // MainResource_Fallback -------------------------------------------------- 275 // MainResource_Fallback --------------------------------------------------
271 276
272 void MainResource_Fallback() { 277 void MainResource_Fallback() {
273 PushNextTask(NewRunnableMethod( 278 PushNextTask(NewRunnableMethod(
274 this, &AppCacheRequestHandlerTest::Verify_MainResource_Fallback)); 279 this, &AppCacheRequestHandlerTest::Verify_MainResource_Fallback));
275 280
276 request_.reset(new MockURLRequest(GURL("http://blah/"))); 281 request_.reset(new MockURLRequest(GURL("http://blah/")));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 EXPECT_TRUE(job_->is_delivering_appcache_response()); 315 EXPECT_TRUE(job_->is_delivering_appcache_response());
311 316
312 int64 cache_id = kNoCacheId; 317 int64 cache_id = kNoCacheId;
313 GURL manifest_url; 318 GURL manifest_url;
314 handler_->GetExtraResponseInfo(&cache_id, &manifest_url); 319 handler_->GetExtraResponseInfo(&cache_id, &manifest_url);
315 EXPECT_EQ(1, cache_id); 320 EXPECT_EQ(1, cache_id);
316 EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url); 321 EXPECT_EQ(GURL("http://blah/manifest/"), manifest_url);
317 EXPECT_TRUE(host_->main_resource_was_fallback_); 322 EXPECT_TRUE(host_->main_resource_was_fallback_);
318 EXPECT_EQ(GURL("http://blah/fallbackurl"), host_->fallback_url_); 323 EXPECT_EQ(GURL("http://blah/fallbackurl"), host_->fallback_url_);
319 324
325 EXPECT_EQ(GURL("http://blah/manifest/"),
326 host_->preferred_manifest_url());
327
320 TestFinished(); 328 TestFinished();
321 } 329 }
322 330
323 // SubResource_Miss_WithNoCacheSelected ---------------------------------- 331 // SubResource_Miss_WithNoCacheSelected ----------------------------------
324 332
325 void SubResource_Miss_WithNoCacheSelected() { 333 void SubResource_Miss_WithNoCacheSelected() {
326 request_.reset(new MockURLRequest(GURL("http://blah/"))); 334 request_.reset(new MockURLRequest(GURL("http://blah/")));
327 handler_.reset(host_->CreateRequestHandler(request_.get(), 335 handler_.reset(host_->CreateRequestHandler(request_.get(),
328 ResourceType::SUB_RESOURCE)); 336 ResourceType::SUB_RESOURCE));
329 337
(...skipping 29 matching lines...) Expand all
359 367
360 TestFinished(); 368 TestFinished();
361 } 369 }
362 370
363 // SubResource_Miss_WithWaitForCacheSelection ----------------------------- 371 // SubResource_Miss_WithWaitForCacheSelection -----------------------------
364 372
365 void SubResource_Miss_WithWaitForCacheSelection() { 373 void SubResource_Miss_WithWaitForCacheSelection() {
366 // Precondition, the host is waiting on cache selection. 374 // Precondition, the host is waiting on cache selection.
367 scoped_refptr<AppCache> cache(MakeNewCache()); 375 scoped_refptr<AppCache> cache(MakeNewCache());
368 host_->pending_selected_cache_id_ = cache->cache_id(); 376 host_->pending_selected_cache_id_ = cache->cache_id();
377 host_->set_preferred_manifest_url(cache->owning_group()->manifest_url());
369 378
370 request_.reset(new MockURLRequest(GURL("http://blah/"))); 379 request_.reset(new MockURLRequest(GURL("http://blah/")));
371 handler_.reset(host_->CreateRequestHandler(request_.get(), 380 handler_.reset(host_->CreateRequestHandler(request_.get(),
372 ResourceType::SUB_RESOURCE)); 381 ResourceType::SUB_RESOURCE));
373 EXPECT_TRUE(handler_.get()); 382 EXPECT_TRUE(handler_.get());
374 job_ = handler_->MaybeLoadResource(request_.get()); 383 job_ = handler_->MaybeLoadResource(request_.get());
375 EXPECT_TRUE(job_.get()); 384 EXPECT_TRUE(job_.get());
376 EXPECT_TRUE(job_->is_waiting()); 385 EXPECT_TRUE(job_->is_waiting());
377 386
378 host_->FinishCacheSelection(cache, NULL); 387 host_->FinishCacheSelection(cache, NULL);
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 748
740 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) { 749 TEST_F(AppCacheRequestHandlerTest, WorkerRequest) {
741 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest); 750 RunTestOnIOThread(&AppCacheRequestHandlerTest::WorkerRequest);
742 } 751 }
743 752
744 } // namespace appcache 753 } // namespace appcache
745 754
746 // AppCacheRequestHandlerTest is expected to always live longer than the 755 // AppCacheRequestHandlerTest is expected to always live longer than the
747 // runnable methods. This lets us call NewRunnableMethod on its instances. 756 // runnable methods. This lets us call NewRunnableMethod on its instances.
748 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheRequestHandlerTest); 757 DISABLE_RUNNABLE_METHOD_REFCOUNT(appcache::AppCacheRequestHandlerTest);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698