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

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

Issue 2672803002: [Telemetry refactor] Migrate clients to new JavaScript API (batch 3) (Closed)
Patch Set: add comment on tools/android Created 3 years, 10 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
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 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
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.WaitForJavaScriptExpression('performance.timing.loadEventEnd', 60) 54 tab.WaitForJavaScriptCondition2('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.WaitForJavaScriptExpression( 60 tab.WaitForJavaScriptCondition2(
61 'PollDRPCheck("%s", "%s")' % (url, expected_via_header), 60) 61 'PollDRPCheck({{ url }}, {{ via_header }})',
62 url=url, via_header=expected_via_header,
63 timeout=60)
62 64
63 65
64 class ChromeProxyValidation(legacy_page_test.LegacyPageTest): 66 class ChromeProxyValidation(legacy_page_test.LegacyPageTest):
65 """Base class for all chrome proxy correctness measurements.""" 67 """Base class for all chrome proxy correctness measurements."""
66 68
67 # 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.
68 extra_via_header = None 70 extra_via_header = None
69 71
70 def __init__(self, restart_after_each_page=False, metrics=None, 72 def __init__(self, restart_after_each_page=False, metrics=None,
71 clear_cache_before_each_run=True): 73 clear_cache_before_each_run=True):
(...skipping 21 matching lines...) Expand all
93 WaitForViaHeader(tab) 95 WaitForViaHeader(tab)
94 96
95 if self.clear_cache_before_each_run: 97 if self.clear_cache_before_each_run:
96 tab.ClearCache(force=True) 98 tab.ClearCache(force=True)
97 assert self._metrics 99 assert self._metrics
98 self._metrics.Start(page, tab) 100 self._metrics.Start(page, tab)
99 101
100 def ValidateAndMeasurePage(self, page, tab, results): 102 def ValidateAndMeasurePage(self, page, tab, results):
101 self._page = page 103 self._page = page
102 # Wait for the load event. 104 # Wait for the load event.
103 tab.WaitForJavaScriptExpression('performance.timing.loadEventStart', 300) 105 tab.WaitForJavaScriptCondition2(
106 'performance.timing.loadEventStart', timeout=300)
104 assert self._metrics 107 assert self._metrics
105 self._metrics.Stop(page, tab) 108 self._metrics.Stop(page, tab)
106 if ChromeProxyValidation.extra_via_header: 109 if ChromeProxyValidation.extra_via_header:
107 self._metrics.AddResultsForExtraViaHeader( 110 self._metrics.AddResultsForExtraViaHeader(
108 tab, results, ChromeProxyValidation.extra_via_header) 111 tab, results, ChromeProxyValidation.extra_via_header)
109 self.AddResults(tab, results) 112 self.AddResults(tab, results)
110 113
111 def AddResults(self, tab, results): 114 def AddResults(self, tab, results):
112 raise NotImplementedError 115 raise NotImplementedError
113 116
114 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613 117 def StopBrowserAfterPage(self, browser, page): # pylint: disable=W0613
115 if hasattr(page, 'restart_after') and page.restart_after: 118 if hasattr(page, 'restart_after') and page.restart_after:
116 return True 119 return True
117 return False 120 return False
OLDNEW
« no previous file with comments | « tools/android/loading/devtools_monitor.py ('k') | tools/chrome_proxy/integration_tests/chrome_proxy_measurements.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698