| Index: tools/chrome_proxy/webdriver/common.py
|
| diff --git a/tools/chrome_proxy/webdriver/common.py b/tools/chrome_proxy/webdriver/common.py
|
| index 2572a64a9253049576e6d5b6364a950ce18c46c3..47917bf87b868e6dfcf4c339ac97c63129a6d8c6 100644
|
| --- a/tools/chrome_proxy/webdriver/common.py
|
| +++ b/tools/chrome_proxy/webdriver/common.py
|
| @@ -327,9 +327,18 @@ class TestDriver:
|
| """
|
| return self.ExecuteJavascript("return " + script, timeout)
|
|
|
| - def GetHistogram(self, histogram):
|
| + def GetHistogram(self, histogram, timeout=30):
|
| + """Gets a Chrome histogram as a dictionary object.
|
| +
|
| + Args:
|
| + histogram: the name of the histogram to fetch
|
| + timeout: timeout for the underlying Javascript query.
|
| +
|
| + Returns:
|
| + A dictionary object containing information about the histogram.
|
| + """
|
| js_query = 'statsCollectionController.getBrowserHistogram("%s")' % histogram
|
| - string_response = self.ExecuteJavascriptStatement(js_query)
|
| + string_response = self.ExecuteJavascriptStatement(js_query, timeout)
|
| self._logger.debug('Got %s histogram=%s', histogram, string_response)
|
| return json.loads(string_response)
|
|
|
| @@ -382,6 +391,27 @@ class TestDriver:
|
| self._has_logs = False
|
| return all_messages
|
|
|
| + def SleepUntilHistogramHasEntry(self, histogram_name, sleep_intervals=10):
|
| + """Polls if a histogram exists in 1-6 second intervals for 10 intervals.
|
| + Allows script to run with a timeout of 5 seconds, so the default behavior
|
| + allows up to 60 seconds until timeout.
|
| +
|
| + Args:
|
| + histogram_name: The name of the histogram to wait for
|
| + sleep_intervals: The number of polling intervals, each polling cycle takes
|
| + no more than 6 seconds.
|
| + Returns:
|
| + Whether the histogram exists
|
| + """
|
| + histogram = {}
|
| + while(not histogram and sleep_intervals > 0):
|
| + histogram = self.GetHistogram(histogram_name, 5)
|
| + if (not histogram):
|
| + time.sleep(1)
|
| + sleep_intervals -= 1
|
| +
|
| + return bool(histogram)
|
| +
|
| def GetHTTPResponses(self, include_favicon=False, skip_domainless_pages=True):
|
| """Parses the Performance Logs and returns a list of HTTPResponse objects.
|
|
|
|
|