OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 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 argparse | 5 import argparse |
6 import json | 6 import json |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import re | 9 import re |
10 import socket | 10 import socket |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 """ | 407 """ |
408 histogram = {} | 408 histogram = {} |
409 while(not histogram and sleep_intervals > 0): | 409 while(not histogram and sleep_intervals > 0): |
410 histogram = self.GetHistogram(histogram_name, 5) | 410 histogram = self.GetHistogram(histogram_name, 5) |
411 if (not histogram): | 411 if (not histogram): |
412 time.sleep(1) | 412 time.sleep(1) |
413 sleep_intervals -= 1 | 413 sleep_intervals -= 1 |
414 | 414 |
415 return bool(histogram) | 415 return bool(histogram) |
416 | 416 |
417 def GetHTTPResponses(self, include_favicon=False, skip_domainless_pages=True): | 417 def GetHTTPResponses(self, include_favicon=False, skip_domainless_pages=True, |
| 418 override_has_logs=False): |
418 """Parses the Performance Logs and returns a list of HTTPResponse objects. | 419 """Parses the Performance Logs and returns a list of HTTPResponse objects. |
419 | 420 |
420 Use caution when calling this function multiple times. Only responses | 421 Use caution when calling this function multiple times. Only responses |
421 since the last time this function was called are returned (or since Chrome | 422 since the last time this function was called are returned (or since Chrome |
422 started, whichever is later). An Exception will be raised if no page was | 423 started, whichever is later). An Exception will be raised if no page was |
423 loaded since the last time this function was called. | 424 loaded since the last time this function was called. |
424 | 425 |
425 Args: | 426 Args: |
426 include_favicon: A bool that if True will include responses for favicons. | 427 include_favicon: A bool that if True will include responses for favicons. |
427 skip_domainless_pages: If True, only responses with a net_loc as in RFC | 428 skip_domainless_pages: If True, only responses with a net_loc as in RFC |
428 1808 will be included. Pages such as about:blank will be skipped. | 429 1808 will be included. Pages such as about:blank will be skipped. |
| 430 override_has_logs: Allows the _has_logs property to be set if there was |
| 431 not a page load but an XHR was expected instead. |
429 Returns: | 432 Returns: |
430 A list of HTTPResponse objects, each representing a single completed HTTP | 433 A list of HTTPResponse objects, each representing a single completed HTTP |
431 transaction by Chrome. | 434 transaction by Chrome. |
432 """ | 435 """ |
| 436 if override_has_logs: |
| 437 self._has_logs = True |
433 def MakeHTTPResponse(log_dict): | 438 def MakeHTTPResponse(log_dict): |
434 params = log_dict['params'] | 439 params = log_dict['params'] |
435 response_dict = params['response'] | 440 response_dict = params['response'] |
436 http_response_dict = { | 441 http_response_dict = { |
437 'response_headers': response_dict['headers'] if 'headers' in | 442 'response_headers': response_dict['headers'] if 'headers' in |
438 response_dict else {}, | 443 response_dict else {}, |
439 'request_headers': response_dict['requestHeaders'] if 'requestHeaders' | 444 'request_headers': response_dict['requestHeaders'] if 'requestHeaders' |
440 in response_dict else {}, | 445 in response_dict else {}, |
441 'url': response_dict['url'] if 'url' in response_dict else '', | 446 'url': response_dict['url'] if 'url' in response_dict else '', |
442 'protocol': response_dict['protocol'] if 'protocol' in response_dict | 447 'protocol': response_dict['protocol'] if 'protocol' in response_dict |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
669 for test_suite in test_suite_iter: | 674 for test_suite in test_suite_iter: |
670 for test_case in test_suite: | 675 for test_case in test_suite: |
671 for test in test_case: | 676 for test in test_case: |
672 # Drop the file name in the form <filename>.<classname>.<methodname> | 677 # Drop the file name in the form <filename>.<classname>.<methodname> |
673 test_id = test.id()[test.id().find('.') + 1:] | 678 test_id = test.id()[test.id().find('.') + 1:] |
674 if re.match(test_filter_re, test_id): | 679 if re.match(test_filter_re, test_id): |
675 tests.addTest(test) | 680 tests.addTest(test) |
676 testRunner = unittest.runner.TextTestRunner(verbosity=2, | 681 testRunner = unittest.runner.TextTestRunner(verbosity=2, |
677 failfast=flags.failfast, buffer=(not flags.disable_buffer)) | 682 failfast=flags.failfast, buffer=(not flags.disable_buffer)) |
678 testRunner.run(tests) | 683 testRunner.run(tests) |
OLD | NEW |