Delete chrome.mediaGalleriesPrivate because the functionality unique to it has since...
[chromium-blink-merge.git] / tools / perf / page_sets / key_mobile_sites_smooth.py
blob36178c5f462a07b5c8326a7bd795f7e360c2672f
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 page_set as page_set_module
7 from page_sets import key_mobile_sites_pages
10 def _IssueMarkerAndScroll(action_runner):
11 interaction = action_runner.BeginGestureInteraction(
12 'ScrollAction', is_smooth=True)
13 action_runner.ScrollPage()
14 interaction.End()
17 def _CreatePageClassWithSmoothInteractions(page_cls):
18 class DerivedSmoothPage(page_cls): # pylint: disable=W0232
20 def RunPageInteractions(self, action_runner):
21 _IssueMarkerAndScroll(action_runner)
22 return DerivedSmoothPage
25 class KeyMobileSitesSmoothPage(page_module.Page):
27 def __init__(self, url, page_set, name='', labels=None):
28 super(KeyMobileSitesSmoothPage, self).__init__(
29 url=url, page_set=page_set, name=name,
30 credentials_path='data/credentials.json', labels=labels)
31 self.user_agent_type = 'mobile'
32 self.archive_data_file = 'data/key_mobile_sites.json'
34 def RunPageInteractions(self, action_runner):
35 _IssueMarkerAndScroll(action_runner)
38 class GmailSmoothPage(key_mobile_sites_pages.GmailPage):
40 def RunPageInteractions(self, action_runner):
41 interaction = action_runner.BeginGestureInteraction(
42 'ScrollAction', is_smooth=True)
43 action_runner.ScrollElement(element_function=(
44 'document.getElementById("views").childNodes[1].firstChild'))
45 interaction.End()
46 interaction = action_runner.BeginGestureInteraction(
47 'ScrollAction', is_smooth=True)
48 action_runner.ScrollElement(element_function=(
49 'document.getElementById("views").childNodes[1].firstChild'))
50 interaction.End()
53 class GroupClonedSmoothPage(key_mobile_sites_pages.GroupClonedPage):
55 def RunPageInteractions(self, action_runner):
56 interaction = action_runner.BeginGestureInteraction(
57 'ScrollAction', is_smooth=True)
58 action_runner.ScrollPage(
59 distance_expr='''
60 Math.max(0, 1250 + document.getElementById("element-19")
61 .contentDocument
62 .getElementById("element-22")
63 .getBoundingClientRect().top);''',
64 use_touch=True)
65 interaction.End()
68 class GroupClonedListImagesPage(
69 key_mobile_sites_pages.GroupClonedListImagesPage):
71 def RunPageInteractions(self, action_runner):
72 interaction = action_runner.BeginGestureInteraction(
73 'ScrollAction', is_smooth=True)
74 action_runner.ScrollPage(
75 distance_expr='''
76 Math.max(0, 1250 +
77 document.getElementById("element-5")
78 .getBoundingClientRect().top);''',
79 use_touch=True)
80 interaction.End()
82 class GoogleNewsMobile2SmoothPage(
83 key_mobile_sites_pages.GoogleNewsMobile2Page):
85 def RunPageInteractions(self, action_runner):
86 interaction = action_runner.BeginGestureInteraction(
87 'ScrollAction', is_smooth=True)
88 action_runner.ScrollElement(
89 element_function='document.getElementById(":5")',
90 distance_expr='''
91 Math.max(0, 2500 +
92 document.getElementById(':h').getBoundingClientRect().top)''',
93 use_touch=True)
94 interaction.End()
97 class AmazonNicolasCageSmoothPage(
98 key_mobile_sites_pages.AmazonNicolasCagePage):
100 def RunPageInteractions(self, action_runner):
101 interaction = action_runner.BeginGestureInteraction(
102 'ScrollAction', is_smooth=True)
103 action_runner.ScrollElement(
104 selector='#search',
105 distance_expr='document.body.scrollHeight - window.innerHeight')
106 interaction.End()
109 class KeyMobileSitesSmoothPageSet(page_set_module.PageSet):
111 """ Key mobile sites with smooth interactions. """
113 def __init__(self):
114 super(KeyMobileSitesSmoothPageSet, self).__init__(
115 user_agent_type='mobile',
116 archive_data_file='data/key_mobile_sites.json',
117 bucket=page_set_module.PARTNER_BUCKET)
120 # Add pages with predefined classes that contain custom navigation logic.
121 predefined_page_classes = [
122 key_mobile_sites_pages.CapitolVolkswagenPage,
123 key_mobile_sites_pages.TheVergeArticlePage,
124 key_mobile_sites_pages.CnnArticlePage,
125 key_mobile_sites_pages.FacebookPage,
126 key_mobile_sites_pages.YoutubeMobilePage,
127 key_mobile_sites_pages.LinkedInPage,
128 key_mobile_sites_pages.YahooAnswersPage,
129 key_mobile_sites_pages.GoogleNewsMobilePage,
131 for page_class in predefined_page_classes:
132 self.AddUserStory(
133 _CreatePageClassWithSmoothInteractions(page_class)(self))
135 # Add pages with custom page interaction logic.
137 # Page behaves non-deterministically, replaced with test version for now.
138 # self.AddUserStory(GroupClonedSmoothPage(self))
139 # mean_input_event_latency cannot be tracked correctly for
140 # GroupClonedListImagesPage.
141 # See crbug.com/409086.
142 # self.AddUserStory(GroupClonedListImagesSmoothPage(self))
143 self.AddUserStory(GoogleNewsMobile2SmoothPage(self))
144 self.AddUserStory(AmazonNicolasCageSmoothPage(self))
146 # Add pages with custom labels.
148 # Why: Top news site.
149 self.AddUserStory(KeyMobileSitesSmoothPage(
150 url='http://nytimes.com/', page_set=self, labels=['fastpath']))
152 # Why: Image-heavy site.
153 self.AddUserStory(KeyMobileSitesSmoothPage(
154 url='http://cuteoverload.com', page_set=self, labels=['fastpath']))
156 # Why: #11 (Alexa global), google property; some blogger layouts
157 # have infinite scroll but more interesting.
158 self.AddUserStory(KeyMobileSitesSmoothPage(
159 url='http://googlewebmastercentral.blogspot.com/',
160 page_set=self, name='Blogger'))
162 # Why: #18 (Alexa global), Picked an interesting post """
163 self.AddUserStory(KeyMobileSitesSmoothPage(
164 # pylint: disable=line-too-long
165 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
166 page_set=self,
167 name='Wordpress'))
169 # Why: #6 (Alexa) most visited worldwide, picked an interesting page
170 self.AddUserStory(KeyMobileSitesSmoothPage(
171 url='http://en.wikipedia.org/wiki/Wikipedia',
172 page_set=self,
173 name='Wikipedia (1 tab)'))
176 # Why: #8 (Alexa global), picked an interesting page
177 # Forbidden (Rate Limit Exceeded)
178 # self.AddUserStory(KeyMobileSitesSmoothPage(
179 # url='http://twitter.com/katyperry', page_set=self, name='Twitter'))
181 # Why: #37 (Alexa global) """
182 self.AddUserStory(KeyMobileSitesSmoothPage(
183 url='http://pinterest.com',
184 page_set=self,
185 name='Pinterest'))
187 # Why: #1 sports.
188 # Fails often; crbug.com/249722'
189 # self.AddUserStory(KeyMobileSitesSmoothPage(
190 # url='http://espn.go.com', page_set=self, name='ESPN'))
191 # Why: crbug.com/231413
192 # Doesn't scroll; crbug.com/249736
193 # self.AddUserStory(KeyMobileSitesSmoothPage(
194 # url='http://forecast.io', page_set=self))
195 # Why: crbug.com/169827
196 self.AddUserStory(KeyMobileSitesSmoothPage(
197 url='http://slashdot.org/', page_set=self, labels=['fastpath']))
199 # Why: #5 Alexa news """
201 self.AddUserStory(KeyMobileSitesSmoothPage(
202 url='http://www.reddit.com/r/programming/comments/1g96ve',
203 page_set=self, labels=['fastpath']))
205 # Why: Problematic use of fixed position elements """
206 self.AddUserStory(KeyMobileSitesSmoothPage(
207 url='http://www.boingboing.net', page_set=self, labels=['fastpath']))
209 # Add simple pages with no custom navigation logic or labels.
210 urls_list = [
211 # Why: Social; top Google property; Public profile; infinite scrolls.
212 # pylint: disable=line-too-long
213 'https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
214 # Why: crbug.com/242544
215 ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
216 'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
217 'program/'),
218 # Why: crbug.com/149958
219 'http://gsp.ro',
220 # Why: Top tech blog
221 'http://theverge.com',
222 # Why: Top tech site
223 'http://digg.com',
224 # Why: Top Google property; a Google tab is often open
225 'https://www.google.com/#hl=en&q=barack+obama',
226 # Why: #1 news worldwide (Alexa global)
227 'http://news.yahoo.com',
228 # Why: #2 news worldwide
229 'http://www.cnn.com',
230 # Why: #1 commerce website by time spent by users in US
231 'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
232 # Why: #1 Alexa recreation
233 # pylint: disable=line-too-long
234 'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
235 # Why: #1 Alexa sports
236 'http://sports.yahoo.com/',
237 # Why: Top tech blog
238 'http://techcrunch.com',
239 # Why: #6 Alexa sports
240 'http://mlb.com/',
241 # Why: #14 Alexa California
242 'http://www.sfgate.com/',
243 # Why: Non-latin character set
244 'http://worldjournal.com/',
245 # Why: Mobile wiki
246 'http://www.wowwiki.com/World_of_Warcraft:_Mists_of_Pandaria',
247 # Why: #15 Alexa news
248 'http://online.wsj.com/home-page',
249 # Why: Image-heavy mobile site
250 'http://www.deviantart.com/',
251 # Why: Top search engine
252 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
253 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
254 # Why: Top search engine
255 'http://www.bing.com/search?q=sloths',
256 # Why: Good example of poor initial scrolling
257 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans'
260 for url in urls_list:
261 self.AddUserStory(KeyMobileSitesSmoothPage(url, self))