Chromium Code Reviews| Index: tools/perf/page_sets/tough_ad_cases.py |
| diff --git a/tools/perf/page_sets/tough_ad_cases.py b/tools/perf/page_sets/tough_ad_cases.py |
| index 969296cdbccd2c5e3775914595fb1a274c544128..01a11c981674ba2b0fcabc6bb667c53f33cec182 100644 |
| --- a/tools/perf/page_sets/tough_ad_cases.py |
| +++ b/tools/perf/page_sets/tough_ad_cases.py |
| @@ -2,7 +2,8 @@ |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| -from telemetry.core import exceptions |
| +from page_sets import repeatable_synthesize_scroll_gesture_shared_state |
| + |
| from telemetry.page import page as page_module |
| from telemetry import story |
| @@ -34,11 +35,17 @@ class SwiffyPage(page_module.Page): |
| class ScrollingPage(page_module.Page): |
| - def __init__(self, url, page_set, top_start_ratio=.5, |
| - make_javascript_deterministic=True): |
| - super(ScrollingPage, self).__init__(url=url, page_set=page_set, |
| - make_javascript_deterministic=make_javascript_deterministic) |
| - self._top_start_ratio = top_start_ratio |
| + def __init__(self, url, page_set, make_javascript_deterministic=True, |
| + y_scroll_distance_multiplier=0.5): |
| + super(ScrollingPage, self).__init__( |
| + url=url, |
| + page_set=page_set, |
| + make_javascript_deterministic=make_javascript_deterministic, |
| + shared_page_state_class=( |
| + repeatable_synthesize_scroll_gesture_shared_state.\ |
| + RepeatableSynthesizeScrollGestureSharedState)) |
| + self._y_scroll_distance_multiplier = y_scroll_distance_multiplier |
| + self._screensize = [] |
| def RunNavigateSteps(self, action_runner): |
| # Rewrite file urls to point to the replay server instead. |
| @@ -49,27 +56,19 @@ class ScrollingPage(page_module.Page): |
| url = self._url |
| action_runner.tab.Navigate(url) |
| - # Give the page one second to become interactive and start scrolling after |
| - # the timeout regardless of the document's ready state. |
| - try: |
| - action_runner.tab.WaitForDocumentReadyStateToBeInteractiveOrBetter(1) |
| - except exceptions.TimeoutException: |
| - pass |
| - # Wait for the document to have a body so that we can scroll. |
| - # Simultaneously (to reduce latency), insert a no-op touch handler on the |
| - # body. Most ads have touch handlers and we want to simulate the worst case |
| - # of the user trying to scroll the page by grabbing an ad. |
| + # Wait for the page to be scrollable. Simultaneously (to reduce latency due |
| + # to main thread round trips), insert a no-op touch handler on the body. |
| + # Most ads have touch handlers and we want to simulate the worst case of the |
| + # user trying to scroll the page by grabbing an ad. |
| action_runner.WaitForJavaScriptCondition( |
| - '!(document.body == null || ' |
| - ' document.body.addEventListener("touchstart", function() {}))') |
| + 'document.body != null && ' |
| + 'document.body.scrollHeight > window.screen.height && ' |
|
Sami
2015/08/20 12:39:53
window.innerHeight is probably want you want here
alex clarke (OOO till 29th)
2015/08/20 12:45:45
Done.
|
| + '!document.body.addEventListener("touchstart", function() {})') |
| def RunPageInteractions(self, action_runner): |
| - for _ in range(10): |
| - with action_runner.CreateGestureInteraction('ScrollAction', |
| - repeatable=True): |
| - action_runner.ScrollPage(distance=500, |
| - top_start_ratio=self._top_start_ratio) |
| - action_runner.Wait(.25) |
| + action_runner.RepeatableBrowserDrivenScroll( |
| + y_scroll_distance_ratio=self._y_scroll_distance_multiplier, |
| + repeat_count=9) |
| class ScrollingForbesPage(ScrollingPage): |
| @@ -79,8 +78,7 @@ class ScrollingForbesPage(ScrollingPage): |
| # which occasionally causes us to try scrolling from outside the |
| # screen. Start at the very top of the viewport to avoid this. |
| super(ScrollingForbesPage, self).__init__( |
| - url=url, page_set=page_set, top_start_ratio=0, |
| - make_javascript_deterministic=False) |
| + url=url, page_set=page_set, make_javascript_deterministic=False) |
| def RunNavigateSteps(self, action_runner): |
| super(ScrollingForbesPage, self).RunNavigateSteps(action_runner) |
| @@ -158,7 +156,8 @@ class ScrollingToughAdCasesPageSet(story.StorySet): |
| cloud_storage_bucket=story.INTERNAL_BUCKET) |
| self.AddStory(ScrollingPage('file://tough_ad_cases/' |
| - 'swiffy_collection.html', self, make_javascript_deterministic=False)) |
| + 'swiffy_collection.html', self, make_javascript_deterministic=False, |
| + y_scroll_distance_multiplier=0.25)) |
| self.AddStory(ScrollingPage('file://tough_ad_cases/' |
| 'swiffy_webgl_collection.html', |
| self, make_javascript_deterministic=False)) |
| @@ -166,15 +165,16 @@ class ScrollingToughAdCasesPageSet(story.StorySet): |
| self.AddStory(ScrollingForbesPage('http://www.forbes.com/sites/parmyolson/' |
| '2015/07/29/jana-mobile-data-facebook-internet-org/', self)) |
| self.AddStory(ScrollingPage('http://androidcentral.com', self)) |
| - self.AddStory(ScrollingPage('http://mashable.com', self, top_start_ratio=0)) |
| + self.AddStory(ScrollingPage('http://mashable.com', self, |
| + y_scroll_distance_multiplier=0.25)) |
| self.AddStory(ScrollingPage('http://www.androidauthority.com/' |
| 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self)) |
| self.AddStory(ScrollingPage('http://www.cnn.com/2015/01/09/politics/' |
| - 'nebraska-keystone-pipeline/index.html', self, top_start_ratio=0)) |
| + 'nebraska-keystone-pipeline/index.html', self)) |
| # Disabled: crbug.com/520509 |
| #self.AddStory(ScrollingPage('http://time.com/3977891/' |
| # 'donald-trump-debate-republican/', self)) |
| self.AddStory(ScrollingPage('http://www.theguardian.com/uk', self)) |
| - self.AddStory(ScrollingPage('http://m.tmz.com', self)) |
| - self.AddStory(ScrollingPage('http://androidpolice.com', self, |
| - top_start_ratio=0)) |
| + self.AddStory(ScrollingPage('http://m.tmz.com', self, |
| + y_scroll_distance_multiplier=0.25)) |
| + self.AddStory(ScrollingPage('http://androidpolice.com', self)) |