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

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

Issue 1783008: Cleanup: Remove the implicit constructor for BoundNetLog that allowed passing... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Sync Created 10 years, 7 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_service.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/net_log_unittest.h" 9 #include "net/base/net_log_unittest.h"
10 #include "net/base/net_errors.h" 10 #include "net/base/net_errors.h"
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 // No bindings were called, so no log entries. 131 // No bindings were called, so no log entries.
132 EXPECT_EQ(0u, log.entries().size()); 132 EXPECT_EQ(0u, log.entries().size());
133 } 133 }
134 134
135 TEST(ProxyResolverV8Test, ReturnEmptyString) { 135 TEST(ProxyResolverV8Test, ReturnEmptyString) {
136 ProxyResolverV8WithMockBindings resolver; 136 ProxyResolverV8WithMockBindings resolver;
137 int result = resolver.SetPacScriptFromDisk("return_empty_string.js"); 137 int result = resolver.SetPacScriptFromDisk("return_empty_string.js");
138 EXPECT_EQ(OK, result); 138 EXPECT_EQ(OK, result);
139 139
140 ProxyInfo proxy_info; 140 ProxyInfo proxy_info;
141 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 141 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
142 BoundNetLog());
142 143
143 EXPECT_EQ(OK, result); 144 EXPECT_EQ(OK, result);
144 EXPECT_TRUE(proxy_info.is_direct()); 145 EXPECT_TRUE(proxy_info.is_direct());
145 146
146 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 147 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
147 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 148 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
148 } 149 }
149 150
150 TEST(ProxyResolverV8Test, Basic) { 151 TEST(ProxyResolverV8Test, Basic) {
151 ProxyResolverV8WithMockBindings resolver; 152 ProxyResolverV8WithMockBindings resolver;
152 int result = resolver.SetPacScriptFromDisk("passthrough.js"); 153 int result = resolver.SetPacScriptFromDisk("passthrough.js");
153 EXPECT_EQ(OK, result); 154 EXPECT_EQ(OK, result);
154 155
155 // The "FindProxyForURL" of this PAC script simply concatenates all of the 156 // The "FindProxyForURL" of this PAC script simply concatenates all of the
156 // arguments into a pseudo-host. The purpose of this test is to verify that 157 // arguments into a pseudo-host. The purpose of this test is to verify that
157 // the correct arguments are being passed to FindProxyForURL(). 158 // the correct arguments are being passed to FindProxyForURL().
158 { 159 {
159 ProxyInfo proxy_info; 160 ProxyInfo proxy_info;
160 result = resolver.GetProxyForURL(GURL("http://query.com/path"), 161 result = resolver.GetProxyForURL(GURL("http://query.com/path"),
161 &proxy_info, NULL, NULL, NULL); 162 &proxy_info, NULL, NULL, BoundNetLog());
162 EXPECT_EQ(OK, result); 163 EXPECT_EQ(OK, result);
163 EXPECT_EQ("http.query.com.path.query.com:80", 164 EXPECT_EQ("http.query.com.path.query.com:80",
164 proxy_info.proxy_server().ToURI()); 165 proxy_info.proxy_server().ToURI());
165 } 166 }
166 { 167 {
167 ProxyInfo proxy_info; 168 ProxyInfo proxy_info;
168 int result = resolver.GetProxyForURL(GURL("ftp://query.com:90/path"), 169 int result = resolver.GetProxyForURL(GURL("ftp://query.com:90/path"),
169 &proxy_info, NULL, NULL, NULL); 170 &proxy_info, NULL, NULL,
171 BoundNetLog());
170 EXPECT_EQ(OK, result); 172 EXPECT_EQ(OK, result);
171 // Note that FindProxyForURL(url, host) does not expect |host| to contain 173 // Note that FindProxyForURL(url, host) does not expect |host| to contain
172 // the port number. 174 // the port number.
173 EXPECT_EQ("ftp.query.com.90.path.query.com:80", 175 EXPECT_EQ("ftp.query.com.90.path.query.com:80",
174 proxy_info.proxy_server().ToURI()); 176 proxy_info.proxy_server().ToURI());
175 177
176 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 178 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
177 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 179 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
178 } 180 }
179 181
(...skipping 17 matching lines...) Expand all
197 // TODO(eroman): Should 'null' be considered equivalent to "DIRECT" ? 199 // TODO(eroman): Should 'null' be considered equivalent to "DIRECT" ?
198 "return_null.js" 200 "return_null.js"
199 }; 201 };
200 202
201 for (size_t i = 0; i < arraysize(filenames); ++i) { 203 for (size_t i = 0; i < arraysize(filenames); ++i) {
202 ProxyResolverV8WithMockBindings resolver; 204 ProxyResolverV8WithMockBindings resolver;
203 int result = resolver.SetPacScriptFromDisk(filenames[i]); 205 int result = resolver.SetPacScriptFromDisk(filenames[i]);
204 EXPECT_EQ(OK, result); 206 EXPECT_EQ(OK, result);
205 207
206 ProxyInfo proxy_info; 208 ProxyInfo proxy_info;
207 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 209 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
210 BoundNetLog());
208 211
209 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result); 212 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
210 213
211 MockJSBindings* bindings = resolver.mock_js_bindings(); 214 MockJSBindings* bindings = resolver.mock_js_bindings();
212 EXPECT_EQ(0U, bindings->alerts.size()); 215 EXPECT_EQ(0U, bindings->alerts.size());
213 ASSERT_EQ(1U, bindings->errors.size()); 216 ASSERT_EQ(1U, bindings->errors.size());
214 EXPECT_EQ("FindProxyForURL() did not return a string.", 217 EXPECT_EQ("FindProxyForURL() did not return a string.",
215 bindings->errors[0]); 218 bindings->errors[0]);
216 EXPECT_EQ(-1, bindings->errors_line_number[0]); 219 EXPECT_EQ(-1, bindings->errors_line_number[0]);
217 } 220 }
218 } 221 }
219 222
220 // Try using a PAC script which defines no "FindProxyForURL" function. 223 // Try using a PAC script which defines no "FindProxyForURL" function.
221 TEST(ProxyResolverV8Test, NoEntryPoint) { 224 TEST(ProxyResolverV8Test, NoEntryPoint) {
222 ProxyResolverV8WithMockBindings resolver; 225 ProxyResolverV8WithMockBindings resolver;
223 int result = resolver.SetPacScriptFromDisk("no_entrypoint.js"); 226 int result = resolver.SetPacScriptFromDisk("no_entrypoint.js");
224 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result); 227 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
225 228
226 ProxyInfo proxy_info; 229 ProxyInfo proxy_info;
227 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 230 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
231 BoundNetLog());
228 232
229 EXPECT_EQ(ERR_FAILED, result); 233 EXPECT_EQ(ERR_FAILED, result);
230 } 234 }
231 235
232 // Try loading a malformed PAC script. 236 // Try loading a malformed PAC script.
233 TEST(ProxyResolverV8Test, ParseError) { 237 TEST(ProxyResolverV8Test, ParseError) {
234 ProxyResolverV8WithMockBindings resolver; 238 ProxyResolverV8WithMockBindings resolver;
235 int result = resolver.SetPacScriptFromDisk("missing_close_brace.js"); 239 int result = resolver.SetPacScriptFromDisk("missing_close_brace.js");
236 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result); 240 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
237 241
238 ProxyInfo proxy_info; 242 ProxyInfo proxy_info;
239 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 243 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
244 BoundNetLog());
240 245
241 EXPECT_EQ(ERR_FAILED, result); 246 EXPECT_EQ(ERR_FAILED, result);
242 247
243 MockJSBindings* bindings = resolver.mock_js_bindings(); 248 MockJSBindings* bindings = resolver.mock_js_bindings();
244 EXPECT_EQ(0U, bindings->alerts.size()); 249 EXPECT_EQ(0U, bindings->alerts.size());
245 250
246 // We get one error during compilation. 251 // We get one error during compilation.
247 ASSERT_EQ(1U, bindings->errors.size()); 252 ASSERT_EQ(1U, bindings->errors.size());
248 253
249 EXPECT_EQ("Uncaught SyntaxError: Unexpected end of input", 254 EXPECT_EQ("Uncaught SyntaxError: Unexpected end of input",
250 bindings->errors[0]); 255 bindings->errors[0]);
251 EXPECT_EQ(-1, bindings->errors_line_number[0]); 256 EXPECT_EQ(-1, bindings->errors_line_number[0]);
252 } 257 }
253 258
254 // Run a PAC script several times, which has side-effects. 259 // Run a PAC script several times, which has side-effects.
255 TEST(ProxyResolverV8Test, SideEffects) { 260 TEST(ProxyResolverV8Test, SideEffects) {
256 ProxyResolverV8WithMockBindings resolver; 261 ProxyResolverV8WithMockBindings resolver;
257 int result = resolver.SetPacScriptFromDisk("side_effects.js"); 262 int result = resolver.SetPacScriptFromDisk("side_effects.js");
258 263
259 // The PAC script increments a counter each time we invoke it. 264 // The PAC script increments a counter each time we invoke it.
260 for (int i = 0; i < 3; ++i) { 265 for (int i = 0; i < 3; ++i) {
261 ProxyInfo proxy_info; 266 ProxyInfo proxy_info;
262 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 267 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
268 BoundNetLog());
263 EXPECT_EQ(OK, result); 269 EXPECT_EQ(OK, result);
264 EXPECT_EQ(StringPrintf("sideffect_%d:80", i), 270 EXPECT_EQ(StringPrintf("sideffect_%d:80", i),
265 proxy_info.proxy_server().ToURI()); 271 proxy_info.proxy_server().ToURI());
266 } 272 }
267 273
268 // Reload the script -- the javascript environment should be reset, hence 274 // Reload the script -- the javascript environment should be reset, hence
269 // the counter starts over. 275 // the counter starts over.
270 result = resolver.SetPacScriptFromDisk("side_effects.js"); 276 result = resolver.SetPacScriptFromDisk("side_effects.js");
271 EXPECT_EQ(OK, result); 277 EXPECT_EQ(OK, result);
272 278
273 for (int i = 0; i < 3; ++i) { 279 for (int i = 0; i < 3; ++i) {
274 ProxyInfo proxy_info; 280 ProxyInfo proxy_info;
275 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 281 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
282 BoundNetLog());
276 EXPECT_EQ(OK, result); 283 EXPECT_EQ(OK, result);
277 EXPECT_EQ(StringPrintf("sideffect_%d:80", i), 284 EXPECT_EQ(StringPrintf("sideffect_%d:80", i),
278 proxy_info.proxy_server().ToURI()); 285 proxy_info.proxy_server().ToURI());
279 } 286 }
280 } 287 }
281 288
282 // Execute a PAC script which throws an exception in FindProxyForURL. 289 // Execute a PAC script which throws an exception in FindProxyForURL.
283 TEST(ProxyResolverV8Test, UnhandledException) { 290 TEST(ProxyResolverV8Test, UnhandledException) {
284 ProxyResolverV8WithMockBindings resolver; 291 ProxyResolverV8WithMockBindings resolver;
285 int result = resolver.SetPacScriptFromDisk("unhandled_exception.js"); 292 int result = resolver.SetPacScriptFromDisk("unhandled_exception.js");
286 EXPECT_EQ(OK, result); 293 EXPECT_EQ(OK, result);
287 294
288 ProxyInfo proxy_info; 295 ProxyInfo proxy_info;
289 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 296 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
297 BoundNetLog());
290 298
291 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result); 299 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
292 300
293 MockJSBindings* bindings = resolver.mock_js_bindings(); 301 MockJSBindings* bindings = resolver.mock_js_bindings();
294 EXPECT_EQ(0U, bindings->alerts.size()); 302 EXPECT_EQ(0U, bindings->alerts.size());
295 ASSERT_EQ(1U, bindings->errors.size()); 303 ASSERT_EQ(1U, bindings->errors.size());
296 EXPECT_EQ("Uncaught ReferenceError: undefined_variable is not defined", 304 EXPECT_EQ("Uncaught ReferenceError: undefined_variable is not defined",
297 bindings->errors[0]); 305 bindings->errors[0]);
298 EXPECT_EQ(3, bindings->errors_line_number[0]); 306 EXPECT_EQ(3, bindings->errors_line_number[0]);
299 } 307 }
300 308
301 // TODO(eroman): This test is disabed right now, since the parsing of 309 // TODO(eroman): This test is disabed right now, since the parsing of
302 // host/port doesn't check for non-ascii characters. 310 // host/port doesn't check for non-ascii characters.
303 TEST(ProxyResolverV8Test, DISABLED_ReturnUnicode) { 311 TEST(ProxyResolverV8Test, DISABLED_ReturnUnicode) {
304 ProxyResolverV8WithMockBindings resolver; 312 ProxyResolverV8WithMockBindings resolver;
305 int result = resolver.SetPacScriptFromDisk("return_unicode.js"); 313 int result = resolver.SetPacScriptFromDisk("return_unicode.js");
306 EXPECT_EQ(OK, result); 314 EXPECT_EQ(OK, result);
307 315
308 ProxyInfo proxy_info; 316 ProxyInfo proxy_info;
309 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 317 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
318 BoundNetLog());
310 319
311 // The result from this resolve was unparseable, because it 320 // The result from this resolve was unparseable, because it
312 // wasn't ascii. 321 // wasn't ascii.
313 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result); 322 EXPECT_EQ(ERR_PAC_SCRIPT_FAILED, result);
314 } 323 }
315 324
316 // Test the PAC library functions that we expose in the JS environmnet. 325 // Test the PAC library functions that we expose in the JS environmnet.
317 TEST(ProxyResolverV8Test, JavascriptLibrary) { 326 TEST(ProxyResolverV8Test, JavascriptLibrary) {
318 ProxyResolverV8WithMockBindings resolver; 327 ProxyResolverV8WithMockBindings resolver;
319 int result = resolver.SetPacScriptFromDisk("pac_library_unittest.js"); 328 int result = resolver.SetPacScriptFromDisk("pac_library_unittest.js");
320 EXPECT_EQ(OK, result); 329 EXPECT_EQ(OK, result);
321 330
322 ProxyInfo proxy_info; 331 ProxyInfo proxy_info;
323 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 332 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
333 BoundNetLog());
324 334
325 // If the javascript side of this unit-test fails, it will throw a javascript 335 // If the javascript side of this unit-test fails, it will throw a javascript
326 // exception. Otherwise it will return "PROXY success:80". 336 // exception. Otherwise it will return "PROXY success:80".
327 EXPECT_EQ(OK, result); 337 EXPECT_EQ(OK, result);
328 EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI()); 338 EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI());
329 339
330 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 340 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
331 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 341 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
332 } 342 }
333 343
334 // Try resolving when SetPacScriptByData() has not been called. 344 // Try resolving when SetPacScriptByData() has not been called.
335 TEST(ProxyResolverV8Test, NoSetPacScript) { 345 TEST(ProxyResolverV8Test, NoSetPacScript) {
336 ProxyResolverV8WithMockBindings resolver; 346 ProxyResolverV8WithMockBindings resolver;
337 347
338 ProxyInfo proxy_info; 348 ProxyInfo proxy_info;
339 349
340 // Resolve should fail, as we are not yet initialized with a script. 350 // Resolve should fail, as we are not yet initialized with a script.
341 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL) ; 351 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
352 BoundNetLog());
342 EXPECT_EQ(ERR_FAILED, result); 353 EXPECT_EQ(ERR_FAILED, result);
343 354
344 // Initialize it. 355 // Initialize it.
345 result = resolver.SetPacScriptFromDisk("direct.js"); 356 result = resolver.SetPacScriptFromDisk("direct.js");
346 EXPECT_EQ(OK, result); 357 EXPECT_EQ(OK, result);
347 358
348 // Resolve should now succeed. 359 // Resolve should now succeed.
349 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 360 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
361 BoundNetLog());
350 EXPECT_EQ(OK, result); 362 EXPECT_EQ(OK, result);
351 363
352 // Clear it, by initializing with an empty string. 364 // Clear it, by initializing with an empty string.
353 resolver.SetPacScriptByData(std::string(), NULL); 365 resolver.SetPacScriptByData(std::string(), NULL);
354 366
355 // Resolve should fail again now. 367 // Resolve should fail again now.
356 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 368 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
369 BoundNetLog());
357 EXPECT_EQ(ERR_FAILED, result); 370 EXPECT_EQ(ERR_FAILED, result);
358 371
359 // Load a good script once more. 372 // Load a good script once more.
360 result = resolver.SetPacScriptFromDisk("direct.js"); 373 result = resolver.SetPacScriptFromDisk("direct.js");
361 EXPECT_EQ(OK, result); 374 EXPECT_EQ(OK, result);
362 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 375 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
376 BoundNetLog());
363 EXPECT_EQ(OK, result); 377 EXPECT_EQ(OK, result);
364 378
365 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 379 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
366 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 380 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
367 } 381 }
368 382
369 // Test marshalling/un-marshalling of values between C++/V8. 383 // Test marshalling/un-marshalling of values between C++/V8.
370 TEST(ProxyResolverV8Test, V8Bindings) { 384 TEST(ProxyResolverV8Test, V8Bindings) {
371 ProxyResolverV8WithMockBindings resolver; 385 ProxyResolverV8WithMockBindings resolver;
372 int result = resolver.SetPacScriptFromDisk("bindings.js"); 386 int result = resolver.SetPacScriptFromDisk("bindings.js");
373 EXPECT_EQ(OK, result); 387 EXPECT_EQ(OK, result);
374 388
375 ProxyInfo proxy_info; 389 ProxyInfo proxy_info;
376 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 390 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
391 BoundNetLog());
377 392
378 EXPECT_EQ(OK, result); 393 EXPECT_EQ(OK, result);
379 EXPECT_TRUE(proxy_info.is_direct()); 394 EXPECT_TRUE(proxy_info.is_direct());
380 395
381 MockJSBindings* bindings = resolver.mock_js_bindings(); 396 MockJSBindings* bindings = resolver.mock_js_bindings();
382 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 397 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
383 398
384 // Alert was called 5 times. 399 // Alert was called 5 times.
385 ASSERT_EQ(5U, bindings->alerts.size()); 400 ASSERT_EQ(5U, bindings->alerts.size());
386 EXPECT_EQ("undefined", bindings->alerts[0]); 401 EXPECT_EQ("undefined", bindings->alerts[0]);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 438
424 int result = resolver.SetPacScriptFromDisk("binding_from_global.js"); 439 int result = resolver.SetPacScriptFromDisk("binding_from_global.js");
425 EXPECT_EQ(OK, result); 440 EXPECT_EQ(OK, result);
426 441
427 MockJSBindings* bindings = resolver.mock_js_bindings(); 442 MockJSBindings* bindings = resolver.mock_js_bindings();
428 443
429 // myIpAddress() got called during initialization of the script. 444 // myIpAddress() got called during initialization of the script.
430 EXPECT_EQ(1, bindings->my_ip_address_count); 445 EXPECT_EQ(1, bindings->my_ip_address_count);
431 446
432 ProxyInfo proxy_info; 447 ProxyInfo proxy_info;
433 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 448 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
449 BoundNetLog());
434 450
435 EXPECT_EQ(OK, result); 451 EXPECT_EQ(OK, result);
436 EXPECT_FALSE(proxy_info.is_direct()); 452 EXPECT_FALSE(proxy_info.is_direct());
437 EXPECT_EQ("127.0.0.1:80", proxy_info.proxy_server().ToURI()); 453 EXPECT_EQ("127.0.0.1:80", proxy_info.proxy_server().ToURI());
438 454
439 // Check that no other bindings were called. 455 // Check that no other bindings were called.
440 EXPECT_EQ(0U, bindings->errors.size()); 456 EXPECT_EQ(0U, bindings->errors.size());
441 ASSERT_EQ(0U, bindings->alerts.size()); 457 ASSERT_EQ(0U, bindings->alerts.size());
442 ASSERT_EQ(0U, bindings->dns_resolves.size()); 458 ASSERT_EQ(0U, bindings->dns_resolves.size());
443 EXPECT_EQ(0, bindings->my_ip_address_ex_count); 459 EXPECT_EQ(0, bindings->my_ip_address_ex_count);
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 // Test the return values from myIpAddress(), myIpAddressEx(), dnsResolve(), 537 // Test the return values from myIpAddress(), myIpAddressEx(), dnsResolve(),
522 // dnsResolveEx(), isResolvable(), isResolvableEx(), when the the binding 538 // dnsResolveEx(), isResolvable(), isResolvableEx(), when the the binding
523 // returns empty string (failure). This simulates the return values from 539 // returns empty string (failure). This simulates the return values from
524 // those functions when the underlying DNS resolution fails. 540 // those functions when the underlying DNS resolution fails.
525 TEST(ProxyResolverV8Test, DNSResolutionFailure) { 541 TEST(ProxyResolverV8Test, DNSResolutionFailure) {
526 ProxyResolverV8WithMockBindings resolver; 542 ProxyResolverV8WithMockBindings resolver;
527 int result = resolver.SetPacScriptFromDisk("dns_fail.js"); 543 int result = resolver.SetPacScriptFromDisk("dns_fail.js");
528 EXPECT_EQ(OK, result); 544 EXPECT_EQ(OK, result);
529 545
530 ProxyInfo proxy_info; 546 ProxyInfo proxy_info;
531 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL, NULL); 547 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL,
548 BoundNetLog());
532 549
533 EXPECT_EQ(OK, result); 550 EXPECT_EQ(OK, result);
534 EXPECT_FALSE(proxy_info.is_direct()); 551 EXPECT_FALSE(proxy_info.is_direct());
535 EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI()); 552 EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI());
536 } 553 }
537 554
538 } // namespace 555 } // namespace
539 } // namespace net 556 } // namespace net
OLDNEW
« no previous file with comments | « net/proxy/proxy_resolver_v8.cc ('k') | net/proxy/proxy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698