| 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/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 1064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1075 EXPECT_EQ(expected_headers, response.headers); | 1075 EXPECT_EQ(expected_headers, response.headers); |
| 1076 | 1076 |
| 1077 std::string body; | 1077 std::string body; |
| 1078 RunOnIOThread( | 1078 RunOnIOThread( |
| 1079 base::Bind(&ReadResponseBody, | 1079 base::Bind(&ReadResponseBody, |
| 1080 &body, base::Owned(blob_data_handle.release()))); | 1080 &body, base::Owned(blob_data_handle.release()))); |
| 1081 EXPECT_EQ("This resource is gone. Gone, gone, gone.", body); | 1081 EXPECT_EQ("This resource is gone. Gone, gone, gone.", body); |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, | 1084 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, |
| 1085 DISABLED_FetchEvent_respondWithRejection) { | 1085 FetchEvent_respondWithRejection) { |
| 1086 ServiceWorkerFetchEventResult result; | 1086 ServiceWorkerFetchEventResult result; |
| 1087 ServiceWorkerResponse response; | 1087 ServiceWorkerResponse response; |
| 1088 scoped_ptr<storage::BlobDataHandle> blob_data_handle; | 1088 scoped_ptr<storage::BlobDataHandle> blob_data_handle; |
| 1089 | 1089 |
| 1090 RunOnIOThread(base::Bind(&self::SetUpRegistrationOnIOThread, this, | 1090 RunOnIOThread(base::Bind(&self::SetUpRegistrationOnIOThread, this, |
| 1091 "/service_worker/fetch_event_rejected.js")); | 1091 "/service_worker/fetch_event_rejected.js")); |
| 1092 | 1092 |
| 1093 ConsoleListener console_listener; | 1093 ConsoleListener console_listener; |
| 1094 version_->embedded_worker()->AddListener(&console_listener); | 1094 version_->embedded_worker()->AddListener(&console_listener); |
| 1095 | 1095 |
| 1096 FetchOnRegisteredWorker(&result, &response, &blob_data_handle); | 1096 FetchOnRegisteredWorker(&result, &response, &blob_data_handle); |
| 1097 const base::string16 expected = | 1097 const base::string16 expected1 = base::ASCIIToUTF16( |
| 1098 base::ASCIIToUTF16("Rejecting respondWith promise"); | 1098 "resulted in a network error response: the promise was rejected."); |
| 1099 console_listener.WaitForConsoleMessages(1); | 1099 const base::string16 expected2 = |
| 1100 base::ASCIIToUTF16("Uncaught (in promise) Rejecting respondWith promise"); |
| 1101 console_listener.WaitForConsoleMessages(2); |
| 1100 ASSERT_NE(base::string16::npos, | 1102 ASSERT_NE(base::string16::npos, |
| 1101 console_listener.messages()[0].find(expected)); | 1103 console_listener.messages()[0].find(expected1)); |
| 1104 ASSERT_EQ(0u, console_listener.messages()[1].find(expected2)); |
| 1102 version_->embedded_worker()->RemoveListener(&console_listener); | 1105 version_->embedded_worker()->RemoveListener(&console_listener); |
| 1103 | 1106 |
| 1104 ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, result); | 1107 ASSERT_EQ(SERVICE_WORKER_FETCH_EVENT_RESULT_RESPONSE, result); |
| 1105 EXPECT_EQ(0, response.status_code); | 1108 EXPECT_EQ(0, response.status_code); |
| 1106 | 1109 |
| 1107 ASSERT_FALSE(blob_data_handle); | 1110 ASSERT_FALSE(blob_data_handle); |
| 1108 } | 1111 } |
| 1109 | 1112 |
| 1110 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, SyncEventHandled) { | 1113 IN_PROC_BROWSER_TEST_F(ServiceWorkerVersionBrowserTest, SyncEventHandled) { |
| 1111 RunOnIOThread(base::Bind( | 1114 RunOnIOThread(base::Bind( |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1517 ASSERT_EQ(SERVICE_WORKER_OK, status); | 1520 ASSERT_EQ(SERVICE_WORKER_OK, status); |
| 1518 // Stop the worker. | 1521 // Stop the worker. |
| 1519 StopWorker(SERVICE_WORKER_OK); | 1522 StopWorker(SERVICE_WORKER_OK); |
| 1520 // Restart the worker. | 1523 // Restart the worker. |
| 1521 StartWorker(SERVICE_WORKER_OK); | 1524 StartWorker(SERVICE_WORKER_OK); |
| 1522 // Stop the worker. | 1525 // Stop the worker. |
| 1523 StopWorker(SERVICE_WORKER_OK); | 1526 StopWorker(SERVICE_WORKER_OK); |
| 1524 } | 1527 } |
| 1525 | 1528 |
| 1526 } // namespace content | 1529 } // namespace content |
| OLD | NEW |