Update WebCore.FeatureObserver histogram owner.
[chromium-blink-merge.git] / tools / perf / page_sets / key_mobile_sites_smooth.py
blobe59a9a43500e26fddca11c9805a8c7c6c48dc666
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
3 # found in the LICENSE file.
4 from telemetry.page import page as page_module
5 from telemetry.page import shared_page_state
6 from telemetry import story
8 from page_sets import key_mobile_sites_pages
11 def _IssueMarkerAndScroll(action_runner):
12 with action_runner.CreateGestureInteraction('ScrollAction'):
13 action_runner.ScrollPage()
16 def _CreatePageClassWithSmoothInteractions(page_cls):
17 class DerivedSmoothPage(page_cls): # pylint: disable=W0232
19 def RunPageInteractions(self, action_runner):
20 _IssueMarkerAndScroll(action_runner)
21 return DerivedSmoothPage
24 class KeyMobileSitesSmoothPage(page_module.Page):
26 def __init__(self, url, page_set, name='', labels=None,
27 action_on_load_complete=False):
28 super(KeyMobileSitesSmoothPage, self).__init__(
29 url=url, page_set=page_set, name=name,
30 credentials_path='data/credentials.json', labels=labels,
31 shared_page_state_class=shared_page_state.SharedMobilePageState)
32 self.archive_data_file = 'data/key_mobile_sites.json'
33 self.action_on_load_complete = action_on_load_complete
35 def RunPageInteractions(self, action_runner):
36 if self.action_on_load_complete:
37 action_runner.WaitForJavaScriptCondition(
38 'document.readyState == "complete"', 30)
39 _IssueMarkerAndScroll(action_runner)
42 class LinkedInSmoothPage(key_mobile_sites_pages.LinkedInPage):
44 def __init__(self, page_set):
45 super(LinkedInSmoothPage, self).__init__(page_set=page_set)
47 # Linkedin has expensive shader compilation so it can benefit from shader
48 # cache from reload.
49 def RunNavigateSteps(self, action_runner):
50 super(LinkedInSmoothPage, self).RunNavigateSteps(action_runner)
51 action_runner.ScrollPage()
52 action_runner.ReloadPage()
53 super(LinkedInSmoothPage, self).RunNavigateSteps(action_runner)
56 class WowwikiSmoothPage(KeyMobileSitesSmoothPage):
57 """Why: Mobile wiki."""
58 def __init__(self, page_set):
59 super(WowwikiSmoothPage, self).__init__(
60 url='http://www.wowwiki.com/World_of_Warcraft:_Mists_of_Pandaria',
61 page_set=page_set)
63 # Wowwiki has expensive shader compilation so it can benefit from shader
64 # cache from reload.
65 def RunNavigateSteps(self, action_runner):
66 super(WowwikiSmoothPage, self).RunNavigateSteps(action_runner)
67 action_runner.ScrollPage()
68 action_runner.ReloadPage()
69 super(WowwikiSmoothPage, self).RunNavigateSteps(action_runner)
72 class GmailSmoothPage(key_mobile_sites_pages.GmailPage):
74 def RunPageInteractions(self, action_runner):
75 with action_runner.CreateGestureInteraction('ScrollAction'):
76 action_runner.ScrollElement(element_function=(
77 'document.getElementById("views").childNodes[1].firstChild'))
78 with action_runner.CreateGestureInteraction('ScrollAction'):
79 action_runner.ScrollElement(element_function=(
80 'document.getElementById("views").childNodes[1].firstChild'))
83 class GroupClonedSmoothPage(key_mobile_sites_pages.GroupClonedPage):
85 def RunPageInteractions(self, action_runner):
86 with action_runner.CreateGestureInteraction('ScrollAction'):
87 action_runner.ScrollPage(
88 distance_expr='''
89 Math.max(0, 1250 + document.getElementById("element-19")
90 .contentDocument
91 .getElementById("element-22")
92 .getBoundingClientRect().top);''',
93 use_touch=True)
96 class GroupClonedListImagesPage(
97 key_mobile_sites_pages.GroupClonedListImagesPage):
99 def RunPageInteractions(self, action_runner):
100 with action_runner.CreateGestureInteraction('ScrollAction'):
101 action_runner.ScrollPage(
102 distance_expr='''
103 Math.max(0, 1250 +
104 document.getElementById("element-5")
105 .getBoundingClientRect().top);''',
106 use_touch=True)
108 class GoogleNewsMobile2SmoothPage(
109 key_mobile_sites_pages.GoogleNewsMobile2Page):
111 def RunPageInteractions(self, action_runner):
112 with action_runner.CreateGestureInteraction('ScrollAction'):
113 action_runner.ScrollElement(
114 element_function='document.getElementById(":5")',
115 distance_expr='''
116 Math.max(0, 2500 +
117 document.getElementById(':h').getBoundingClientRect().top)''',
118 use_touch=True)
121 class AmazonNicolasCageSmoothPage(
122 key_mobile_sites_pages.AmazonNicolasCagePage):
124 def RunPageInteractions(self, action_runner):
125 with action_runner.CreateGestureInteraction('ScrollAction'):
126 action_runner.ScrollElement(
127 selector='#search',
128 distance_expr='document.body.scrollHeight - window.innerHeight')
131 class KeyMobileSitesSmoothPageSet(story.StorySet):
133 """ Key mobile sites with smooth interactions. """
135 def __init__(self):
136 super(KeyMobileSitesSmoothPageSet, self).__init__(
137 archive_data_file='data/key_mobile_sites_smooth.json',
138 cloud_storage_bucket=story.PARTNER_BUCKET)
141 # Add pages with predefined classes that contain custom navigation logic.
142 predefined_page_classes = [
143 key_mobile_sites_pages.CapitolVolkswagenPage,
144 key_mobile_sites_pages.TheVergeArticlePage,
145 key_mobile_sites_pages.CnnArticlePage,
146 key_mobile_sites_pages.FacebookPage,
147 key_mobile_sites_pages.YoutubeMobilePage,
148 key_mobile_sites_pages.YahooAnswersPage,
149 key_mobile_sites_pages.GoogleNewsMobilePage,
151 for page_class in predefined_page_classes:
152 self.AddUserStory(
153 _CreatePageClassWithSmoothInteractions(page_class)(self))
155 self.AddUserStory(
156 _CreatePageClassWithSmoothInteractions(LinkedInSmoothPage)(self))
157 self.AddUserStory(WowwikiSmoothPage(self))
159 # Add pages with custom page interaction logic.
161 # Page behaves non-deterministically, replaced with test version for now.
162 # self.AddUserStory(GroupClonedSmoothPage(self))
163 # mean_input_event_latency cannot be tracked correctly for
164 # GroupClonedListImagesPage.
165 # See crbug.com/409086.
166 # self.AddUserStory(GroupClonedListImagesSmoothPage(self))
167 self.AddUserStory(GoogleNewsMobile2SmoothPage(self))
168 self.AddUserStory(AmazonNicolasCageSmoothPage(self))
170 # Add pages with custom labels.
172 # Why: Top news site.
173 self.AddUserStory(KeyMobileSitesSmoothPage(
174 url='http://nytimes.com/', page_set=self, labels=['fastpath']))
176 # Why: Image-heavy site.
177 self.AddUserStory(KeyMobileSitesSmoothPage(
178 url='http://cuteoverload.com', page_set=self, labels=['fastpath']))
180 # Why: #11 (Alexa global), google property; some blogger layouts
181 # have infinite scroll but more interesting.
182 self.AddUserStory(KeyMobileSitesSmoothPage(
183 url='http://googlewebmastercentral.blogspot.com/',
184 page_set=self, name='Blogger'))
186 # Why: #18 (Alexa global), Picked an interesting post """
187 self.AddUserStory(KeyMobileSitesSmoothPage(
188 # pylint: disable=line-too-long
189 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
190 page_set=self,
191 name='Wordpress'))
193 # Why: #6 (Alexa) most visited worldwide, picked an interesting page
194 self.AddUserStory(KeyMobileSitesSmoothPage(
195 url='http://en.wikipedia.org/wiki/Wikipedia',
196 page_set=self,
197 name='Wikipedia (1 tab)'))
199 # Why: Wikipedia page with a delayed scroll start
200 self.AddUserStory(KeyMobileSitesSmoothPage(
201 url='http://en.wikipedia.org/wiki/Wikipedia',
202 page_set=self,
203 name='Wikipedia (1 tab) - delayed scroll start',
204 action_on_load_complete=True))
206 # Why: #8 (Alexa global), picked an interesting page
207 # Forbidden (Rate Limit Exceeded)
208 # self.AddUserStory(KeyMobileSitesSmoothPage(
209 # url='http://twitter.com/katyperry', page_set=self, name='Twitter'))
211 # Why: #37 (Alexa global) """
212 self.AddUserStory(KeyMobileSitesSmoothPage(
213 url='http://pinterest.com',
214 page_set=self,
215 name='Pinterest'))
217 # Why: #1 sports.
218 # Fails often; crbug.com/249722'
219 # self.AddUserStory(KeyMobileSitesSmoothPage(
220 # url='http://espn.go.com', page_set=self, name='ESPN'))
221 # Why: crbug.com/231413
222 # Doesn't scroll; crbug.com/249736
223 # self.AddUserStory(KeyMobileSitesSmoothPage(
224 # url='http://forecast.io', page_set=self))
225 # Why: crbug.com/169827
226 self.AddUserStory(KeyMobileSitesSmoothPage(
227 url='http://slashdot.org/', page_set=self, labels=['fastpath']))
229 # Why: #5 Alexa news """
231 self.AddUserStory(KeyMobileSitesSmoothPage(
232 url='http://www.reddit.com/r/programming/comments/1g96ve',
233 page_set=self, labels=['fastpath']))
235 # Why: Problematic use of fixed position elements """
236 self.AddUserStory(KeyMobileSitesSmoothPage(
237 url='http://www.boingboing.net', page_set=self, labels=['fastpath']))
239 # Add simple pages with no custom navigation logic or labels.
240 urls_list = [
241 # Why: Social; top Google property; Public profile; infinite scrolls.
242 # pylint: disable=line-too-long
243 'https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
244 # Why: crbug.com/242544
245 ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
246 'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
247 'program/'),
248 # Why: crbug.com/149958
249 'http://gsp.ro',
250 # Why: Top tech blog
251 'http://theverge.com',
252 # Why: Top tech site
253 'http://digg.com',
254 # Why: Top Google property; a Google tab is often open
255 'https://www.google.com/#hl=en&q=barack+obama',
256 # Why: #1 news worldwide (Alexa global)
257 'http://news.yahoo.com',
258 # Why: #2 news worldwide
259 'http://www.cnn.com',
260 # Why: #1 commerce website by time spent by users in US
261 'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
262 # Why: #1 Alexa recreation
263 # pylint: disable=line-too-long
264 'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
265 # Why: Top tech blog
266 'http://techcrunch.com',
267 # Why: #6 Alexa sports
268 'http://mlb.com/',
269 # Why: #14 Alexa California
270 'http://www.sfgate.com/',
271 # Why: Non-latin character set
272 'http://worldjournal.com/',
273 # Why: #15 Alexa news
274 'http://online.wsj.com/home-page',
275 # Why: Image-heavy mobile site
276 'http://www.deviantart.com/',
277 # Why: Top search engine
278 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
279 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
280 # Why: Top search engine
281 'http://www.bing.com/search?q=sloths',
282 # Why: Good example of poor initial scrolling
283 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans'
286 for url in urls_list:
287 self.AddUserStory(KeyMobileSitesSmoothPage(url, self))