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

Side by Side Diff: tools/perf/page_sets/tough_ad_cases.py

Issue 1291513004: smoothness.scrolling_tough_ad_cases to use browser driven scrolls (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Responding to feedback Created 5 years, 4 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 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 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 from telemetry.core import exceptions 5 from page_sets import repeatable_synthesize_scroll_gesture_shared_state
6
6 from telemetry.page import page as page_module 7 from telemetry.page import page as page_module
8 from telemetry.web_perf import timeline_interaction_record
7 from telemetry import story 9 from telemetry import story
8 10
9 11
10 class SwiffyPage(page_module.Page): 12 class SwiffyPage(page_module.Page):
11 13
12 def __init__(self, url, page_set): 14 def __init__(self, url, page_set):
13 super(SwiffyPage, self).__init__(url=url, page_set=page_set, 15 super(SwiffyPage, self).__init__(url=url, page_set=page_set,
14 make_javascript_deterministic=False) 16 make_javascript_deterministic=False)
15 17
16 def RunNavigateSteps(self, action_runner): 18 def RunNavigateSteps(self, action_runner):
(...skipping 11 matching lines...) Expand all
28 action_runner.EvaluateJavaScript(viewport_js) 30 action_runner.EvaluateJavaScript(viewport_js)
29 31
30 def RunPageInteractions(self, action_runner): 32 def RunPageInteractions(self, action_runner):
31 with action_runner.CreateInteraction('ToughAd'): 33 with action_runner.CreateInteraction('ToughAd'):
32 action_runner.Wait(10) 34 action_runner.Wait(10)
33 35
34 36
35 class ScrollingPage(page_module.Page): 37 class ScrollingPage(page_module.Page):
36 38
37 def __init__(self, url, page_set, top_start_ratio=.5, 39 def __init__(self, url, page_set, top_start_ratio=.5,
38 make_javascript_deterministic=True): 40 make_javascript_deterministic=True, scroll_multiplier=0.5):
Sami 2015/08/19 11:54:46 What does it mean to scroll .5 times?-)
alex clarke (OOO till 29th) 2015/08/19 15:40:58 It's a distance multiplier, hopefully that is more
39 super(ScrollingPage, self).__init__(url=url, page_set=page_set, 41 super(ScrollingPage, self).__init__(
40 make_javascript_deterministic=make_javascript_deterministic) 42 url=url,
43 page_set=page_set,
44 make_javascript_deterministic=make_javascript_deterministic,
45 shared_page_state_class=(
46 repeatable_synthesize_scroll_gesture_shared_state.\
47 RepeatableSynthesizeScrollGestureSharedState))
41 self._top_start_ratio = top_start_ratio 48 self._top_start_ratio = top_start_ratio
49 self._scroll_multiplier = scroll_multiplier
50 self._screensize = []
42 51
43 def RunNavigateSteps(self, action_runner): 52 def RunNavigateSteps(self, action_runner):
44 # Rewrite file urls to point to the replay server instead. 53 # Rewrite file urls to point to the replay server instead.
45 if self.is_file: 54 if self.is_file:
46 url = self.file_path_url_with_scheme 55 url = self.file_path_url_with_scheme
47 url = action_runner.tab.browser.http_server.UrlOf(url[len('file://'):]) 56 url = action_runner.tab.browser.http_server.UrlOf(url[len('file://'):])
48 else: 57 else:
49 url = self._url 58 url = self._url
50 action_runner.tab.Navigate(url) 59 action_runner.tab.Navigate(url)
51 60
52 # Give the page one second to become interactive and start scrolling after 61 # Wait for the page to be scrollable.
53 # the timeout regardless of the document's ready state.
54 try:
55 action_runner.tab.WaitForDocumentReadyStateToBeInteractiveOrBetter(1)
56 except exceptions.TimeoutException:
57 pass
58 # Wait for the document to have a body so that we can scroll.
59 # Simultaneously (to reduce latency), insert a no-op touch handler on the
60 # body. Most ads have touch handlers and we want to simulate the worst case
61 # of the user trying to scroll the page by grabbing an ad.
62 action_runner.WaitForJavaScriptCondition( 62 action_runner.WaitForJavaScriptCondition(
63 '!(document.body == null || ' 63 'document.body != null && '
64 ' document.body.addEventListener("touchstart", function() {}))') 64 'document.body.scrollHeight > window.screen.height')
65
66 # Get the dimensions of the screen. Simultaneously (to reduce latency),
67 # insert a no-op touch handler on the body. Most ads have touch handlers
68 # and we want to simulate the worst case of the user trying to scroll the
69 # page by grabbing an ad.
70 js_result = action_runner.EvaluateJavaScript(
71 'window.screen.availWidth + "," + window.screen.availHeight + "," + '
72 '(document.body.addEventListener("touchstart", function() {}) ? 1 : 0)')
73 self._screensize = [int(n) for n in js_result.split(',')]
74
65 75
66 def RunPageInteractions(self, action_runner): 76 def RunPageInteractions(self, action_runner):
67 for _ in range(10): 77 scroll_distance = int(self._scroll_multiplier * self._screensize[1])
68 with action_runner.CreateGestureInteraction('ScrollAction',
69 repeatable=True):
70 action_runner.ScrollPage(distance=500,
71 top_start_ratio=self._top_start_ratio)
72 action_runner.Wait(.25)
73 78
79 # Set up a browser driven repeating scroll. The delay between the scrolls
80 # should be unaffected by render thread responsivness (or lack there of).
81 action_runner.tab.SynthesizeScrollGesture(
82 x=int(self._screensize[0] / 2),
83 y=self._screensize[1] - int(self._screensize[1] * 0.25),
84 xDistance=0,
85 yDistance=-scroll_distance,
86 repeatCount=9,
87 repeatDelayMs=250,
88 interactionMarkerName=timeline_interaction_record.GetJavaScriptMarker(
89 'Gesture_ScrollAction', [timeline_interaction_record.REPEATABLE]))
74 90
75 class ScrollingForbesPage(ScrollingPage): 91 class ScrollingForbesPage(ScrollingPage):
76 92
77 def __init__(self, url, page_set): 93 def __init__(self, url, page_set):
78 # forbes.com uses a strange dynamic transform on the body element, 94 # forbes.com uses a strange dynamic transform on the body element,
79 # which occasionally causes us to try scrolling from outside the 95 # which occasionally causes us to try scrolling from outside the
80 # screen. Start at the very top of the viewport to avoid this. 96 # screen. Start at the very top of the viewport to avoid this.
81 super(ScrollingForbesPage, self).__init__( 97 super(ScrollingForbesPage, self).__init__(
82 url=url, page_set=page_set, top_start_ratio=0, 98 url=url, page_set=page_set, top_start_ratio=0,
83 make_javascript_deterministic=False) 99 make_javascript_deterministic=False)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 137
122 class ScrollingToughAdCasesPageSet(story.StorySet): 138 class ScrollingToughAdCasesPageSet(story.StorySet):
123 """Pages for measuring scrolling performance with advertising content.""" 139 """Pages for measuring scrolling performance with advertising content."""
124 140
125 def __init__(self): 141 def __init__(self):
126 super(ScrollingToughAdCasesPageSet, self).__init__( 142 super(ScrollingToughAdCasesPageSet, self).__init__(
127 archive_data_file='data/tough_ad_cases.json', 143 archive_data_file='data/tough_ad_cases.json',
128 cloud_storage_bucket=story.INTERNAL_BUCKET) 144 cloud_storage_bucket=story.INTERNAL_BUCKET)
129 145
130 self.AddStory(ScrollingPage('file://tough_ad_cases/' 146 self.AddStory(ScrollingPage('file://tough_ad_cases/'
131 'swiffy_collection.html', self, make_javascript_deterministic=False)) 147 'swiffy_collection.html', self, make_javascript_deterministic=False,
148 scroll_multiplier=0.25))
132 self.AddStory(ScrollingPage('http://www.latimes.com', self)) 149 self.AddStory(ScrollingPage('http://www.latimes.com', self))
133 self.AddStory(ScrollingForbesPage('http://www.forbes.com/sites/parmyolson/' 150 self.AddStory(ScrollingForbesPage('http://www.forbes.com/sites/parmyolson/'
134 '2015/07/29/jana-mobile-data-facebook-internet-org/', self)) 151 '2015/07/29/jana-mobile-data-facebook-internet-org/', self))
135 self.AddStory(ScrollingPage('http://androidcentral.com', self)) 152 self.AddStory(ScrollingPage('http://androidcentral.com', self))
136 self.AddStory(ScrollingPage('http://mashable.com', self, top_start_ratio=0)) 153 self.AddStory(ScrollingPage('http://mashable.com', self, top_start_ratio=0))
137 self.AddStory(ScrollingPage('http://www.androidauthority.com/' 154 self.AddStory(ScrollingPage('http://www.androidauthority.com/'
138 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self)) 155 'reduce-data-use-turn-on-data-compression-in-chrome-630064/', self))
139 self.AddStory(ScrollingPage('http://www.cnn.com/2015/01/09/politics/' 156 self.AddStory(ScrollingPage('http://www.cnn.com/2015/01/09/politics/'
140 'nebraska-keystone-pipeline/index.html', self, top_start_ratio=0)) 157 'nebraska-keystone-pipeline/index.html', self, top_start_ratio=0))
141 # Disabled: crbug.com/520509 158 # Disabled: crbug.com/520509
142 #self.AddStory(ScrollingPage('http://time.com/3977891/' 159 #self.AddStory(ScrollingPage('http://time.com/3977891/'
143 # 'donald-trump-debate-republican/', self)) 160 # 'donald-trump-debate-republican/', self))
144 self.AddStory(ScrollingPage('http://www.theguardian.com/uk', self)) 161 self.AddStory(ScrollingPage('http://www.theguardian.com/uk', self))
145 self.AddStory(ScrollingPage('http://m.tmz.com', self)) 162 self.AddStory(ScrollingPage('http://m.tmz.com', self,
163 scroll_multiplier=0.25))
146 self.AddStory(ScrollingPage('http://androidpolice.com', self, 164 self.AddStory(ScrollingPage('http://androidpolice.com', self,
147 top_start_ratio=0)) 165 top_start_ratio=0))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698