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

Side by Side Diff: net/proxy/proxy_resolver_v8_unittest.cc

Issue 149525: Remove the concept of threading from ProxyService, and move it into the Proxy... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Add missing header for mac Created 11 years, 4 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
« no previous file with comments | « net/proxy/proxy_resolver_v8.cc ('k') | net/proxy/proxy_resolver_winhttp.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/file_util.h" 5 #include "base/file_util.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "googleurl/src/gurl.h" 8 #include "googleurl/src/gurl.h"
9 #include "net/base/mock_host_resolver.h" 9 #include "net/base/mock_host_resolver.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 78
79 // Try to read the file from disk. 79 // Try to read the file from disk.
80 std::string file_contents; 80 std::string file_contents;
81 bool ok = file_util::ReadFileToString(path, &file_contents); 81 bool ok = file_util::ReadFileToString(path, &file_contents);
82 82
83 // If we can't load the file from disk, something is misconfigured. 83 // If we can't load the file from disk, something is misconfigured.
84 LOG_IF(ERROR, !ok) << "Failed to read file: " << path.value(); 84 LOG_IF(ERROR, !ok) << "Failed to read file: " << path.value();
85 ASSERT_TRUE(ok); 85 ASSERT_TRUE(ok);
86 86
87 // Load the PAC script into the ProxyResolver. 87 // Load the PAC script into the ProxyResolver.
88 SetPacScript(file_contents); 88 SetPacScriptByData(file_contents);
89 } 89 }
90 }; 90 };
91 91
92 // Doesn't really matter what these values are for many of the tests. 92 // Doesn't really matter what these values are for many of the tests.
93 const GURL kQueryUrl("http://www.google.com"); 93 const GURL kQueryUrl("http://www.google.com");
94 const GURL kPacUrl; 94 const GURL kPacUrl;
95 95
96 } 96 }
97 97
98 TEST(ProxyResolverV8Test, Direct) { 98 TEST(ProxyResolverV8Test, Direct) {
99 ProxyResolverV8WithMockBindings resolver; 99 ProxyResolverV8WithMockBindings resolver;
100 resolver.SetPacScriptFromDisk("direct.js"); 100 resolver.SetPacScriptFromDisk("direct.js");
101 101
102 net::ProxyInfo proxy_info; 102 net::ProxyInfo proxy_info;
103 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 103 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
104 104
105 EXPECT_EQ(net::OK, result); 105 EXPECT_EQ(net::OK, result);
106 EXPECT_TRUE(proxy_info.is_direct()); 106 EXPECT_TRUE(proxy_info.is_direct());
107 107
108 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 108 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
109 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 109 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
110 } 110 }
111 111
112 TEST(ProxyResolverV8Test, ReturnEmptyString) { 112 TEST(ProxyResolverV8Test, ReturnEmptyString) {
113 ProxyResolverV8WithMockBindings resolver; 113 ProxyResolverV8WithMockBindings resolver;
114 resolver.SetPacScriptFromDisk("return_empty_string.js"); 114 resolver.SetPacScriptFromDisk("return_empty_string.js");
115 115
116 net::ProxyInfo proxy_info; 116 net::ProxyInfo proxy_info;
117 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 117 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
118 118
119 EXPECT_EQ(net::OK, result); 119 EXPECT_EQ(net::OK, result);
120 EXPECT_TRUE(proxy_info.is_direct()); 120 EXPECT_TRUE(proxy_info.is_direct());
121 121
122 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 122 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
123 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 123 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
124 } 124 }
125 125
126 TEST(ProxyResolverV8Test, Basic) { 126 TEST(ProxyResolverV8Test, Basic) {
127 ProxyResolverV8WithMockBindings resolver; 127 ProxyResolverV8WithMockBindings resolver;
128 resolver.SetPacScriptFromDisk("passthrough.js"); 128 resolver.SetPacScriptFromDisk("passthrough.js");
129 129
130 // The "FindProxyForURL" of this PAC script simply concatenates all of the 130 // The "FindProxyForURL" of this PAC script simply concatenates all of the
131 // arguments into a pseudo-host. The purpose of this test is to verify that 131 // arguments into a pseudo-host. The purpose of this test is to verify that
132 // the correct arguments are being passed to FindProxyForURL(). 132 // the correct arguments are being passed to FindProxyForURL().
133 { 133 {
134 net::ProxyInfo proxy_info; 134 net::ProxyInfo proxy_info;
135 int result = resolver.GetProxyForURL(GURL("http://query.com/path"), 135 int result = resolver.GetProxyForURL(GURL("http://query.com/path"),
136 kPacUrl, &proxy_info); 136 &proxy_info, NULL, NULL);
137 EXPECT_EQ(net::OK, result); 137 EXPECT_EQ(net::OK, result);
138 EXPECT_EQ("http.query.com.path.query.com:80", 138 EXPECT_EQ("http.query.com.path.query.com:80",
139 proxy_info.proxy_server().ToURI()); 139 proxy_info.proxy_server().ToURI());
140 } 140 }
141 { 141 {
142 net::ProxyInfo proxy_info; 142 net::ProxyInfo proxy_info;
143 int result = resolver.GetProxyForURL(GURL("ftp://query.com:90/path"), 143 int result = resolver.GetProxyForURL(GURL("ftp://query.com:90/path"),
144 kPacUrl, &proxy_info); 144 &proxy_info, NULL, NULL);
145 EXPECT_EQ(net::OK, result); 145 EXPECT_EQ(net::OK, result);
146 // Note that FindProxyForURL(url, host) does not expect |host| to contain 146 // Note that FindProxyForURL(url, host) does not expect |host| to contain
147 // the port number. 147 // the port number.
148 EXPECT_EQ("ftp.query.com.90.path.query.com:80", 148 EXPECT_EQ("ftp.query.com.90.path.query.com:80",
149 proxy_info.proxy_server().ToURI()); 149 proxy_info.proxy_server().ToURI());
150 150
151 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 151 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
152 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 152 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
153 } 153 }
154 } 154 }
155 155
156 TEST(ProxyResolverV8Test, BadReturnType) { 156 TEST(ProxyResolverV8Test, BadReturnType) {
157 // These are the filenames of PAC scripts which each return a non-string 157 // These are the filenames of PAC scripts which each return a non-string
158 // types for FindProxyForURL(). They should all fail with 158 // types for FindProxyForURL(). They should all fail with
159 // ERR_PAC_SCRIPT_FAILED. 159 // ERR_PAC_SCRIPT_FAILED.
160 static const char* const filenames[] = { 160 static const char* const filenames[] = {
161 "return_undefined.js", 161 "return_undefined.js",
162 "return_integer.js", 162 "return_integer.js",
163 "return_function.js", 163 "return_function.js",
164 "return_object.js", 164 "return_object.js",
165 // TODO(eroman): Should 'null' be considered equivalent to "DIRECT" ? 165 // TODO(eroman): Should 'null' be considered equivalent to "DIRECT" ?
166 "return_null.js" 166 "return_null.js"
167 }; 167 };
168 168
169 for (size_t i = 0; i < arraysize(filenames); ++i) { 169 for (size_t i = 0; i < arraysize(filenames); ++i) {
170 ProxyResolverV8WithMockBindings resolver; 170 ProxyResolverV8WithMockBindings resolver;
171 resolver.SetPacScriptFromDisk(filenames[i]); 171 resolver.SetPacScriptFromDisk(filenames[i]);
172 172
173 net::ProxyInfo proxy_info; 173 net::ProxyInfo proxy_info;
174 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 174 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
175 175
176 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result); 176 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result);
177 177
178 MockJSBindings* bindings = resolver.mock_js_bindings(); 178 MockJSBindings* bindings = resolver.mock_js_bindings();
179 EXPECT_EQ(0U, bindings->alerts.size()); 179 EXPECT_EQ(0U, bindings->alerts.size());
180 ASSERT_EQ(1U, bindings->errors.size()); 180 ASSERT_EQ(1U, bindings->errors.size());
181 EXPECT_EQ("FindProxyForURL() did not return a string.", 181 EXPECT_EQ("FindProxyForURL() did not return a string.",
182 bindings->errors[0]); 182 bindings->errors[0]);
183 EXPECT_EQ(-1, bindings->errors_line_number[0]); 183 EXPECT_EQ(-1, bindings->errors_line_number[0]);
184 } 184 }
185 } 185 }
186 186
187 // Try using a PAC script which defines no "FindProxyForURL" function. 187 // Try using a PAC script which defines no "FindProxyForURL" function.
188 TEST(ProxyResolverV8Test, NoEntryPoint) { 188 TEST(ProxyResolverV8Test, NoEntryPoint) {
189 ProxyResolverV8WithMockBindings resolver; 189 ProxyResolverV8WithMockBindings resolver;
190 resolver.SetPacScriptFromDisk("no_entrypoint.js"); 190 resolver.SetPacScriptFromDisk("no_entrypoint.js");
191 191
192 net::ProxyInfo proxy_info; 192 net::ProxyInfo proxy_info;
193 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 193 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
194 194
195 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result); 195 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result);
196 196
197 MockJSBindings* bindings = resolver.mock_js_bindings(); 197 MockJSBindings* bindings = resolver.mock_js_bindings();
198 EXPECT_EQ(0U, bindings->alerts.size()); 198 EXPECT_EQ(0U, bindings->alerts.size());
199 ASSERT_EQ(1U, bindings->errors.size()); 199 ASSERT_EQ(1U, bindings->errors.size());
200 EXPECT_EQ("FindProxyForURL() is undefined.", bindings->errors[0]); 200 EXPECT_EQ("FindProxyForURL() is undefined.", bindings->errors[0]);
201 EXPECT_EQ(-1, bindings->errors_line_number[0]); 201 EXPECT_EQ(-1, bindings->errors_line_number[0]);
202 } 202 }
203 203
204 // Try loading a malformed PAC script. 204 // Try loading a malformed PAC script.
205 TEST(ProxyResolverV8Test, ParseError) { 205 TEST(ProxyResolverV8Test, ParseError) {
206 ProxyResolverV8WithMockBindings resolver; 206 ProxyResolverV8WithMockBindings resolver;
207 resolver.SetPacScriptFromDisk("missing_close_brace.js"); 207 resolver.SetPacScriptFromDisk("missing_close_brace.js");
208 208
209 net::ProxyInfo proxy_info; 209 net::ProxyInfo proxy_info;
210 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 210 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
211 211
212 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result); 212 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result);
213 213
214 MockJSBindings* bindings = resolver.mock_js_bindings(); 214 MockJSBindings* bindings = resolver.mock_js_bindings();
215 EXPECT_EQ(0U, bindings->alerts.size()); 215 EXPECT_EQ(0U, bindings->alerts.size());
216 216
217 // We get two errors -- one during compilation, and then later when 217 // We get two errors -- one during compilation, and then later when
218 // trying to run FindProxyForURL(). 218 // trying to run FindProxyForURL().
219 ASSERT_EQ(2U, bindings->errors.size()); 219 ASSERT_EQ(2U, bindings->errors.size());
220 220
221 EXPECT_EQ("Uncaught SyntaxError: Unexpected end of input", 221 EXPECT_EQ("Uncaught SyntaxError: Unexpected end of input",
222 bindings->errors[0]); 222 bindings->errors[0]);
223 EXPECT_EQ(-1, bindings->errors_line_number[0]); 223 EXPECT_EQ(-1, bindings->errors_line_number[0]);
224 224
225 EXPECT_EQ("FindProxyForURL() is undefined.", bindings->errors[1]); 225 EXPECT_EQ("FindProxyForURL() is undefined.", bindings->errors[1]);
226 EXPECT_EQ(-1, bindings->errors_line_number[1]); 226 EXPECT_EQ(-1, bindings->errors_line_number[1]);
227 } 227 }
228 228
229 // Run a PAC script several times, which has side-effects. 229 // Run a PAC script several times, which has side-effects.
230 TEST(ProxyResolverV8Test, SideEffects) { 230 TEST(ProxyResolverV8Test, SideEffects) {
231 ProxyResolverV8WithMockBindings resolver; 231 ProxyResolverV8WithMockBindings resolver;
232 resolver.SetPacScriptFromDisk("side_effects.js"); 232 resolver.SetPacScriptFromDisk("side_effects.js");
233 233
234 // The PAC script increments a counter each time we invoke it. 234 // The PAC script increments a counter each time we invoke it.
235 for (int i = 0; i < 3; ++i) { 235 for (int i = 0; i < 3; ++i) {
236 net::ProxyInfo proxy_info; 236 net::ProxyInfo proxy_info;
237 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 237 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
238 EXPECT_EQ(net::OK, result); 238 EXPECT_EQ(net::OK, result);
239 EXPECT_EQ(StringPrintf("sideffect_%d:80", i), 239 EXPECT_EQ(StringPrintf("sideffect_%d:80", i),
240 proxy_info.proxy_server().ToURI()); 240 proxy_info.proxy_server().ToURI());
241 } 241 }
242 242
243 // Reload the script -- the javascript environment should be reset, hence 243 // Reload the script -- the javascript environment should be reset, hence
244 // the counter starts over. 244 // the counter starts over.
245 resolver.SetPacScriptFromDisk("side_effects.js"); 245 resolver.SetPacScriptFromDisk("side_effects.js");
246 246
247 for (int i = 0; i < 3; ++i) { 247 for (int i = 0; i < 3; ++i) {
248 net::ProxyInfo proxy_info; 248 net::ProxyInfo proxy_info;
249 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 249 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
250 EXPECT_EQ(net::OK, result); 250 EXPECT_EQ(net::OK, result);
251 EXPECT_EQ(StringPrintf("sideffect_%d:80", i), 251 EXPECT_EQ(StringPrintf("sideffect_%d:80", i),
252 proxy_info.proxy_server().ToURI()); 252 proxy_info.proxy_server().ToURI());
253 } 253 }
254 } 254 }
255 255
256 // Execute a PAC script which throws an exception in FindProxyForURL. 256 // Execute a PAC script which throws an exception in FindProxyForURL.
257 TEST(ProxyResolverV8Test, UnhandledException) { 257 TEST(ProxyResolverV8Test, UnhandledException) {
258 ProxyResolverV8WithMockBindings resolver; 258 ProxyResolverV8WithMockBindings resolver;
259 resolver.SetPacScriptFromDisk("unhandled_exception.js"); 259 resolver.SetPacScriptFromDisk("unhandled_exception.js");
260 260
261 net::ProxyInfo proxy_info; 261 net::ProxyInfo proxy_info;
262 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 262 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
263 263
264 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result); 264 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result);
265 265
266 MockJSBindings* bindings = resolver.mock_js_bindings(); 266 MockJSBindings* bindings = resolver.mock_js_bindings();
267 EXPECT_EQ(0U, bindings->alerts.size()); 267 EXPECT_EQ(0U, bindings->alerts.size());
268 ASSERT_EQ(1U, bindings->errors.size()); 268 ASSERT_EQ(1U, bindings->errors.size());
269 EXPECT_EQ("Uncaught ReferenceError: undefined_variable is not defined", 269 EXPECT_EQ("Uncaught ReferenceError: undefined_variable is not defined",
270 bindings->errors[0]); 270 bindings->errors[0]);
271 EXPECT_EQ(3, bindings->errors_line_number[0]); 271 EXPECT_EQ(3, bindings->errors_line_number[0]);
272 } 272 }
273 273
274 // TODO(eroman): This test is disabed right now, since the parsing of 274 // TODO(eroman): This test is disabed right now, since the parsing of
275 // host/port doesn't check for non-ascii characters. 275 // host/port doesn't check for non-ascii characters.
276 TEST(ProxyResolverV8Test, DISABLED_ReturnUnicode) { 276 TEST(ProxyResolverV8Test, DISABLED_ReturnUnicode) {
277 ProxyResolverV8WithMockBindings resolver; 277 ProxyResolverV8WithMockBindings resolver;
278 resolver.SetPacScriptFromDisk("return_unicode.js"); 278 resolver.SetPacScriptFromDisk("return_unicode.js");
279 279
280 net::ProxyInfo proxy_info; 280 net::ProxyInfo proxy_info;
281 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 281 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
282 282
283 // The result from this resolve was unparseable, because it 283 // The result from this resolve was unparseable, because it
284 // wasn't ascii. 284 // wasn't ascii.
285 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result); 285 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result);
286 } 286 }
287 287
288 // Test the PAC library functions that we expose in the JS environmnet. 288 // Test the PAC library functions that we expose in the JS environmnet.
289 TEST(ProxyResolverV8Test, JavascriptLibrary) { 289 TEST(ProxyResolverV8Test, JavascriptLibrary) {
290 ProxyResolverV8WithMockBindings resolver; 290 ProxyResolverV8WithMockBindings resolver;
291 resolver.SetPacScriptFromDisk("pac_library_unittest.js"); 291 resolver.SetPacScriptFromDisk("pac_library_unittest.js");
292 292
293 net::ProxyInfo proxy_info; 293 net::ProxyInfo proxy_info;
294 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 294 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
295 295
296 // If the javascript side of this unit-test fails, it will throw a javascript 296 // If the javascript side of this unit-test fails, it will throw a javascript
297 // exception. Otherwise it will return "PROXY success:80". 297 // exception. Otherwise it will return "PROXY success:80".
298 EXPECT_EQ(net::OK, result); 298 EXPECT_EQ(net::OK, result);
299 EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI()); 299 EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI());
300 300
301 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 301 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
302 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 302 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
303 } 303 }
304 304
305 // Try resolving when SetPacScript() has not been called. 305 // Try resolving when SetPacScriptByData() has not been called.
306 TEST(ProxyResolverV8Test, NoSetPacScript) { 306 TEST(ProxyResolverV8Test, NoSetPacScript) {
307 ProxyResolverV8WithMockBindings resolver; 307 ProxyResolverV8WithMockBindings resolver;
308 308
309 net::ProxyInfo proxy_info; 309 net::ProxyInfo proxy_info;
310 310
311 // Resolve should fail, as we are not yet initialized with a script. 311 // Resolve should fail, as we are not yet initialized with a script.
312 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 312 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
313 EXPECT_EQ(net::ERR_FAILED, result); 313 EXPECT_EQ(net::ERR_FAILED, result);
314 314
315 // Initialize it. 315 // Initialize it.
316 resolver.SetPacScriptFromDisk("direct.js"); 316 resolver.SetPacScriptFromDisk("direct.js");
317 317
318 // Resolve should now succeed. 318 // Resolve should now succeed.
319 result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 319 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
320 EXPECT_EQ(net::OK, result); 320 EXPECT_EQ(net::OK, result);
321 321
322 // Clear it, by initializing with an empty string. 322 // Clear it, by initializing with an empty string.
323 resolver.SetPacScript(std::string()); 323 resolver.SetPacScriptByData(std::string());
324 324
325 // Resolve should fail again now. 325 // Resolve should fail again now.
326 result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 326 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
327 EXPECT_EQ(net::ERR_FAILED, result); 327 EXPECT_EQ(net::ERR_FAILED, result);
328 328
329 // Load a good script once more. 329 // Load a good script once more.
330 resolver.SetPacScriptFromDisk("direct.js"); 330 resolver.SetPacScriptFromDisk("direct.js");
331 result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 331 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
332 EXPECT_EQ(net::OK, result); 332 EXPECT_EQ(net::OK, result);
333 333
334 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 334 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
335 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 335 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
336 } 336 }
337 337
338 // Test marshalling/un-marshalling of values between C++/V8. 338 // Test marshalling/un-marshalling of values between C++/V8.
339 TEST(ProxyResolverV8Test, V8Bindings) { 339 TEST(ProxyResolverV8Test, V8Bindings) {
340 ProxyResolverV8WithMockBindings resolver; 340 ProxyResolverV8WithMockBindings resolver;
341 resolver.SetPacScriptFromDisk("bindings.js"); 341 resolver.SetPacScriptFromDisk("bindings.js");
342 342
343 net::ProxyInfo proxy_info; 343 net::ProxyInfo proxy_info;
344 int result = resolver.GetProxyForURL(kQueryUrl, kPacUrl, &proxy_info); 344 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
345 345
346 EXPECT_EQ(net::OK, result); 346 EXPECT_EQ(net::OK, result);
347 EXPECT_TRUE(proxy_info.is_direct()); 347 EXPECT_TRUE(proxy_info.is_direct());
348 348
349 MockJSBindings* bindings = resolver.mock_js_bindings(); 349 MockJSBindings* bindings = resolver.mock_js_bindings();
350 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 350 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
351 351
352 // Alert was called 5 times. 352 // Alert was called 5 times.
353 ASSERT_EQ(5U, bindings->alerts.size()); 353 ASSERT_EQ(5U, bindings->alerts.size());
354 EXPECT_EQ("undefined", bindings->alerts[0]); 354 EXPECT_EQ("undefined", bindings->alerts[0]);
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 scoped_ptr<net::ProxyResolverV8::JSBindings> bindings( 433 scoped_ptr<net::ProxyResolverV8::JSBindings> bindings(
434 net::ProxyResolverV8::CreateDefaultBindings( 434 net::ProxyResolverV8::CreateDefaultBindings(
435 new net::MockHostResolver, NULL)); 435 new net::MockHostResolver, NULL));
436 436
437 // Our IP address is always going to be 127.0.0.1, since we are using a 437 // Our IP address is always going to be 127.0.0.1, since we are using a
438 // mock host resolver. 438 // mock host resolver.
439 std::string my_ip_address = bindings->MyIpAddress(); 439 std::string my_ip_address = bindings->MyIpAddress();
440 440
441 EXPECT_EQ("127.0.0.1", my_ip_address); 441 EXPECT_EQ("127.0.0.1", my_ip_address);
442 } 442 }
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_v8.cc ('k') | net/proxy/proxy_resolver_winhttp.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698