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 import urlparse | 7 import urlparse |
8 | 8 |
| 9 from common.chrome_proxy_measurements import ChromeProxyValidation |
9 from integration_tests import chrome_proxy_metrics as metrics | 10 from integration_tests import chrome_proxy_metrics as metrics |
10 from metrics import loading | 11 from metrics import loading |
11 from telemetry.core import exceptions | 12 from telemetry.core import exceptions |
12 from telemetry.page import page_test | 13 from telemetry.page import page_test |
13 | 14 |
14 class ChromeProxyLatency(page_test.PageTest): | 15 class ChromeProxyLatency(page_test.PageTest): |
15 """Chrome proxy latency measurement.""" | 16 """Chrome proxy latency measurement.""" |
16 | 17 |
17 def __init__(self, *args, **kwargs): | 18 def __init__(self, *args, **kwargs): |
18 super(ChromeProxyLatency, self).__init__(*args, **kwargs) | 19 super(ChromeProxyLatency, self).__init__(*args, **kwargs) |
(...skipping 24 matching lines...) Expand all Loading... |
43 tab.ClearCache(force=True) | 44 tab.ClearCache(force=True) |
44 self._metrics.Start(page, tab) | 45 self._metrics.Start(page, tab) |
45 | 46 |
46 def ValidateAndMeasurePage(self, page, tab, results): | 47 def ValidateAndMeasurePage(self, page, tab, results): |
47 # Wait for the load event. | 48 # Wait for the load event. |
48 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) | 49 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) |
49 self._metrics.Stop(page, tab) | 50 self._metrics.Stop(page, tab) |
50 self._metrics.AddResultsForDataSaving(tab, results) | 51 self._metrics.AddResultsForDataSaving(tab, results) |
51 | 52 |
52 | 53 |
53 class ChromeProxyValidation(page_test.PageTest): | |
54 """Base class for all chrome proxy correctness measurements.""" | |
55 | |
56 # Value of the extra via header. |None| if no extra via header is expected. | |
57 extra_via_header = None | |
58 | |
59 def __init__(self, restart_after_each_page=False): | |
60 super(ChromeProxyValidation, self).__init__( | |
61 needs_browser_restart_after_each_page=restart_after_each_page) | |
62 self._metrics = metrics.ChromeProxyMetric() | |
63 self._page = None | |
64 # Whether a timeout exception is expected during the test. | |
65 self._expect_timeout = False | |
66 | |
67 def CustomizeBrowserOptions(self, options): | |
68 # Enable the chrome proxy (data reduction proxy). | |
69 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') | |
70 | |
71 def WillNavigateToPage(self, page, tab): | |
72 tab.ClearCache(force=True) | |
73 assert self._metrics | |
74 self._metrics.Start(page, tab) | |
75 | |
76 def ValidateAndMeasurePage(self, page, tab, results): | |
77 self._page = page | |
78 # Wait for the load event. | |
79 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) | |
80 assert self._metrics | |
81 self._metrics.Stop(page, tab) | |
82 if ChromeProxyValidation.extra_via_header: | |
83 self._metrics.AddResultsForExtraViaHeader( | |
84 tab, results, ChromeProxyValidation.extra_via_header) | |
85 self.AddResults(tab, results) | |
86 | |
87 def AddResults(self, tab, results): | |
88 raise NotImplementedError | |
89 | |
90 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 | |
91 if hasattr(page, 'restart_after') and page.restart_after: | |
92 return True | |
93 return False | |
94 | |
95 def RunNavigateSteps(self, page, tab): | |
96 # The redirect from safebrowsing causes a timeout. Ignore that. | |
97 try: | |
98 super(ChromeProxyValidation, self).RunNavigateSteps(page, tab) | |
99 if self._expect_timeout: | |
100 raise metrics.ChromeProxyMetricException, ( | |
101 'Timeout was expected, but did not occur') | |
102 except exceptions.TimeoutException as e: | |
103 if self._expect_timeout: | |
104 logging.warning('Navigation timeout on page %s', | |
105 page.name if page.name else page.url) | |
106 else: | |
107 raise e | |
108 | |
109 | |
110 class ChromeProxyHeaders(ChromeProxyValidation): | 54 class ChromeProxyHeaders(ChromeProxyValidation): |
111 """Correctness measurement for response headers.""" | 55 """Correctness measurement for response headers.""" |
112 | 56 |
113 def __init__(self): | 57 def __init__(self): |
114 super(ChromeProxyHeaders, self).__init__(restart_after_each_page=True) | 58 super(ChromeProxyHeaders, self).__init__( |
| 59 restart_after_each_page=True, |
| 60 metrics=metrics.ChromeProxyMetric()) |
115 | 61 |
116 def AddResults(self, tab, results): | 62 def AddResults(self, tab, results): |
117 self._metrics.AddResultsForHeaderValidation(tab, results) | 63 self._metrics.AddResultsForHeaderValidation(tab, results) |
118 | 64 |
119 | 65 |
120 class ChromeProxyBypass(ChromeProxyValidation): | 66 class ChromeProxyBypass(ChromeProxyValidation): |
121 """Correctness measurement for bypass responses.""" | 67 """Correctness measurement for bypass responses.""" |
122 | 68 |
123 def __init__(self): | 69 def __init__(self): |
124 super(ChromeProxyBypass, self).__init__(restart_after_each_page=True) | 70 super(ChromeProxyBypass, self).__init__( |
| 71 restart_after_each_page=True, |
| 72 metrics=metrics.ChromeProxyMetric()) |
125 | 73 |
126 def AddResults(self, tab, results): | 74 def AddResults(self, tab, results): |
127 self._metrics.AddResultsForBypass(tab, results) | 75 self._metrics.AddResultsForBypass(tab, results) |
128 | 76 |
129 | 77 |
130 class ChromeProxyCorsBypass(ChromeProxyValidation): | 78 class ChromeProxyCorsBypass(ChromeProxyValidation): |
131 """Correctness measurement for bypass responses for CORS requests.""" | 79 """Correctness measurement for bypass responses for CORS requests.""" |
132 | 80 |
133 def __init__(self): | 81 def __init__(self): |
134 super(ChromeProxyCorsBypass, self).__init__(restart_after_each_page=True) | 82 super(ChromeProxyCorsBypass, self).__init__( |
| 83 restart_after_each_page=True, |
| 84 metrics=metrics.ChromeProxyMetric()) |
135 | 85 |
136 def ValidateAndMeasurePage(self, page, tab, results): | 86 def ValidateAndMeasurePage(self, page, tab, results): |
137 # The test page sets window.xhrRequestCompleted to true when the XHR fetch | 87 # The test page sets window.xhrRequestCompleted to true when the XHR fetch |
138 # finishes. | 88 # finishes. |
139 tab.WaitForJavaScriptExpression('window.xhrRequestCompleted', 300) | 89 tab.WaitForJavaScriptExpression('window.xhrRequestCompleted', 300) |
140 super(ChromeProxyCorsBypass, | 90 super(ChromeProxyCorsBypass, |
141 self).ValidateAndMeasurePage(page, tab, results) | 91 self).ValidateAndMeasurePage(page, tab, results) |
142 | 92 |
143 def AddResults(self, tab, results): | 93 def AddResults(self, tab, results): |
144 self._metrics.AddResultsForCorsBypass(tab, results) | 94 self._metrics.AddResultsForCorsBypass(tab, results) |
145 | 95 |
146 | 96 |
147 class ChromeProxyBlockOnce(ChromeProxyValidation): | 97 class ChromeProxyBlockOnce(ChromeProxyValidation): |
148 """Correctness measurement for block-once responses.""" | 98 """Correctness measurement for block-once responses.""" |
149 | 99 |
150 def __init__(self): | 100 def __init__(self): |
151 super(ChromeProxyBlockOnce, self).__init__(restart_after_each_page=True) | 101 super(ChromeProxyBlockOnce, self).__init__( |
| 102 restart_after_each_page=True, |
| 103 metrics=metrics.ChromeProxyMetric()) |
152 | 104 |
153 def AddResults(self, tab, results): | 105 def AddResults(self, tab, results): |
154 self._metrics.AddResultsForBlockOnce(tab, results) | 106 self._metrics.AddResultsForBlockOnce(tab, results) |
155 | 107 |
156 | 108 |
157 class ChromeProxySafebrowsingOn(ChromeProxyValidation): | 109 class ChromeProxySafebrowsingOn(ChromeProxyValidation): |
158 """Correctness measurement for safebrowsing.""" | 110 """Correctness measurement for safebrowsing.""" |
159 | 111 |
160 def __init__(self): | 112 def __init__(self): |
161 super(ChromeProxySafebrowsingOn, self).__init__() | 113 super(ChromeProxySafebrowsingOn, self).__init__( |
| 114 metrics=metrics.ChromeProxyMetric()) |
162 | 115 |
163 def WillNavigateToPage(self, page, tab): | 116 def WillNavigateToPage(self, page, tab): |
164 super(ChromeProxySafebrowsingOn, self).WillNavigateToPage(page, tab) | 117 super(ChromeProxySafebrowsingOn, self).WillNavigateToPage(page, tab) |
165 self._expect_timeout = True | 118 self._expect_timeout = True |
166 | 119 |
167 def AddResults(self, tab, results): | 120 def AddResults(self, tab, results): |
168 self._metrics.AddResultsForSafebrowsingOn(tab, results) | 121 self._metrics.AddResultsForSafebrowsingOn(tab, results) |
169 | 122 |
170 class ChromeProxySafebrowsingOff(ChromeProxyValidation): | 123 class ChromeProxySafebrowsingOff(ChromeProxyValidation): |
171 """Correctness measurement for safebrowsing.""" | 124 """Correctness measurement for safebrowsing.""" |
172 | 125 |
173 def __init__(self): | 126 def __init__(self): |
174 super(ChromeProxySafebrowsingOff, self).__init__() | 127 super(ChromeProxySafebrowsingOff, self).__init__( |
| 128 metrics=metrics.ChromeProxyMetric()) |
175 | 129 |
176 def AddResults(self, tab, results): | 130 def AddResults(self, tab, results): |
177 self._metrics.AddResultsForSafebrowsingOff(tab, results) | 131 self._metrics.AddResultsForSafebrowsingOff(tab, results) |
178 | 132 |
179 _FAKE_PROXY_AUTH_VALUE = 'aabbccdd3b7579186c1b0620614fdb1f0000ffff' | 133 _FAKE_PROXY_AUTH_VALUE = 'aabbccdd3b7579186c1b0620614fdb1f0000ffff' |
180 _TEST_SERVER = 'chromeproxy-test.appspot.com' | 134 _TEST_SERVER = 'chromeproxy-test.appspot.com' |
181 _TEST_SERVER_DEFAULT_URL = 'http://' + _TEST_SERVER + '/default' | 135 _TEST_SERVER_DEFAULT_URL = 'http://' + _TEST_SERVER + '/default' |
182 | 136 |
183 | 137 |
184 # We rely on the chromeproxy-test server to facilitate some of the tests. | 138 # We rely on the chromeproxy-test server to facilitate some of the tests. |
(...skipping 26 matching lines...) Expand all Loading... |
211 | 165 |
212 class ChromeProxyHTTPFallbackProbeURL(ChromeProxyValidation): | 166 class ChromeProxyHTTPFallbackProbeURL(ChromeProxyValidation): |
213 """Correctness measurement for proxy fallback. | 167 """Correctness measurement for proxy fallback. |
214 | 168 |
215 In this test, the probe URL does not return 'OK'. Chrome is expected | 169 In this test, the probe URL does not return 'OK'. Chrome is expected |
216 to use the fallback proxy. | 170 to use the fallback proxy. |
217 """ | 171 """ |
218 | 172 |
219 def __init__(self): | 173 def __init__(self): |
220 super(ChromeProxyHTTPFallbackProbeURL, self).__init__( | 174 super(ChromeProxyHTTPFallbackProbeURL, self).__init__( |
221 restart_after_each_page=True) | 175 restart_after_each_page=True, |
| 176 metrics=metrics.ChromeProxyMetric()) |
222 | 177 |
223 def CustomizeBrowserOptions(self, options): | 178 def CustomizeBrowserOptions(self, options): |
224 super(ChromeProxyHTTPFallbackProbeURL, | 179 super(ChromeProxyHTTPFallbackProbeURL, |
225 self).CustomizeBrowserOptions(options) | 180 self).CustomizeBrowserOptions(options) |
226 # Set the secure proxy check URL to the google.com favicon, which will be | 181 # Set the secure proxy check URL to the google.com favicon, which will be |
227 # interpreted as a secure proxy check failure since the response body is not | 182 # interpreted as a secure proxy check failure since the response body is not |
228 # "OK". The google.com favicon is used because it will load reliably fast, | 183 # "OK". The google.com favicon is used because it will load reliably fast, |
229 # and there have been problems with chromeproxy-test.appspot.com being slow | 184 # and there have been problems with chromeproxy-test.appspot.com being slow |
230 # and causing tests to flake. | 185 # and causing tests to flake. |
231 options.AppendExtraBrowserArgs( | 186 options.AppendExtraBrowserArgs( |
232 '--data-reduction-proxy-secure-proxy-check-url=' | 187 '--data-reduction-proxy-secure-proxy-check-url=' |
233 'http://www.google.com/favicon.ico') | 188 'http://www.google.com/favicon.ico') |
234 | 189 |
235 def AddResults(self, tab, results): | 190 def AddResults(self, tab, results): |
236 self._metrics.AddResultsForHTTPFallback(tab, results) | 191 self._metrics.AddResultsForHTTPFallback(tab, results) |
237 | 192 |
238 | 193 |
239 class ChromeProxyHTTPFallbackViaHeader(ChromeProxyValidation): | 194 class ChromeProxyHTTPFallbackViaHeader(ChromeProxyValidation): |
240 """Correctness measurement for proxy fallback. | 195 """Correctness measurement for proxy fallback. |
241 | 196 |
242 In this test, the configured proxy is the chromeproxy-test server which | 197 In this test, the configured proxy is the chromeproxy-test server which |
243 will send back a response without the expected Via header. Chrome is | 198 will send back a response without the expected Via header. Chrome is |
244 expected to use the fallback proxy and add the configured proxy to the | 199 expected to use the fallback proxy and add the configured proxy to the |
245 bad proxy list. | 200 bad proxy list. |
246 """ | 201 """ |
247 | 202 |
248 def __init__(self): | 203 def __init__(self): |
249 super(ChromeProxyHTTPFallbackViaHeader, self).__init__( | 204 super(ChromeProxyHTTPFallbackViaHeader, self).__init__( |
250 restart_after_each_page=True) | 205 restart_after_each_page=True, |
| 206 metrics=metrics.ChromeProxyMetric()) |
251 | 207 |
252 def CustomizeBrowserOptions(self, options): | 208 def CustomizeBrowserOptions(self, options): |
253 super(ChromeProxyHTTPFallbackViaHeader, | 209 super(ChromeProxyHTTPFallbackViaHeader, |
254 self).CustomizeBrowserOptions(options) | 210 self).CustomizeBrowserOptions(options) |
255 options.AppendExtraBrowserArgs('--ignore-certificate-errors') | 211 options.AppendExtraBrowserArgs('--ignore-certificate-errors') |
256 options.AppendExtraBrowserArgs( | 212 options.AppendExtraBrowserArgs( |
257 '--spdy-proxy-auth-origin=http://%s' % _TEST_SERVER) | 213 '--spdy-proxy-auth-origin=http://%s' % _TEST_SERVER) |
258 | 214 |
259 def AddResults(self, tab, results): | 215 def AddResults(self, tab, results): |
260 self._metrics.AddResultsForHTTPFallback(tab, results) | 216 self._metrics.AddResultsForHTTPFallback(tab, results) |
261 | 217 |
262 | 218 |
263 class ChromeProxyClientVersion(ChromeProxyValidation): | 219 class ChromeProxyClientVersion(ChromeProxyValidation): |
264 """Correctness measurement for version directives in Chrome-Proxy header. | 220 """Correctness measurement for version directives in Chrome-Proxy header. |
265 | 221 |
266 The test verifies that the version information provided in the Chrome-Proxy | 222 The test verifies that the version information provided in the Chrome-Proxy |
267 request header overrides any version, if specified, that is provided in the | 223 request header overrides any version, if specified, that is provided in the |
268 user agent string. | 224 user agent string. |
269 """ | 225 """ |
270 | 226 |
271 def __init__(self): | 227 def __init__(self): |
272 super(ChromeProxyClientVersion, self).__init__() | 228 super(ChromeProxyClientVersion, self).__init__( |
| 229 metrics=metrics.ChromeProxyMetric()) |
273 | 230 |
274 def CustomizeBrowserOptions(self, options): | 231 def CustomizeBrowserOptions(self, options): |
275 super(ChromeProxyClientVersion, | 232 super(ChromeProxyClientVersion, |
276 self).CustomizeBrowserOptions(options) | 233 self).CustomizeBrowserOptions(options) |
277 options.AppendExtraBrowserArgs('--user-agent="Chrome/32.0.1700.99"') | 234 options.AppendExtraBrowserArgs('--user-agent="Chrome/32.0.1700.99"') |
278 | 235 |
279 def AddResults(self, tab, results): | 236 def AddResults(self, tab, results): |
280 self._metrics.AddResultsForClientVersion(tab, results) | 237 self._metrics.AddResultsForClientVersion(tab, results) |
281 | 238 |
282 | 239 |
283 class ChromeProxyClientType(ChromeProxyValidation): | 240 class ChromeProxyClientType(ChromeProxyValidation): |
284 """Correctness measurement for Chrome-Proxy header client type directives.""" | 241 """Correctness measurement for Chrome-Proxy header client type directives.""" |
285 | 242 |
286 def __init__(self): | 243 def __init__(self): |
287 super(ChromeProxyClientType, self).__init__(restart_after_each_page=True) | 244 super(ChromeProxyClientType, self).__init__( |
| 245 restart_after_each_page=True, |
| 246 metrics=metrics.ChromeProxyMetric()) |
288 self._chrome_proxy_client_type = None | 247 self._chrome_proxy_client_type = None |
289 | 248 |
290 def AddResults(self, tab, results): | 249 def AddResults(self, tab, results): |
291 # Get the Chrome-Proxy client type from the first page in the page set, so | 250 # Get the Chrome-Proxy client type from the first page in the page set, so |
292 # that the client type value can be used to determine which of the later | 251 # that the client type value can be used to determine which of the later |
293 # pages in the page set should be bypassed. | 252 # pages in the page set should be bypassed. |
294 if not self._chrome_proxy_client_type: | 253 if not self._chrome_proxy_client_type: |
295 client_type = self._metrics.GetClientTypeFromRequests(tab) | 254 client_type = self._metrics.GetClientTypeFromRequests(tab) |
296 if client_type: | 255 if client_type: |
297 self._chrome_proxy_client_type = client_type | 256 self._chrome_proxy_client_type = client_type |
298 | 257 |
299 self._metrics.AddResultsForClientType(tab, | 258 self._metrics.AddResultsForClientType(tab, |
300 results, | 259 results, |
301 self._chrome_proxy_client_type, | 260 self._chrome_proxy_client_type, |
302 self._page.bypass_for_client_type) | 261 self._page.bypass_for_client_type) |
303 | 262 |
304 | 263 |
305 class ChromeProxyLoFi(ChromeProxyValidation): | 264 class ChromeProxyLoFi(ChromeProxyValidation): |
306 """Correctness measurement for Lo-Fi in Chrome-Proxy header.""" | 265 """Correctness measurement for Lo-Fi in Chrome-Proxy header.""" |
307 | 266 |
308 def __init__(self): | 267 def __init__(self): |
309 super(ChromeProxyLoFi, self).__init__(restart_after_each_page=True) | 268 super(ChromeProxyLoFi, self).__init__(restart_after_each_page=True, |
| 269 metrics=metrics.ChromeProxyMetric()) |
310 | 270 |
311 def CustomizeBrowserOptions(self, options): | 271 def CustomizeBrowserOptions(self, options): |
312 super(ChromeProxyLoFi, self).CustomizeBrowserOptions(options) | 272 super(ChromeProxyLoFi, self).CustomizeBrowserOptions(options) |
313 options.AppendExtraBrowserArgs('--enable-data-reduction-proxy-lo-fi') | 273 options.AppendExtraBrowserArgs('--enable-data-reduction-proxy-lo-fi') |
314 | 274 |
315 def AddResults(self, tab, results): | 275 def AddResults(self, tab, results): |
316 self._metrics.AddResultsForLoFi(tab, results) | 276 self._metrics.AddResultsForLoFi(tab, results) |
317 | 277 |
318 class ChromeProxyExpDirective(ChromeProxyValidation): | 278 class ChromeProxyExpDirective(ChromeProxyValidation): |
319 """Correctness measurement for experiment directives in Chrome-Proxy header. | 279 """Correctness measurement for experiment directives in Chrome-Proxy header. |
320 | 280 |
321 This test verifies that "exp=test" in the Chrome-Proxy request header | 281 This test verifies that "exp=test" in the Chrome-Proxy request header |
322 causes a bypass on the experiment test page. | 282 causes a bypass on the experiment test page. |
323 """ | 283 """ |
324 | 284 |
325 def __init__(self): | 285 def __init__(self): |
326 super(ChromeProxyExpDirective, self).__init__(restart_after_each_page=True) | 286 super(ChromeProxyExpDirective, self).__init__( |
| 287 restart_after_each_page=True, |
| 288 metrics=metrics.ChromeProxyMetric()) |
327 | 289 |
328 def CustomizeBrowserOptions(self, options): | 290 def CustomizeBrowserOptions(self, options): |
329 super(ChromeProxyExpDirective, self).CustomizeBrowserOptions(options) | 291 super(ChromeProxyExpDirective, self).CustomizeBrowserOptions(options) |
330 options.AppendExtraBrowserArgs('--data-reduction-proxy-experiment=test') | 292 options.AppendExtraBrowserArgs('--data-reduction-proxy-experiment=test') |
331 | 293 |
332 def AddResults(self, tab, results): | 294 def AddResults(self, tab, results): |
333 self._metrics.AddResultsForBypass(tab, results) | 295 self._metrics.AddResultsForBypass(tab, results) |
334 | 296 |
335 | 297 |
336 class ChromeProxyHTTPToDirectFallback(ChromeProxyValidation): | 298 class ChromeProxyHTTPToDirectFallback(ChromeProxyValidation): |
337 """Correctness measurement for HTTP proxy fallback to direct.""" | 299 """Correctness measurement for HTTP proxy fallback to direct.""" |
338 | 300 |
339 def __init__(self): | 301 def __init__(self): |
340 super(ChromeProxyHTTPToDirectFallback, self).__init__( | 302 super(ChromeProxyHTTPToDirectFallback, self).__init__( |
341 restart_after_each_page=True) | 303 restart_after_each_page=True, |
| 304 metrics=metrics.ChromeProxyMetric()) |
342 | 305 |
343 def CustomizeBrowserOptions(self, options): | 306 def CustomizeBrowserOptions(self, options): |
344 super(ChromeProxyHTTPToDirectFallback, | 307 super(ChromeProxyHTTPToDirectFallback, |
345 self).CustomizeBrowserOptions(options) | 308 self).CustomizeBrowserOptions(options) |
346 # Set the primary proxy to something that will fail to be resolved so that | 309 # Set the primary proxy to something that will fail to be resolved so that |
347 # this test will run using the HTTP fallback proxy. | 310 # this test will run using the HTTP fallback proxy. |
348 options.AppendExtraBrowserArgs( | 311 options.AppendExtraBrowserArgs( |
349 '--spdy-proxy-auth-origin=http://nonexistent.googlezip.net') | 312 '--spdy-proxy-auth-origin=http://nonexistent.googlezip.net') |
350 | 313 |
351 def WillNavigateToPage(self, page, tab): | 314 def WillNavigateToPage(self, page, tab): |
(...skipping 11 matching lines...) Expand all Loading... |
363 class ChromeProxyReenableAfterBypass(ChromeProxyValidation): | 326 class ChromeProxyReenableAfterBypass(ChromeProxyValidation): |
364 """Correctness measurement for re-enabling proxies after bypasses. | 327 """Correctness measurement for re-enabling proxies after bypasses. |
365 | 328 |
366 This test loads a page that causes all data reduction proxies to be bypassed | 329 This test loads a page that causes all data reduction proxies to be bypassed |
367 for 1 to 5 minutes, then waits 5 minutes and verifies that the proxy is no | 330 for 1 to 5 minutes, then waits 5 minutes and verifies that the proxy is no |
368 longer bypassed. | 331 longer bypassed. |
369 """ | 332 """ |
370 | 333 |
371 def __init__(self): | 334 def __init__(self): |
372 super(ChromeProxyReenableAfterBypass, self).__init__( | 335 super(ChromeProxyReenableAfterBypass, self).__init__( |
373 restart_after_each_page=True) | 336 restart_after_each_page=True, |
| 337 metrics=metrics.ChromeProxyMetric()) |
374 | 338 |
375 def AddResults(self, tab, results): | 339 def AddResults(self, tab, results): |
376 self._metrics.AddResultsForReenableAfterBypass( | 340 self._metrics.AddResultsForReenableAfterBypass( |
377 tab, results, self._page.bypass_seconds_min, | 341 tab, results, self._page.bypass_seconds_min, |
378 self._page.bypass_seconds_max) | 342 self._page.bypass_seconds_max) |
379 | 343 |
380 | 344 |
381 class ChromeProxySmoke(ChromeProxyValidation): | 345 class ChromeProxySmoke(ChromeProxyValidation): |
382 """Smoke measurement for basic chrome proxy correctness.""" | 346 """Smoke measurement for basic chrome proxy correctness.""" |
383 | 347 |
384 def __init__(self): | 348 def __init__(self): |
385 super(ChromeProxySmoke, self).__init__(restart_after_each_page=True) | 349 super(ChromeProxySmoke, self).__init__(restart_after_each_page=True, |
| 350 metrics=metrics.ChromeProxyMetric()) |
386 | 351 |
387 def WillNavigateToPage(self, page, tab): | 352 def WillNavigateToPage(self, page, tab): |
388 super(ChromeProxySmoke, self).WillNavigateToPage(page, tab) | 353 super(ChromeProxySmoke, self).WillNavigateToPage(page, tab) |
389 | 354 |
390 def AddResults(self, tab, results): | 355 def AddResults(self, tab, results): |
391 # Map a page name to its AddResults func. | 356 # Map a page name to its AddResults func. |
392 page_to_metrics = { | 357 page_to_metrics = { |
393 'header validation': [self._metrics.AddResultsForHeaderValidation], | 358 'header validation': [self._metrics.AddResultsForHeaderValidation], |
394 'compression: image': [ | 359 'compression: image': [ |
395 self._metrics.AddResultsForHeaderValidation, | 360 self._metrics.AddResultsForHeaderValidation, |
396 self._metrics.AddResultsForDataSaving, | 361 self._metrics.AddResultsForDataSaving, |
397 ], | 362 ], |
398 'compression: javascript': [ | 363 'compression: javascript': [ |
399 self._metrics.AddResultsForHeaderValidation, | 364 self._metrics.AddResultsForHeaderValidation, |
400 self._metrics.AddResultsForDataSaving, | 365 self._metrics.AddResultsForDataSaving, |
401 ], | 366 ], |
402 'compression: css': [ | 367 'compression: css': [ |
403 self._metrics.AddResultsForHeaderValidation, | 368 self._metrics.AddResultsForHeaderValidation, |
404 self._metrics.AddResultsForDataSaving, | 369 self._metrics.AddResultsForDataSaving, |
405 ], | 370 ], |
406 'bypass': [self._metrics.AddResultsForBypass], | 371 'bypass': [self._metrics.AddResultsForBypass], |
407 } | 372 } |
408 if not self._page.name in page_to_metrics: | 373 if not self._page.name in page_to_metrics: |
409 raise page_test.MeasurementFailure( | 374 raise page_test.MeasurementFailure( |
410 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % ( | 375 'Invalid page name (%s) in smoke. Page name must be one of:\n%s' % ( |
411 self._page.name, page_to_metrics.keys())) | 376 self._page.name, page_to_metrics.keys())) |
412 for add_result in page_to_metrics[self._page.name]: | 377 for add_result in page_to_metrics[self._page.name]: |
413 add_result(tab, results) | 378 add_result(tab, results) |
OLD | NEW |