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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/callback.h" | 6 #include "base/callback.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "content/browser/fileapi/chrome_blob_storage_context.h" | 10 #include "content/browser/fileapi/chrome_blob_storage_context.h" |
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 CreateReceiver(BrowserThread::UI, done, result)); | 537 CreateReceiver(BrowserThread::UI, done, result)); |
538 } | 538 } |
539 | 539 |
540 void FetchOnIOThread(const base::Closure& done, | 540 void FetchOnIOThread(const base::Closure& done, |
541 bool* prepare_result, | 541 bool* prepare_result, |
542 FetchResult* result) { | 542 FetchResult* result) { |
543 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); | 543 ASSERT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::IO)); |
544 ServiceWorkerFetchRequest request( | 544 ServiceWorkerFetchRequest request( |
545 embedded_test_server()->GetURL("/service_worker/empty.html"), | 545 embedded_test_server()->GetURL("/service_worker/empty.html"), |
546 "GET", | 546 "GET", |
547 std::map<std::string, std::string>(), | 547 ServiceWorkerHeaderMap(), |
548 GURL(""), | 548 GURL(""), |
549 false); | 549 false); |
550 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); | 550 version_->SetStatus(ServiceWorkerVersion::ACTIVATED); |
551 version_->DispatchFetchEvent( | 551 version_->DispatchFetchEvent( |
552 request, | 552 request, |
553 CreatePrepareReceiver(prepare_result), | 553 CreatePrepareReceiver(prepare_result), |
554 CreateResponseReceiver( | 554 CreateResponseReceiver( |
555 BrowserThread::UI, done, blob_context_.get(), result)); | 555 BrowserThread::UI, done, blob_context_.get(), result)); |
556 } | 556 } |
557 | 557 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 | 694 |
695 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchEvent_Response) { | 695 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, FetchEvent_Response) { |
696 ServiceWorkerFetchEventResult result; | 696 ServiceWorkerFetchEventResult result; |
697 ServiceWorkerResponse response; | 697 ServiceWorkerResponse response; |
698 scoped_ptr<storage::BlobDataHandle> blob_data_handle; | 698 scoped_ptr<storage::BlobDataHandle> blob_data_handle; |
699 FetchTestHelper("/service_worker/fetch_event.js", | 699 FetchTestHelper("/service_worker/fetch_event.js", |
700 &result, &response, &blob_data_handle); | 700 &result, &response, &blob_data_handle); |
701 ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, result); | 701 ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, result); |
702 EXPECT_EQ(301, response.status_code); | 702 EXPECT_EQ(301, response.status_code); |
703 EXPECT_EQ("Moved Permanently", response.status_text); | 703 EXPECT_EQ("Moved Permanently", response.status_text); |
704 std::map<std::string, std::string> expected_headers; | 704 ServiceWorkerHeaderMap expected_headers; |
705 expected_headers["content-language"] = "fi"; | 705 expected_headers["content-language"] = "fi"; |
706 expected_headers["content-type"] = "text/html; charset=UTF-8"; | 706 expected_headers["content-type"] = "text/html; charset=UTF-8"; |
707 EXPECT_EQ(expected_headers, response.headers); | 707 EXPECT_EQ(expected_headers, response.headers); |
708 | 708 |
709 std::string body; | 709 std::string body; |
710 RunOnIOThread( | 710 RunOnIOThread( |
711 base::Bind(&ReadResponseBody, | 711 base::Bind(&ReadResponseBody, |
712 &body, base::Owned(blob_data_handle.release()))); | 712 &body, base::Owned(blob_data_handle.release()))); |
713 EXPECT_EQ("This resource is gone. Gone, gone, gone.", body); | 713 EXPECT_EQ("This resource is gone. Gone, gone, gone.", body); |
714 } | 714 } |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
946 RunOnIOThread( | 946 RunOnIOThread( |
947 base::Bind(&ServiceWorkerBlackBoxBrowserTest::FindRegistrationOnIO, | 947 base::Bind(&ServiceWorkerBlackBoxBrowserTest::FindRegistrationOnIO, |
948 this, | 948 this, |
949 embedded_test_server()->GetURL("/service_worker/empty.html"), | 949 embedded_test_server()->GetURL("/service_worker/empty.html"), |
950 &status)); | 950 &status)); |
951 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, status); | 951 EXPECT_EQ(SERVICE_WORKER_ERROR_NOT_FOUND, status); |
952 } | 952 } |
953 } | 953 } |
954 | 954 |
955 } // namespace content | 955 } // namespace content |
OLD | NEW |