| 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 | 7 |
| 8 from common import chrome_proxy_metrics as metrics | 8 from common import chrome_proxy_metrics as metrics |
| 9 from telemetry.core import exceptions | 9 from telemetry.core import exceptions |
| 10 from telemetry.page import legacy_page_test | 10 from telemetry.page import legacy_page_test |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 '} catch (err) {' | 44 '} catch (err) {' |
| 45 '/* Return normally if the xhr request failed. */' | 45 '/* Return normally if the xhr request failed. */' |
| 46 '}' | 46 '}' |
| 47 'return false;' | 47 'return false;' |
| 48 '}' | 48 '}' |
| 49 '</script>' | 49 '</script>' |
| 50 'Waiting for Chrome to start using the DRP...' | 50 'Waiting for Chrome to start using the DRP...' |
| 51 '</body></html>')) | 51 '</body></html>')) |
| 52 | 52 |
| 53 # Ensure the page has finished loading before attempting the DRP check. | 53 # Ensure the page has finished loading before attempting the DRP check. |
| 54 tab.WaitForJavaScriptCondition2('performance.timing.loadEventEnd', timeout=60) | 54 tab.WaitForJavaScriptCondition('performance.timing.loadEventEnd', timeout=60) |
| 55 | 55 |
| 56 expected_via_header = metrics.CHROME_PROXY_VIA_HEADER | 56 expected_via_header = metrics.CHROME_PROXY_VIA_HEADER |
| 57 if ChromeProxyValidation.extra_via_header: | 57 if ChromeProxyValidation.extra_via_header: |
| 58 expected_via_header = ChromeProxyValidation.extra_via_header | 58 expected_via_header = ChromeProxyValidation.extra_via_header |
| 59 | 59 |
| 60 tab.WaitForJavaScriptCondition2( | 60 tab.WaitForJavaScriptCondition( |
| 61 'PollDRPCheck({{ url }}, {{ via_header }})', | 61 'PollDRPCheck({{ url }}, {{ via_header }})', |
| 62 url=url, via_header=expected_via_header, | 62 url=url, via_header=expected_via_header, |
| 63 timeout=60) | 63 timeout=60) |
| 64 | 64 |
| 65 | 65 |
| 66 class ChromeProxyValidation(legacy_page_test.LegacyPageTest): | 66 class ChromeProxyValidation(legacy_page_test.LegacyPageTest): |
| 67 """Base class for all chrome proxy correctness measurements.""" | 67 """Base class for all chrome proxy correctness measurements.""" |
| 68 | 68 |
| 69 # Value of the extra via header. |None| if no extra via header is expected. | 69 # Value of the extra via header. |None| if no extra via header is expected. |
| 70 extra_via_header = None | 70 extra_via_header = None |
| (...skipping 24 matching lines...) Expand all Loading... |
| 95 WaitForViaHeader(tab) | 95 WaitForViaHeader(tab) |
| 96 | 96 |
| 97 if self.clear_cache_before_each_run: | 97 if self.clear_cache_before_each_run: |
| 98 tab.ClearCache(force=True) | 98 tab.ClearCache(force=True) |
| 99 assert self._metrics | 99 assert self._metrics |
| 100 self._metrics.Start(page, tab) | 100 self._metrics.Start(page, tab) |
| 101 | 101 |
| 102 def ValidateAndMeasurePage(self, page, tab, results): | 102 def ValidateAndMeasurePage(self, page, tab, results): |
| 103 self._page = page | 103 self._page = page |
| 104 # Wait for the load event. | 104 # Wait for the load event. |
| 105 tab.WaitForJavaScriptCondition2( | 105 tab.WaitForJavaScriptCondition( |
| 106 'performance.timing.loadEventStart', timeout=300) | 106 'performance.timing.loadEventStart', timeout=300) |
| 107 assert self._metrics | 107 assert self._metrics |
| 108 self._metrics.Stop(page, tab) | 108 self._metrics.Stop(page, tab) |
| 109 if ChromeProxyValidation.extra_via_header: | 109 if ChromeProxyValidation.extra_via_header: |
| 110 self._metrics.AddResultsForExtraViaHeader( | 110 self._metrics.AddResultsForExtraViaHeader( |
| 111 tab, results, ChromeProxyValidation.extra_via_header) | 111 tab, results, ChromeProxyValidation.extra_via_header) |
| 112 self.AddResults(tab, results) | 112 self.AddResults(tab, results) |
| 113 | 113 |
| 114 def AddResults(self, tab, results): | 114 def AddResults(self, tab, results): |
| 115 raise NotImplementedError | 115 raise NotImplementedError |
| 116 | 116 |
| 117 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 | 117 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 |
| 118 if hasattr(page, 'restart_after') and page.restart_after: | 118 if hasattr(page, 'restart_after') and page.restart_after: |
| 119 return True | 119 return True |
| 120 return False | 120 return False |
| OLD | NEW |