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 page_test | 10 from telemetry.page import legacy_page_test |
11 | 11 |
12 | 12 |
13 def WaitForViaHeader(tab, url="http://check.googlezip.net/test.html"): | 13 def WaitForViaHeader(tab, url="http://check.googlezip.net/test.html"): |
14 """Wait until responses start coming back with the Chrome Proxy via header. | 14 """Wait until responses start coming back with the Chrome Proxy via header. |
15 | 15 |
16 Poll |url| in |tab| until the Chrome Proxy via header is present in a | 16 Poll |url| in |tab| until the Chrome Proxy via header is present in a |
17 response. | 17 response. |
18 | 18 |
19 This function is useful when testing with the Data Saver API, since Chrome | 19 This function is useful when testing with the Data Saver API, since Chrome |
20 won't actually start sending requests to the Data Reduction Proxy until the | 20 won't actually start sending requests to the Data Reduction Proxy until the |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 tab.WaitForJavaScriptExpression('performance.timing.loadEventEnd', 60) | 54 tab.WaitForJavaScriptExpression('performance.timing.loadEventEnd', 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.WaitForJavaScriptExpression( | 60 tab.WaitForJavaScriptExpression( |
61 'PollDRPCheck("%s", "%s")' % (url, expected_via_header), 60) | 61 'PollDRPCheck("%s", "%s")' % (url, expected_via_header), 60) |
62 | 62 |
63 | 63 |
64 class ChromeProxyValidation(page_test.PageTest): | 64 class ChromeProxyValidation(legacy_page_test.LegacyPageTest): |
65 """Base class for all chrome proxy correctness measurements.""" | 65 """Base class for all chrome proxy correctness measurements.""" |
66 | 66 |
67 # Value of the extra via header. |None| if no extra via header is expected. | 67 # Value of the extra via header. |None| if no extra via header is expected. |
68 extra_via_header = None | 68 extra_via_header = None |
69 | 69 |
70 def __init__(self, restart_after_each_page=False, metrics=None, | 70 def __init__(self, restart_after_each_page=False, metrics=None, |
71 clear_cache_before_each_run=True): | 71 clear_cache_before_each_run=True): |
72 super(ChromeProxyValidation, self).__init__( | 72 super(ChromeProxyValidation, self).__init__( |
73 needs_browser_restart_after_each_page=restart_after_each_page, | 73 needs_browser_restart_after_each_page=restart_after_each_page, |
74 clear_cache_before_each_run=clear_cache_before_each_run) | 74 clear_cache_before_each_run=clear_cache_before_each_run) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 tab, results, ChromeProxyValidation.extra_via_header) | 108 tab, results, ChromeProxyValidation.extra_via_header) |
109 self.AddResults(tab, results) | 109 self.AddResults(tab, results) |
110 | 110 |
111 def AddResults(self, tab, results): | 111 def AddResults(self, tab, results): |
112 raise NotImplementedError | 112 raise NotImplementedError |
113 | 113 |
114 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 | 114 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 |
115 if hasattr(page, 'restart_after') and page.restart_after: | 115 if hasattr(page, 'restart_after') and page.restart_after: |
116 return True | 116 return True |
117 return False | 117 return False |
OLD | NEW |