OLD | NEW |
1 // Copyright (c) 2011 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 "content/browser/renderer_host/resource_dispatcher_host.h" | 5 #include "content/browser/renderer_host/resource_dispatcher_host.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
(...skipping 1204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1215 EXPECT_EQ(1, host_.pending_requests()); | 1215 EXPECT_EQ(1, host_.pending_requests()); |
1216 | 1216 |
1217 // Cancelling by other methods shouldn't work either. | 1217 // Cancelling by other methods shouldn't work either. |
1218 host_.CancelRequestsForProcess(render_view_id); | 1218 host_.CancelRequestsForProcess(render_view_id); |
1219 EXPECT_EQ(1, host_.pending_requests()); | 1219 EXPECT_EQ(1, host_.pending_requests()); |
1220 | 1220 |
1221 // Cancelling by context should work. | 1221 // Cancelling by context should work. |
1222 host_.CancelRequestsForContext(&filter_->resource_context()); | 1222 host_.CancelRequestsForContext(&filter_->resource_context()); |
1223 EXPECT_EQ(0, host_.pending_requests()); | 1223 EXPECT_EQ(0, host_.pending_requests()); |
1224 } | 1224 } |
| 1225 |
| 1226 TEST_F(ResourceDispatcherHostTest, UnknownURLScheme) { |
| 1227 EXPECT_EQ(0, host_.pending_requests()); |
| 1228 |
| 1229 SetResourceType(ResourceType::MAIN_FRAME); |
| 1230 HandleScheme("http"); |
| 1231 |
| 1232 MakeTestRequest(0, 1, GURL("foo://bar")); |
| 1233 |
| 1234 // Flush all pending requests. |
| 1235 while (net::URLRequestTestJob::ProcessOnePendingMessage()) {} |
| 1236 |
| 1237 // Sorts out all the messages we saw by request. |
| 1238 ResourceIPCAccumulator::ClassifiedMessages msgs; |
| 1239 accum_.GetClassifiedMessages(&msgs); |
| 1240 |
| 1241 // We should have gotten one RequestComplete message. |
| 1242 ASSERT_EQ(1U, msgs[0].size()); |
| 1243 EXPECT_EQ(ResourceMsg_RequestComplete::ID, msgs[0][0].type()); |
| 1244 |
| 1245 // The RequestComplete message should have had status |
| 1246 // (FAILED, ERR_UNKNOWN_URL_SCHEME). |
| 1247 int request_id; |
| 1248 net::URLRequestStatus status; |
| 1249 |
| 1250 void* iter = NULL; |
| 1251 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &request_id)); |
| 1252 EXPECT_TRUE(IPC::ReadParam(&msgs[0][0], &iter, &status)); |
| 1253 |
| 1254 EXPECT_EQ(1, request_id); |
| 1255 EXPECT_EQ(net::URLRequestStatus::FAILED, status.status()); |
| 1256 EXPECT_EQ(net::ERR_UNKNOWN_URL_SCHEME, status.error()); |
| 1257 } |
OLD | NEW |