Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(58)

Side by Side Diff: tools/chrome_proxy/common/chrome_proxy_measurements.py

Issue 1135173007: Kill page_test.NavigateToPage (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@KillNavigateToPage
Patch Set: Address sclittle's comment Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/chrome_proxy/integration_tests/chrome_proxy_benchmark.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 logging 5 import logging
6 6
7 from common import chrome_proxy_metrics as metrics 7 from common import chrome_proxy_metrics as metrics
8 from telemetry.core import exceptions 8 from telemetry.core import exceptions
9 from telemetry.page import page_test 9 from telemetry.page import page_test
10 10
11 class ChromeProxyValidation(page_test.PageTest): 11 class ChromeProxyValidation(page_test.PageTest):
12 """Base class for all chrome proxy correctness measurements.""" 12 """Base class for all chrome proxy correctness measurements."""
13 13
14 # Value of the extra via header. |None| if no extra via header is expected. 14 # Value of the extra via header. |None| if no extra via header is expected.
15 extra_via_header = None 15 extra_via_header = None
16 16
17 def __init__(self, restart_after_each_page=False, metrics=None): 17 def __init__(self, restart_after_each_page=False, metrics=None):
18 super(ChromeProxyValidation, self).__init__( 18 super(ChromeProxyValidation, self).__init__(
19 needs_browser_restart_after_each_page=restart_after_each_page) 19 needs_browser_restart_after_each_page=restart_after_each_page)
20 self._metrics = metrics 20 self._metrics = metrics
21 self._page = None 21 self._page = None
22 # Whether a timeout exception is expected during the test.
23 self._expect_timeout = False
24 22
25 def CustomizeBrowserOptions(self, options): 23 def CustomizeBrowserOptions(self, options):
26 # Enable the chrome proxy (data reduction proxy). 24 # Enable the chrome proxy (data reduction proxy).
27 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth') 25 options.AppendExtraBrowserArgs('--enable-spdy-proxy-auth')
28 26
29 def WillNavigateToPage(self, page, tab): 27 def WillNavigateToPage(self, page, tab):
30 tab.ClearCache(force=True) 28 tab.ClearCache(force=True)
31 assert self._metrics 29 assert self._metrics
32 self._metrics.Start(page, tab) 30 self._metrics.Start(page, tab)
33 31
34 def ValidateAndMeasurePage(self, page, tab, results): 32 def ValidateAndMeasurePage(self, page, tab, results):
35 self._page = page 33 self._page = page
36 # Wait for the load event. 34 # Wait for the load event.
37 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) 35 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300)
38 assert self._metrics 36 assert self._metrics
39 self._metrics.Stop(page, tab) 37 self._metrics.Stop(page, tab)
40 if ChromeProxyValidation.extra_via_header: 38 if ChromeProxyValidation.extra_via_header:
41 self._metrics.AddResultsForExtraViaHeader( 39 self._metrics.AddResultsForExtraViaHeader(
42 tab, results, ChromeProxyValidation.extra_via_header) 40 tab, results, ChromeProxyValidation.extra_via_header)
43 self.AddResults(tab, results) 41 self.AddResults(tab, results)
44 42
45 def AddResults(self, tab, results): 43 def AddResults(self, tab, results):
46 raise NotImplementedError 44 raise NotImplementedError
47 45
48 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 46 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613
49 if hasattr(page, 'restart_after') and page.restart_after: 47 if hasattr(page, 'restart_after') and page.restart_after:
50 return True 48 return True
51 return False 49 return False
52
53 def RunNavigateSteps(self, page, tab):
54 # The redirect from safebrowsing causes a timeout. Ignore that.
55 try:
56 super(ChromeProxyValidation, self).RunNavigateSteps(page, tab)
57 if self._expect_timeout:
58 raise metrics.ChromeProxyMetricException, (
59 'Timeout was expected, but did not occur')
60 except exceptions.TimeoutException as e:
61 if self._expect_timeout:
62 logging.warning('Navigation timeout on page %s',
63 page.name if page.name else page.url)
64 else:
65 raise e
OLDNEW
« no previous file with comments | « no previous file | tools/chrome_proxy/integration_tests/chrome_proxy_benchmark.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698