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 datetime | 5 import datetime |
6 import logging | 6 import logging |
7 import os | 7 import os |
8 | 8 |
9 from integration_tests import network_metrics | 9 from integration_tests import network_metrics |
10 from telemetry.page import page_test | 10 from telemetry.page import page_test |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 else: | 150 else: |
151 r = resp.response | 151 r = resp.response |
152 raise ChromeProxyMetricException, ( | 152 raise ChromeProxyMetricException, ( |
153 '%s: Via header (%s) is not valid (refer=%s, status=%d)' % ( | 153 '%s: Via header (%s) is not valid (refer=%s, status=%d)' % ( |
154 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) | 154 r.url, r.GetHeader('Via'), r.GetHeader('Referer'), r.status)) |
155 results.AddValue(scalar.ScalarValue( | 155 results.AddValue(scalar.ScalarValue( |
156 results.current_page, 'checked_via_header', 'count', via_count)) | 156 results.current_page, 'checked_via_header', 'count', via_count)) |
157 results.AddValue(scalar.ScalarValue( | 157 results.AddValue(scalar.ScalarValue( |
158 results.current_page, 'request_bypassed', 'count', bypass_count)) | 158 results.current_page, 'request_bypassed', 'count', bypass_count)) |
159 | 159 |
| 160 def AddResultsForClientVersion(self, tab, results): |
| 161 for resp in self.IterResponses(tab): |
| 162 r = resp.response |
| 163 if resp.response.status != 200: |
| 164 raise ChromeProxyMetricException, ('%s: Response is not 200: %d' % |
| 165 (r.url, r.status)) |
| 166 if not resp.IsValidByViaHeader(): |
| 167 raise ChromeProxyMetricException, ('%s: Response missing via header' % |
| 168 (r.url)) |
| 169 results.AddValue(scalar.ScalarValue( |
| 170 results.current_page, 'version_test', 'count', 1)) |
| 171 |
| 172 |
160 def IsProxyBypassed(self, tab): | 173 def IsProxyBypassed(self, tab): |
161 """ Returns True if all configured proxies are bypassed.""" | 174 """ Returns True if all configured proxies are bypassed.""" |
162 if not tab: | 175 if not tab: |
163 return False, [] | 176 return False, [] |
164 | 177 |
165 info = GetProxyInfoFromNetworkInternals(tab) | 178 info = GetProxyInfoFromNetworkInternals(tab) |
166 if not info['enabled']: | 179 if not info['enabled']: |
167 raise ChromeProxyMetricException, ( | 180 raise ChromeProxyMetricException, ( |
168 'Chrome proxy should be enabled. proxy info: %s' % info) | 181 'Chrome proxy should be enabled. proxy info: %s' % info) |
169 | 182 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 bad_proxies = [] | 291 bad_proxies = [] |
279 if 'badProxies' in info and info['badProxies']: | 292 if 'badProxies' in info and info['badProxies']: |
280 bad_proxies = [p['proxy'] for p in info['badProxies'] | 293 bad_proxies = [p['proxy'] for p in info['badProxies'] |
281 if 'proxy' in p and p['proxy']] | 294 if 'proxy' in p and p['proxy']] |
282 if bad_proxies != expected_bad_proxies: | 295 if bad_proxies != expected_bad_proxies: |
283 raise ChromeProxyMetricException, ( | 296 raise ChromeProxyMetricException, ( |
284 'Wrong bad proxies (%s). Expect: "%s"' % ( | 297 'Wrong bad proxies (%s). Expect: "%s"' % ( |
285 str(bad_proxies), str(expected_bad_proxies))) | 298 str(bad_proxies), str(expected_bad_proxies))) |
286 results.AddValue(scalar.ScalarValue( | 299 results.AddValue(scalar.ScalarValue( |
287 results.current_page, 'http_fallback', 'boolean', True)) | 300 results.current_page, 'http_fallback', 'boolean', True)) |
OLD | NEW |