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

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

Issue 160510: Better match IE's proxy settings.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix merge conflict 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/net_errors.h" 9 #include "net/base/net_errors.h"
10 #include "net/proxy/proxy_info.h" 10 #include "net/proxy/proxy_info.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 // disk. 61 // disk.
62 class ProxyResolverV8WithMockBindings : public net::ProxyResolverV8 { 62 class ProxyResolverV8WithMockBindings : public net::ProxyResolverV8 {
63 public: 63 public:
64 ProxyResolverV8WithMockBindings() : ProxyResolverV8(new MockJSBindings()) {} 64 ProxyResolverV8WithMockBindings() : ProxyResolverV8(new MockJSBindings()) {}
65 65
66 MockJSBindings* mock_js_bindings() const { 66 MockJSBindings* mock_js_bindings() const {
67 return reinterpret_cast<MockJSBindings*>(js_bindings()); 67 return reinterpret_cast<MockJSBindings*>(js_bindings());
68 } 68 }
69 69
70 // Initialize with the PAC script data at |filename|. 70 // Initialize with the PAC script data at |filename|.
71 void SetPacScriptFromDisk(const char* filename) { 71 int SetPacScriptFromDisk(const char* filename) {
72 FilePath path; 72 FilePath path;
73 PathService::Get(base::DIR_SOURCE_ROOT, &path); 73 PathService::Get(base::DIR_SOURCE_ROOT, &path);
74 path = path.AppendASCII("net"); 74 path = path.AppendASCII("net");
75 path = path.AppendASCII("data"); 75 path = path.AppendASCII("data");
76 path = path.AppendASCII("proxy_resolver_v8_unittest"); 76 path = path.AppendASCII("proxy_resolver_v8_unittest");
77 path = path.AppendASCII(filename); 77 path = path.AppendASCII(filename);
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 if (!ok) {
85 ASSERT_TRUE(ok); 85 LOG(ERROR) << "Failed to read file: " << path.value();
86 return net::ERR_UNEXPECTED;
87 }
86 88
87 // Load the PAC script into the ProxyResolver. 89 // Load the PAC script into the ProxyResolver.
88 SetPacScriptByData(file_contents); 90 return SetPacScriptByData(file_contents, NULL);
89 } 91 }
90 }; 92 };
91 93
92 // Doesn't really matter what these values are for many of the tests. 94 // Doesn't really matter what these values are for many of the tests.
93 const GURL kQueryUrl("http://www.google.com"); 95 const GURL kQueryUrl("http://www.google.com");
94 const GURL kPacUrl; 96 const GURL kPacUrl;
95 97
96 } 98 }
97 99
98 TEST(ProxyResolverV8Test, Direct) { 100 TEST(ProxyResolverV8Test, Direct) {
99 ProxyResolverV8WithMockBindings resolver; 101 ProxyResolverV8WithMockBindings resolver;
100 resolver.SetPacScriptFromDisk("direct.js"); 102 int result = resolver.SetPacScriptFromDisk("direct.js");
103 EXPECT_EQ(net::OK, result);
101 104
102 net::ProxyInfo proxy_info; 105 net::ProxyInfo proxy_info;
103 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 106 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
104 107
105 EXPECT_EQ(net::OK, result); 108 EXPECT_EQ(net::OK, result);
106 EXPECT_TRUE(proxy_info.is_direct()); 109 EXPECT_TRUE(proxy_info.is_direct());
107 110
108 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 111 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
109 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 112 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
110 } 113 }
111 114
112 TEST(ProxyResolverV8Test, ReturnEmptyString) { 115 TEST(ProxyResolverV8Test, ReturnEmptyString) {
113 ProxyResolverV8WithMockBindings resolver; 116 ProxyResolverV8WithMockBindings resolver;
114 resolver.SetPacScriptFromDisk("return_empty_string.js"); 117 int result = resolver.SetPacScriptFromDisk("return_empty_string.js");
118 EXPECT_EQ(net::OK, result);
115 119
116 net::ProxyInfo proxy_info; 120 net::ProxyInfo proxy_info;
117 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 121 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
118 122
119 EXPECT_EQ(net::OK, result); 123 EXPECT_EQ(net::OK, result);
120 EXPECT_TRUE(proxy_info.is_direct()); 124 EXPECT_TRUE(proxy_info.is_direct());
121 125
122 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 126 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
123 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 127 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
124 } 128 }
125 129
126 TEST(ProxyResolverV8Test, Basic) { 130 TEST(ProxyResolverV8Test, Basic) {
127 ProxyResolverV8WithMockBindings resolver; 131 ProxyResolverV8WithMockBindings resolver;
128 resolver.SetPacScriptFromDisk("passthrough.js"); 132 int result = resolver.SetPacScriptFromDisk("passthrough.js");
133 EXPECT_EQ(net::OK, result);
129 134
130 // The "FindProxyForURL" of this PAC script simply concatenates all of the 135 // 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 136 // arguments into a pseudo-host. The purpose of this test is to verify that
132 // the correct arguments are being passed to FindProxyForURL(). 137 // the correct arguments are being passed to FindProxyForURL().
133 { 138 {
134 net::ProxyInfo proxy_info; 139 net::ProxyInfo proxy_info;
135 int result = resolver.GetProxyForURL(GURL("http://query.com/path"), 140 result = resolver.GetProxyForURL(GURL("http://query.com/path"),
136 &proxy_info, NULL, NULL); 141 &proxy_info, NULL, NULL);
137 EXPECT_EQ(net::OK, result); 142 EXPECT_EQ(net::OK, result);
138 EXPECT_EQ("http.query.com.path.query.com:80", 143 EXPECT_EQ("http.query.com.path.query.com:80",
139 proxy_info.proxy_server().ToURI()); 144 proxy_info.proxy_server().ToURI());
140 } 145 }
141 { 146 {
142 net::ProxyInfo proxy_info; 147 net::ProxyInfo proxy_info;
143 int result = resolver.GetProxyForURL(GURL("ftp://query.com:90/path"), 148 int result = resolver.GetProxyForURL(GURL("ftp://query.com:90/path"),
144 &proxy_info, NULL, NULL); 149 &proxy_info, NULL, NULL);
145 EXPECT_EQ(net::OK, result); 150 EXPECT_EQ(net::OK, result);
(...skipping 15 matching lines...) Expand all
161 "return_undefined.js", 166 "return_undefined.js",
162 "return_integer.js", 167 "return_integer.js",
163 "return_function.js", 168 "return_function.js",
164 "return_object.js", 169 "return_object.js",
165 // TODO(eroman): Should 'null' be considered equivalent to "DIRECT" ? 170 // TODO(eroman): Should 'null' be considered equivalent to "DIRECT" ?
166 "return_null.js" 171 "return_null.js"
167 }; 172 };
168 173
169 for (size_t i = 0; i < arraysize(filenames); ++i) { 174 for (size_t i = 0; i < arraysize(filenames); ++i) {
170 ProxyResolverV8WithMockBindings resolver; 175 ProxyResolverV8WithMockBindings resolver;
171 resolver.SetPacScriptFromDisk(filenames[i]); 176 int result = resolver.SetPacScriptFromDisk(filenames[i]);
177 EXPECT_EQ(net::OK, result);
172 178
173 net::ProxyInfo proxy_info; 179 net::ProxyInfo proxy_info;
174 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 180 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
175 181
176 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result); 182 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result);
177 183
178 MockJSBindings* bindings = resolver.mock_js_bindings(); 184 MockJSBindings* bindings = resolver.mock_js_bindings();
179 EXPECT_EQ(0U, bindings->alerts.size()); 185 EXPECT_EQ(0U, bindings->alerts.size());
180 ASSERT_EQ(1U, bindings->errors.size()); 186 ASSERT_EQ(1U, bindings->errors.size());
181 EXPECT_EQ("FindProxyForURL() did not return a string.", 187 EXPECT_EQ("FindProxyForURL() did not return a string.",
182 bindings->errors[0]); 188 bindings->errors[0]);
183 EXPECT_EQ(-1, bindings->errors_line_number[0]); 189 EXPECT_EQ(-1, bindings->errors_line_number[0]);
184 } 190 }
185 } 191 }
186 192
187 // Try using a PAC script which defines no "FindProxyForURL" function. 193 // Try using a PAC script which defines no "FindProxyForURL" function.
188 TEST(ProxyResolverV8Test, NoEntryPoint) { 194 TEST(ProxyResolverV8Test, NoEntryPoint) {
189 ProxyResolverV8WithMockBindings resolver; 195 ProxyResolverV8WithMockBindings resolver;
190 resolver.SetPacScriptFromDisk("no_entrypoint.js"); 196 int result = resolver.SetPacScriptFromDisk("no_entrypoint.js");
197 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result);
191 198
192 net::ProxyInfo proxy_info; 199 net::ProxyInfo proxy_info;
193 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 200 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
194 201
195 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result); 202 EXPECT_EQ(net::ERR_FAILED, result);
196
197 MockJSBindings* bindings = resolver.mock_js_bindings();
198 EXPECT_EQ(0U, bindings->alerts.size());
199 ASSERT_EQ(1U, bindings->errors.size());
200 EXPECT_EQ("FindProxyForURL() is undefined.", bindings->errors[0]);
201 EXPECT_EQ(-1, bindings->errors_line_number[0]);
202 } 203 }
203 204
204 // Try loading a malformed PAC script. 205 // Try loading a malformed PAC script.
205 TEST(ProxyResolverV8Test, ParseError) { 206 TEST(ProxyResolverV8Test, ParseError) {
206 ProxyResolverV8WithMockBindings resolver; 207 ProxyResolverV8WithMockBindings resolver;
207 resolver.SetPacScriptFromDisk("missing_close_brace.js"); 208 int result = resolver.SetPacScriptFromDisk("missing_close_brace.js");
209 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result);
208 210
209 net::ProxyInfo proxy_info; 211 net::ProxyInfo proxy_info;
210 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 212 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
211 213
212 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result); 214 EXPECT_EQ(net::ERR_FAILED, result);
213 215
214 MockJSBindings* bindings = resolver.mock_js_bindings(); 216 MockJSBindings* bindings = resolver.mock_js_bindings();
215 EXPECT_EQ(0U, bindings->alerts.size()); 217 EXPECT_EQ(0U, bindings->alerts.size());
216 218
217 // We get two errors -- one during compilation, and then later when 219 // We get one error during compilation.
218 // trying to run FindProxyForURL(). 220 ASSERT_EQ(1U, bindings->errors.size());
219 ASSERT_EQ(2U, bindings->errors.size());
220 221
221 EXPECT_EQ("Uncaught SyntaxError: Unexpected end of input", 222 EXPECT_EQ("Uncaught SyntaxError: Unexpected end of input",
222 bindings->errors[0]); 223 bindings->errors[0]);
223 EXPECT_EQ(-1, bindings->errors_line_number[0]); 224 EXPECT_EQ(-1, bindings->errors_line_number[0]);
224
225 EXPECT_EQ("FindProxyForURL() is undefined.", bindings->errors[1]);
226 EXPECT_EQ(-1, bindings->errors_line_number[1]);
227 } 225 }
228 226
229 // Run a PAC script several times, which has side-effects. 227 // Run a PAC script several times, which has side-effects.
230 TEST(ProxyResolverV8Test, SideEffects) { 228 TEST(ProxyResolverV8Test, SideEffects) {
231 ProxyResolverV8WithMockBindings resolver; 229 ProxyResolverV8WithMockBindings resolver;
232 resolver.SetPacScriptFromDisk("side_effects.js"); 230 int result = resolver.SetPacScriptFromDisk("side_effects.js");
233 231
234 // The PAC script increments a counter each time we invoke it. 232 // The PAC script increments a counter each time we invoke it.
235 for (int i = 0; i < 3; ++i) { 233 for (int i = 0; i < 3; ++i) {
236 net::ProxyInfo proxy_info; 234 net::ProxyInfo proxy_info;
237 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 235 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
238 EXPECT_EQ(net::OK, result); 236 EXPECT_EQ(net::OK, result);
239 EXPECT_EQ(StringPrintf("sideffect_%d:80", i), 237 EXPECT_EQ(StringPrintf("sideffect_%d:80", i),
240 proxy_info.proxy_server().ToURI()); 238 proxy_info.proxy_server().ToURI());
241 } 239 }
242 240
243 // Reload the script -- the javascript environment should be reset, hence 241 // Reload the script -- the javascript environment should be reset, hence
244 // the counter starts over. 242 // the counter starts over.
245 resolver.SetPacScriptFromDisk("side_effects.js"); 243 result = resolver.SetPacScriptFromDisk("side_effects.js");
244 EXPECT_EQ(net::OK, result);
246 245
247 for (int i = 0; i < 3; ++i) { 246 for (int i = 0; i < 3; ++i) {
248 net::ProxyInfo proxy_info; 247 net::ProxyInfo proxy_info;
249 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 248 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
250 EXPECT_EQ(net::OK, result); 249 EXPECT_EQ(net::OK, result);
251 EXPECT_EQ(StringPrintf("sideffect_%d:80", i), 250 EXPECT_EQ(StringPrintf("sideffect_%d:80", i),
252 proxy_info.proxy_server().ToURI()); 251 proxy_info.proxy_server().ToURI());
253 } 252 }
254 } 253 }
255 254
256 // Execute a PAC script which throws an exception in FindProxyForURL. 255 // Execute a PAC script which throws an exception in FindProxyForURL.
257 TEST(ProxyResolverV8Test, UnhandledException) { 256 TEST(ProxyResolverV8Test, UnhandledException) {
258 ProxyResolverV8WithMockBindings resolver; 257 ProxyResolverV8WithMockBindings resolver;
259 resolver.SetPacScriptFromDisk("unhandled_exception.js"); 258 int result = resolver.SetPacScriptFromDisk("unhandled_exception.js");
259 EXPECT_EQ(net::OK, result);
260 260
261 net::ProxyInfo proxy_info; 261 net::ProxyInfo proxy_info;
262 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 262 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 int result = resolver.SetPacScriptFromDisk("return_unicode.js");
279 EXPECT_EQ(net::OK, result);
279 280
280 net::ProxyInfo proxy_info; 281 net::ProxyInfo proxy_info;
281 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 282 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
282 283
283 // The result from this resolve was unparseable, because it 284 // The result from this resolve was unparseable, because it
284 // wasn't ascii. 285 // wasn't ascii.
285 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result); 286 EXPECT_EQ(net::ERR_PAC_SCRIPT_FAILED, result);
286 } 287 }
287 288
288 // Test the PAC library functions that we expose in the JS environmnet. 289 // Test the PAC library functions that we expose in the JS environmnet.
289 TEST(ProxyResolverV8Test, JavascriptLibrary) { 290 TEST(ProxyResolverV8Test, JavascriptLibrary) {
290 ProxyResolverV8WithMockBindings resolver; 291 ProxyResolverV8WithMockBindings resolver;
291 resolver.SetPacScriptFromDisk("pac_library_unittest.js"); 292 int result = resolver.SetPacScriptFromDisk("pac_library_unittest.js");
293 EXPECT_EQ(net::OK, result);
292 294
293 net::ProxyInfo proxy_info; 295 net::ProxyInfo proxy_info;
294 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 296 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
295 297
296 // If the javascript side of this unit-test fails, it will throw a javascript 298 // If the javascript side of this unit-test fails, it will throw a javascript
297 // exception. Otherwise it will return "PROXY success:80". 299 // exception. Otherwise it will return "PROXY success:80".
298 EXPECT_EQ(net::OK, result); 300 EXPECT_EQ(net::OK, result);
299 EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI()); 301 EXPECT_EQ("success:80", proxy_info.proxy_server().ToURI());
300 302
301 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 303 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
302 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 304 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
303 } 305 }
304 306
305 // Try resolving when SetPacScriptByData() has not been called. 307 // Try resolving when SetPacScriptByData() has not been called.
306 TEST(ProxyResolverV8Test, NoSetPacScript) { 308 TEST(ProxyResolverV8Test, NoSetPacScript) {
307 ProxyResolverV8WithMockBindings resolver; 309 ProxyResolverV8WithMockBindings resolver;
308 310
309 net::ProxyInfo proxy_info; 311 net::ProxyInfo proxy_info;
310 312
311 // Resolve should fail, as we are not yet initialized with a script. 313 // Resolve should fail, as we are not yet initialized with a script.
312 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 314 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
313 EXPECT_EQ(net::ERR_FAILED, result); 315 EXPECT_EQ(net::ERR_FAILED, result);
314 316
315 // Initialize it. 317 // Initialize it.
316 resolver.SetPacScriptFromDisk("direct.js"); 318 result = resolver.SetPacScriptFromDisk("direct.js");
319 EXPECT_EQ(net::OK, result);
317 320
318 // Resolve should now succeed. 321 // Resolve should now succeed.
319 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 322 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
320 EXPECT_EQ(net::OK, result); 323 EXPECT_EQ(net::OK, result);
321 324
322 // Clear it, by initializing with an empty string. 325 // Clear it, by initializing with an empty string.
323 resolver.SetPacScriptByData(std::string()); 326 resolver.SetPacScriptByData(std::string(), NULL);
324 327
325 // Resolve should fail again now. 328 // Resolve should fail again now.
326 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 329 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
327 EXPECT_EQ(net::ERR_FAILED, result); 330 EXPECT_EQ(net::ERR_FAILED, result);
328 331
329 // Load a good script once more. 332 // Load a good script once more.
330 resolver.SetPacScriptFromDisk("direct.js"); 333 result = resolver.SetPacScriptFromDisk("direct.js");
334 EXPECT_EQ(net::OK, result);
331 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 335 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
332 EXPECT_EQ(net::OK, result); 336 EXPECT_EQ(net::OK, result);
333 337
334 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size()); 338 EXPECT_EQ(0U, resolver.mock_js_bindings()->alerts.size());
335 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 339 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
336 } 340 }
337 341
338 // Test marshalling/un-marshalling of values between C++/V8. 342 // Test marshalling/un-marshalling of values between C++/V8.
339 TEST(ProxyResolverV8Test, V8Bindings) { 343 TEST(ProxyResolverV8Test, V8Bindings) {
340 ProxyResolverV8WithMockBindings resolver; 344 ProxyResolverV8WithMockBindings resolver;
341 resolver.SetPacScriptFromDisk("bindings.js"); 345 int result = resolver.SetPacScriptFromDisk("bindings.js");
346 EXPECT_EQ(net::OK, result);
342 347
343 net::ProxyInfo proxy_info; 348 net::ProxyInfo proxy_info;
344 int result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL); 349 result = resolver.GetProxyForURL(kQueryUrl, &proxy_info, NULL, NULL);
345 350
346 EXPECT_EQ(net::OK, result); 351 EXPECT_EQ(net::OK, result);
347 EXPECT_TRUE(proxy_info.is_direct()); 352 EXPECT_TRUE(proxy_info.is_direct());
348 353
349 MockJSBindings* bindings = resolver.mock_js_bindings(); 354 MockJSBindings* bindings = resolver.mock_js_bindings();
350 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size()); 355 EXPECT_EQ(0U, resolver.mock_js_bindings()->errors.size());
351 356
352 // Alert was called 5 times. 357 // Alert was called 5 times.
353 ASSERT_EQ(5U, bindings->alerts.size()); 358 ASSERT_EQ(5U, bindings->alerts.size());
354 EXPECT_EQ("undefined", bindings->alerts[0]); 359 EXPECT_EQ("undefined", bindings->alerts[0]);
(...skipping 14 matching lines...) Expand all
369 // TODO(eroman): This isn't quite right... should probably stringize 374 // TODO(eroman): This isn't quite right... should probably stringize
370 // to something like "['3']". 375 // to something like "['3']".
371 EXPECT_EQ("3", bindings->dns_resolves[6]); 376 EXPECT_EQ("3", bindings->dns_resolves[6]);
372 377
373 EXPECT_EQ("arg1", bindings->dns_resolves[7]); 378 EXPECT_EQ("arg1", bindings->dns_resolves[7]);
374 379
375 // MyIpAddress was called two times. 380 // MyIpAddress was called two times.
376 EXPECT_EQ(2, bindings->my_ip_address_count); 381 EXPECT_EQ(2, bindings->my_ip_address_count);
377 } 382 }
378 383
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