Add ICU message format support
[chromium-blink-merge.git] / tools / chrome_proxy / common / chrome_proxy_measurements.py
blob1e14d3719bc1d6dd281991580e630bbfe7d47048
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
3 # found in the LICENSE file.
5 import logging
7 from common import chrome_proxy_metrics as metrics
8 from telemetry.core import exceptions
9 from telemetry.page import page_test
11 class ChromeProxyValidation(page_test.PageTest):
12 """Base class for all chrome proxy correctness measurements."""
14 # Value of the extra via header. |None| if no extra via header is expected.
15 extra_via_header = None
17 def __init__(self, restart_after_each_page=False, metrics=None):
18 super(ChromeProxyValidation, self).__init__(
19 needs_browser_restart_after_each_page=restart_after_each_page)
20 self._metrics = metrics
21 self._page = None
23 def CustomizeBrowserOptions(self, options):
24 # Enable the chrome proxy (data reduction proxy).
25 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
27 def WillNavigateToPage(self, page, tab):
28 tab.ClearCache(force=True)
29 assert self._metrics
30 self._metrics.Start(page, tab)
32 def ValidateAndMeasurePage(self, page, tab, results):
33 self._page = page
34 # Wait for the load event.
35 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
36 assert self._metrics
37 self._metrics.Stop(page, tab)
38 if ChromeProxyValidation.extra_via_header:
39 self._metrics.AddResultsForExtraViaHeader(
40 tab, results, ChromeProxyValidation.extra_via_header)
41 self.AddResults(tab, results)
43 def AddResults(self, tab, results):
44 raise NotImplementedError
46 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613
47 if hasattr(page, 'restart_after') and page.restart_after:
48 return True
49 return False