OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/search/iframe_source.h" | 5 #include "chrome/browser/search/iframe_source.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/memory/ref_counted_memory.h" | 8 #include "base/memory/ref_counted_memory.h" |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
11 #include "chrome/browser/search/instant_io_context.h" | 11 #include "chrome/browser/search/instant_io_context.h" |
12 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
13 #include "content/public/browser/resource_request_info.h" | 13 #include "content/public/browser/resource_request_info.h" |
14 #include "content/public/test/mock_resource_context.h" | 14 #include "content/public/test/mock_resource_context.h" |
15 #include "content/public/test/test_browser_thread_bundle.h" | 15 #include "content/public/test/test_browser_thread_bundle.h" |
16 #include "grit/browser_resources.h" | 16 #include "grit/browser_resources.h" |
17 #include "net/base/request_priority.h" | |
17 #include "net/url_request/url_request.h" | 18 #include "net/url_request/url_request.h" |
18 #include "net/url_request/url_request_context.h" | 19 #include "net/url_request/url_request_context.h" |
19 #include "net/url_request/url_request_test_util.h" | 20 #include "net/url_request/url_request_test_util.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
22 | 23 |
23 const int kNonInstantRendererPID = 0; | 24 const int kNonInstantRendererPID = 0; |
24 const char kNonInstantOrigin[] = "http://evil"; | 25 const char kNonInstantOrigin[] = "http://evil"; |
25 const int kInstantRendererPID = 1; | 26 const int kInstantRendererPID = 1; |
26 const char kInstantOrigin[] = "chrome-search://instant"; | 27 const char kInstantOrigin[] = "chrome-search://instant"; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 } | 90 } |
90 return ""; | 91 return ""; |
91 } | 92 } |
92 | 93 |
93 net::URLRequest* MockRequest( | 94 net::URLRequest* MockRequest( |
94 const std::string& url, | 95 const std::string& url, |
95 bool allocate_info, | 96 bool allocate_info, |
96 int render_process_id, | 97 int render_process_id, |
97 int render_view_id) { | 98 int render_view_id) { |
98 net::URLRequest* request = | 99 net::URLRequest* request = |
99 new net::URLRequest(GURL(url), NULL, | 100 new net::URLRequest(GURL(url), |
100 resource_context_.GetRequestContext()); | 101 net::DEFAULT_PRIORITY, |
102 NULL, | |
103 resource_context_.GetRequestContext(), | |
104 NULL); | |
mmenke
2013/10/30 15:27:11
Again, don't want to add assumptions here.
akalin
2013/10/30 21:44:37
removed arg.
| |
101 if (allocate_info) { | 105 if (allocate_info) { |
102 content::ResourceRequestInfo::AllocateForTesting(request, | 106 content::ResourceRequestInfo::AllocateForTesting(request, |
103 ResourceType::SUB_FRAME, | 107 ResourceType::SUB_FRAME, |
104 &resource_context_, | 108 &resource_context_, |
105 render_process_id, | 109 render_process_id, |
106 render_view_id, | 110 render_view_id, |
107 false); | 111 false); |
108 } | 112 } |
109 return request; | 113 return request; |
110 } | 114 } |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
188 } | 192 } |
189 | 193 |
190 TEST_F(IframeSourceTest, SendJSWithOrigin) { | 194 TEST_F(IframeSourceTest, SendJSWithOrigin) { |
191 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInstantRendererPID, 0); | 195 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInstantRendererPID, 0); |
192 EXPECT_FALSE(response_string().empty()); | 196 EXPECT_FALSE(response_string().empty()); |
193 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kNonInstantRendererPID, 0); | 197 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kNonInstantRendererPID, 0); |
194 EXPECT_FALSE(response_string().empty()); | 198 EXPECT_FALSE(response_string().empty()); |
195 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInvalidRendererPID, 0); | 199 SendJSWithOrigin(IDR_MOST_VISITED_TITLE_JS, kInvalidRendererPID, 0); |
196 EXPECT_TRUE(response_string().empty()); | 200 EXPECT_TRUE(response_string().empty()); |
197 } | 201 } |
OLD | NEW |