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 logging | 5 import logging |
6 import time | 6 import time |
7 | 7 |
8 from integration_tests import network_metrics | 8 from integration_tests import network_metrics |
9 from telemetry.page import page_test | 9 from telemetry.page import page_test |
10 from telemetry.value import scalar | 10 from telemetry.value import scalar |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
263 'Exactly one response should be bypassed. ' | 263 'Exactly one response should be bypassed. ' |
264 '(eligible_response_count=%d, bypass_count=%d)\n' % ( | 264 '(eligible_response_count=%d, bypass_count=%d)\n' % ( |
265 eligible_response_count, bypass_count)) | 265 eligible_response_count, bypass_count)) |
266 else: | 266 else: |
267 results.AddValue(scalar.ScalarValue( | 267 results.AddValue(scalar.ScalarValue( |
268 results.current_page, 'eligible_responses', 'count', | 268 results.current_page, 'eligible_responses', 'count', |
269 eligible_response_count)) | 269 eligible_response_count)) |
270 results.AddValue(scalar.ScalarValue( | 270 results.AddValue(scalar.ScalarValue( |
271 results.current_page, 'bypass', 'count', bypass_count)) | 271 results.current_page, 'bypass', 'count', bypass_count)) |
272 | 272 |
273 def AddResultsForSafebrowsing(self, tab, results): | 273 def AddResultsForSafebrowsingMobile(self, tab, results): |
274 count = 0 | 274 response_count = 0 |
275 safebrowsing_count = 0 | |
276 | |
277 for resp in self.IterResponses(tab): | 275 for resp in self.IterResponses(tab): |
278 count += 1 | 276 response_count += 1 |
279 if resp.IsSafebrowsingResponse(): | 277 if not resp.IsSafebrowsingResponse(): |
280 safebrowsing_count += 1 | |
281 else: | |
282 r = resp.response | 278 r = resp.response |
283 raise ChromeProxyMetricException, ( | 279 raise ChromeProxyMetricException, ( |
284 '%s: Not a valid safe browsing response.\n' | 280 '%s: Not a valid safe browsing response.\n' |
285 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( | 281 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( |
286 r.url, r.status, r.status_text, r.headers)) | 282 r.url, r.status, r.status_text, r.headers)) |
287 if count == safebrowsing_count: | 283 |
288 results.AddValue(scalar.ScalarValue( | 284 if response_count == 0: |
289 results.current_page, 'safebrowsing', 'boolean', True)) | |
290 else: | |
291 raise ChromeProxyMetricException, ( | 285 raise ChromeProxyMetricException, ( |
292 'Safebrowsing failed (count=%d, safebrowsing_count=%d)\n' % ( | 286 'Safebrowsing failed: No valid responses received)\n') |
sclittle
2015/01/23 20:06:46
nit: remove ')\n' from the end
Not at Google. Contact bengr
2015/01/23 22:56:00
Done.
| |
293 count, safebrowsing_count)) | 287 |
288 results.AddValue(scalar.ScalarValue( | |
289 results.current_page, 'safebrowsing', 'responses', response_count)) | |
290 | |
291 | |
292 def AddResultsForSafebrowsingDesktop(self, tab, results): | |
293 response_count = 0 | |
294 for resp in self.IterResponses(tab): | |
295 # For desktop, data reduction proxy should return the real response for | |
296 # sites with malware. | |
297 response_count += 1 | |
298 if not resp.HasChromeProxyViaHeader(): | |
299 r = resp.response | |
300 raise ChromeProxyMetricException, ( | |
301 '%s: Safebrowsing feature should be off for desktop.\n' | |
302 'Reponse: status=(%d, %s)\nHeaders:\n %s' % ( | |
303 r.url, r.status, r.status_text, r.headers)) | |
304 | |
305 if response_count == 0: | |
306 raise ChromeProxyMetricException, ( | |
307 'Safebrowsing failed: No valid responses received\n') | |
sclittle
2015/01/23 20:06:46
nit: remove '\n' from the end
Not at Google. Contact bengr
2015/01/23 22:56:00
Done.
| |
308 | |
309 results.AddValue(scalar.ScalarValue( | |
310 results.current_page, 'safebrowsing', 'responses', response_count)) | |
294 | 311 |
295 def AddResultsForHTTPFallback(self, tab, results): | 312 def AddResultsForHTTPFallback(self, tab, results): |
296 via_fallback_count = 0 | 313 via_fallback_count = 0 |
297 | 314 |
298 for resp in self.IterResponses(tab): | 315 for resp in self.IterResponses(tab): |
299 if resp.ShouldHaveChromeProxyViaHeader(): | 316 if resp.ShouldHaveChromeProxyViaHeader(): |
300 # All responses should have come through the HTTP fallback proxy, which | 317 # All responses should have come through the HTTP fallback proxy, which |
301 # means that they should have the via header, and if a remote port is | 318 # means that they should have the via header, and if a remote port is |
302 # defined, it should be port 80. | 319 # defined, it should be port 80. |
303 if (not resp.HasChromeProxyViaHeader() or | 320 if (not resp.HasChromeProxyViaHeader() or |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
412 'Response for %s should have via header; proxy should no longer ' | 429 'Response for %s should have via header; proxy should no longer ' |
413 'be bypassed.\nReponse: status=(%d, %s)\nHeaders:\n %s' % ( | 430 'be bypassed.\nReponse: status=(%d, %s)\nHeaders:\n %s' % ( |
414 r.url, r.status, r.status_text, r.headers)) | 431 r.url, r.status, r.status_text, r.headers)) |
415 else: | 432 else: |
416 via_count += 1 | 433 via_count += 1 |
417 | 434 |
418 results.AddValue(scalar.ScalarValue( | 435 results.AddValue(scalar.ScalarValue( |
419 results.current_page, 'bypass', 'count', bypass_count)) | 436 results.current_page, 'bypass', 'count', bypass_count)) |
420 results.AddValue(scalar.ScalarValue( | 437 results.AddValue(scalar.ScalarValue( |
421 results.current_page, 'via', 'count', via_count)) | 438 results.current_page, 'via', 'count', via_count)) |
OLD | NEW |