| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 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 import base64 | 5 import base64 |
| 6 import logging | 6 import logging |
| 7 import urlparse | 7 import urlparse |
| 8 | 8 |
| 9 from integration_tests import chrome_proxy_metrics as metrics | 9 from integration_tests import chrome_proxy_metrics as metrics |
| 10 from metrics import loading | 10 from metrics import loading |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 def __init__(self): | 222 def __init__(self): |
| 223 super(ChromeProxyHTTPFallbackViaHeader, self).__init__( | 223 super(ChromeProxyHTTPFallbackViaHeader, self).__init__( |
| 224 restart_after_each_page=True) | 224 restart_after_each_page=True) |
| 225 | 225 |
| 226 def CustomizeBrowserOptions(self, options): | 226 def CustomizeBrowserOptions(self, options): |
| 227 super(ChromeProxyHTTPFallbackViaHeader, | 227 super(ChromeProxyHTTPFallbackViaHeader, |
| 228 self).CustomizeBrowserOptions(options) | 228 self).CustomizeBrowserOptions(options) |
| 229 options.AppendExtraBrowserArgs('--ignore-certificate-errors') | 229 options.AppendExtraBrowserArgs('--ignore-certificate-errors') |
| 230 options.AppendExtraBrowserArgs( | 230 options.AppendExtraBrowserArgs( |
| 231 '--spdy-proxy-auth-origin=http://%s' % _TEST_SERVER) | 231 '--spdy-proxy-auth-origin=http://%s' % _TEST_SERVER) |
| 232 options.AppendExtraBrowserArgs( | |
| 233 '--spdy-proxy-auth-value=%s' % _FAKE_PROXY_AUTH_VALUE) | |
| 234 | 232 |
| 235 def AddResults(self, tab, results): | 233 def AddResults(self, tab, results): |
| 236 proxies = [ | 234 self._metrics.AddResultsForHTTPFallback(tab, results) |
| 237 _TEST_SERVER + ":80", | |
| 238 self._metrics.effective_proxies['fallback'], | |
| 239 self._metrics.effective_proxies['direct']] | |
| 240 bad_proxies = [_TEST_SERVER + ":80", metrics.PROXY_SETTING_HTTP] | |
| 241 self._metrics.AddResultsForHTTPFallback(tab, results, proxies, bad_proxies) | |
| 242 | 235 |
| 243 | 236 |
| 244 class ChromeProxyClientVersion(ChromeProxyValidation): | 237 class ChromeProxyClientVersion(ChromeProxyValidation): |
| 245 """Correctness measurement for version directives in Chrome-Proxy header. | 238 """Correctness measurement for version directives in Chrome-Proxy header. |
| 246 | 239 |
| 247 The test verifies that the version information provided in the Chrome-Proxy | 240 The test verifies that the version information provided in the Chrome-Proxy |
| 248 request header overrides any version, if specified, that is provided in the | 241 request header overrides any version, if specified, that is provided in the |
| 249 user agent string. | 242 user agent string. |
| 250 """ | 243 """ |
| 251 | 244 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 | 285 |
| 293 def CustomizeBrowserOptions(self, options): | 286 def CustomizeBrowserOptions(self, options): |
| 294 super(ChromeProxyHTTPToDirectFallback, | 287 super(ChromeProxyHTTPToDirectFallback, |
| 295 self).CustomizeBrowserOptions(options) | 288 self).CustomizeBrowserOptions(options) |
| 296 # Set the primary proxy to something that will fail to be resolved so that | 289 # Set the primary proxy to something that will fail to be resolved so that |
| 297 # this test will run using the HTTP fallback proxy. | 290 # this test will run using the HTTP fallback proxy. |
| 298 options.AppendExtraBrowserArgs( | 291 options.AppendExtraBrowserArgs( |
| 299 '--spdy-proxy-auth-origin=http://nonexistent.googlezip.net') | 292 '--spdy-proxy-auth-origin=http://nonexistent.googlezip.net') |
| 300 | 293 |
| 301 def WillNavigateToPage(self, page, tab): | 294 def WillNavigateToPage(self, page, tab): |
| 295 super(ChromeProxyHTTPToDirectFallback, self).WillNavigateToPage(page, tab) |
| 302 # Attempt to load a page through the nonexistent primary proxy in order to | 296 # Attempt to load a page through the nonexistent primary proxy in order to |
| 303 # cause a proxy fallback, and have this test run starting from the HTTP | 297 # cause a proxy fallback, and have this test run starting from the HTTP |
| 304 # fallback proxy. | 298 # fallback proxy. |
| 305 tab.Navigate(_TEST_SERVER_DEFAULT_URL) | 299 tab.Navigate(_TEST_SERVER_DEFAULT_URL) |
| 306 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) | 300 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) |
| 307 proxies = [ | |
| 308 'nonexistent.googlezip.net:80', | |
| 309 self._metrics.effective_proxies['fallback'], | |
| 310 self._metrics.effective_proxies['direct']] | |
| 311 # TODO(sclittle): Remove this dependency on net-internals#proxy once an | |
| 312 # alternative method of verifying that Chrome is on the fallback proxy | |
| 313 # exists. | |
| 314 self._metrics.VerifyProxyInfo(tab, proxies, proxies[:1]) | |
| 315 super(ChromeProxyHTTPToDirectFallback, self).WillNavigateToPage(page, tab) | |
| 316 | 301 |
| 317 def AddResults(self, tab, results): | 302 def AddResults(self, tab, results): |
| 318 self._metrics.AddResultsForHTTPToDirectFallback(tab, results) | 303 self._metrics.AddResultsForHTTPToDirectFallback(tab, results) |
| 319 | 304 |
| 320 | 305 |
| 321 class ChromeProxyExplicitBypass(ChromeProxyValidation): | 306 class ChromeProxyReenableAfterBypass(ChromeProxyValidation): |
| 322 """Correctness measurement for explicit proxy bypasses. | 307 """Correctness measurement for re-enabling proxies after bypasses. |
| 323 | 308 |
| 324 In this test, the configured proxy is the chromeproxy-test server which | 309 This test loads a page that causes all data reduction proxies to be bypassed |
| 325 will send back a response without the expected Via header. Chrome is | 310 for 1 to 5 minutes, then waits 5 minutes and verifies that the proxy is no |
| 326 expected to use the fallback proxy and add the configured proxy to the | 311 longer bypassed. |
| 327 bad proxy list. | |
| 328 """ | 312 """ |
| 329 | 313 |
| 330 def __init__(self): | 314 def __init__(self): |
| 331 super(ChromeProxyExplicitBypass, self).__init__( | 315 super(ChromeProxyReenableAfterBypass, self).__init__( |
| 332 restart_after_each_page=True) | 316 restart_after_each_page=True) |
| 333 | 317 |
| 334 def CustomizeBrowserOptions(self, options): | |
| 335 super(ChromeProxyExplicitBypass, | |
| 336 self).CustomizeBrowserOptions(options) | |
| 337 options.AppendExtraBrowserArgs('--ignore-certificate-errors') | |
| 338 options.AppendExtraBrowserArgs( | |
| 339 '--spdy-proxy-auth-origin=http://%s' % _TEST_SERVER) | |
| 340 options.AppendExtraBrowserArgs( | |
| 341 '--spdy-proxy-auth-value=%s' % _FAKE_PROXY_AUTH_VALUE) | |
| 342 | |
| 343 def AddResults(self, tab, results): | 318 def AddResults(self, tab, results): |
| 344 bad_proxies = [{ | 319 self._metrics.AddResultsForReenableAfterBypass( |
| 345 'proxy': _TEST_SERVER + ':80', | 320 tab, results, self._page.bypass_seconds_min, |
| 346 'retry_seconds_low': self._page.bypass_seconds_low, | 321 self._page.bypass_seconds_max) |
| 347 'retry_seconds_high': self._page.bypass_seconds_high | |
| 348 }] | |
| 349 if self._page.num_bypassed_proxies == 2: | |
| 350 bad_proxies.append({ | |
| 351 'proxy': self._metrics.effective_proxies['fallback'], | |
| 352 'retry_seconds_low': self._page.bypass_seconds_low, | |
| 353 'retry_seconds_high': self._page.bypass_seconds_high | |
| 354 }) | |
| 355 else: | |
| 356 # Even if the test page only causes the primary proxy to be bypassed, | |
| 357 # Chrome will attempt to fetch the favicon for the test server through | |
| 358 # the data reduction proxy, which will cause a "block=0" bypass. | |
| 359 bad_proxies.append({'proxy': self._metrics.effective_proxies['fallback']}) | |
| 360 | |
| 361 self._metrics.AddResultsForExplicitBypass(tab, results, bad_proxies) | |
| 362 | 322 |
| 363 | 323 |
| 364 class ChromeProxySmoke(ChromeProxyValidation): | 324 class ChromeProxySmoke(ChromeProxyValidation): |
| 365 """Smoke measurement for basic chrome proxy correctness.""" | 325 """Smoke measurement for basic chrome proxy correctness.""" |
| 366 | 326 |
| 367 def __init__(self): | 327 def __init__(self): |
| 368 super(ChromeProxySmoke, self).__init__() | 328 super(ChromeProxySmoke, self).__init__() |
| 369 | 329 |
| 370 def WillNavigateToPage(self, page, tab): | 330 def WillNavigateToPage(self, page, tab): |
| 371 super(ChromeProxySmoke, self).WillNavigateToPage(page, tab) | 331 super(ChromeProxySmoke, self).WillNavigateToPage(page, tab) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 390 ], | 350 ], |
| 391 'bypass': [self._metrics.AddResultsForBypass], | 351 'bypass': [self._metrics.AddResultsForBypass], |
| 392 'safebrowsing': [self._metrics.AddResultsForSafebrowsing], | 352 'safebrowsing': [self._metrics.AddResultsForSafebrowsing], |
| 393 } | 353 } |
| 394 if not self._page.name in page_to_metrics: | 354 if not self._page.name in page_to_metrics: |
| 395 raise page_test.MeasurementFailure( | 355 raise page_test.MeasurementFailure( |
| 396 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % ( | 356 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % ( |
| 397 self._page.name, page_to_metrics.keys())) | 357 self._page.name, page_to_metrics.keys())) |
| 398 for add_result in page_to_metrics[self._page.name]: | 358 for add_result in page_to_metrics[self._page.name]: |
| 399 add_result(tab, results) | 359 add_result(tab, results) |
| OLD | NEW |