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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 info = GetProxyInfoFromNetworkInternals(tab) | 228 info = GetProxyInfoFromNetworkInternals(tab) |
229 if not info['enabled']: | 229 if not info['enabled']: |
230 raise ChromeProxyMetricException, ( | 230 raise ChromeProxyMetricException, ( |
231 'Chrome proxy should be enabled. proxy info: %s' % info) | 231 'Chrome proxy should be enabled. proxy info: %s' % info) |
232 _, expected_bad_proxies = self.IsProxyBypassed(tab) | 232 _, expected_bad_proxies = self.IsProxyBypassed(tab) |
233 self.VerifyBadProxies(info['badProxies'], expected_bad_proxies) | 233 self.VerifyBadProxies(info['badProxies'], expected_bad_proxies) |
234 | 234 |
235 results.AddValue(scalar.ScalarValue( | 235 results.AddValue(scalar.ScalarValue( |
236 results.current_page, 'bypass', 'count', bypass_count)) | 236 results.current_page, 'bypass', 'count', bypass_count)) |
237 | 237 |
| 238 def AddResultsForBlockOnce(self, tab, results): |
| 239 eligible_response_count = 0 |
| 240 bypass_count = 0 |
| 241 for resp in self.IterResponses(tab): |
| 242 if resp.ShouldHaveChromeProxyViaHeader(): |
| 243 eligible_response_count += 1 |
| 244 if not resp.HasChromeProxyViaHeader(): |
| 245 bypass_count += 1 |
| 246 |
| 247 if tab: |
| 248 info = GetProxyInfoFromNetworkInternals(tab) |
| 249 if not info['enabled']: |
| 250 raise ChromeProxyMetricException, ( |
| 251 'Chrome proxy should be enabled. proxy info: %s' % info) |
| 252 self.VerifyBadProxies(info['badProxies'], []) |
| 253 |
| 254 if eligible_response_count <= 1: |
| 255 raise ChromeProxyMetricException, ( |
| 256 'There should be more than one DRP eligible response ' |
| 257 '(eligible_response_count=%d, bypass_count=%d)\n' % ( |
| 258 eligible_response_count, bypass_count)) |
| 259 elif bypass_count != 1: |
| 260 raise ChromeProxyMetricException, ( |
| 261 'Exactly one response should be bypassed. ' |
| 262 '(eligible_response_count=%d, bypass_count=%d)\n' % ( |
| 263 eligible_response_count, bypass_count)) |
| 264 else: |
| 265 results.AddValue(scalar.ScalarValue( |
| 266 results.current_page, 'eligible_responses', 'count', |
| 267 eligible_response_count)) |
| 268 results.AddValue(scalar.ScalarValue( |
| 269 results.current_page, 'bypass', 'count', bypass_count)) |
| 270 |
238 def AddResultsForSafebrowsing(self, tab, results): | 271 def AddResultsForSafebrowsing(self, tab, results): |
239 count = 0 | 272 count = 0 |
240 safebrowsing_count = 0 | 273 safebrowsing_count = 0 |
241 for resp in self.IterResponses(tab): | 274 for resp in self.IterResponses(tab): |
242 count += 1 | 275 count += 1 |
243 if resp.IsSafebrowsingResponse(): | 276 if resp.IsSafebrowsingResponse(): |
244 safebrowsing_count += 1 | 277 safebrowsing_count += 1 |
245 else: | 278 else: |
246 r = resp.response | 279 r = resp.response |
247 raise ChromeProxyMetricException, ( | 280 raise ChromeProxyMetricException, ( |
(...skipping 30 matching lines...) Expand all Loading... |
278 bad_proxies = [] | 311 bad_proxies = [] |
279 if 'badProxies' in info and info['badProxies']: | 312 if 'badProxies' in info and info['badProxies']: |
280 bad_proxies = [p['proxy'] for p in info['badProxies'] | 313 bad_proxies = [p['proxy'] for p in info['badProxies'] |
281 if 'proxy' in p and p['proxy']] | 314 if 'proxy' in p and p['proxy']] |
282 if bad_proxies != expected_bad_proxies: | 315 if bad_proxies != expected_bad_proxies: |
283 raise ChromeProxyMetricException, ( | 316 raise ChromeProxyMetricException, ( |
284 'Wrong bad proxies (%s). Expect: "%s"' % ( | 317 'Wrong bad proxies (%s). Expect: "%s"' % ( |
285 str(bad_proxies), str(expected_bad_proxies))) | 318 str(bad_proxies), str(expected_bad_proxies))) |
286 results.AddValue(scalar.ScalarValue( | 319 results.AddValue(scalar.ScalarValue( |
287 results.current_page, 'http_fallback', 'boolean', True)) | 320 results.current_page, 'http_fallback', 'boolean', True)) |
OLD | NEW |