Update broken references to image assets
[chromium-blink-merge.git] / tools / perf / page_sets / key_mobile_sites_smooth.py
blob577c0e9a2de83d6539cbf4b6cf4916ff4934af10
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 super(LinkedInSmoothPage, self).RunNavigateSteps(action_runner)
55 class WowwikiSmoothPage(KeyMobileSitesSmoothPage):
56 """Why: Mobile wiki."""
57 def __init__(self, page_set):
58 super(WowwikiSmoothPage, self).__init__(
59 url='http://www.wowwiki.com/World_of_Warcraft:_Mists_of_Pandaria',
60 page_set=page_set)
62 # Wowwiki has expensive shader compilation so it can benefit from shader
63 # cache from reload.
64 def RunNavigateSteps(self, action_runner):
65 super(WowwikiSmoothPage, self).RunNavigateSteps(action_runner)
66 action_runner.ScrollPage()
67 super(WowwikiSmoothPage, self).RunNavigateSteps(action_runner)
70 class GmailSmoothPage(key_mobile_sites_pages.GmailPage):
72 def RunPageInteractions(self, action_runner):
73 with action_runner.CreateGestureInteraction('ScrollAction'):
74 action_runner.ScrollElement(element_function=(
75 'document.getElementById("views").childNodes[1].firstChild'))
76 with action_runner.CreateGestureInteraction('ScrollAction'):
77 action_runner.ScrollElement(element_function=(
78 'document.getElementById("views").childNodes[1].firstChild'))
81 class GroupClonedSmoothPage(key_mobile_sites_pages.GroupClonedPage):
83 def RunPageInteractions(self, action_runner):
84 with action_runner.CreateGestureInteraction('ScrollAction'):
85 action_runner.ScrollPage(
86 distance_expr='''
87 Math.max(0, 1250 + document.getElementById("element-19")
88 .contentDocument
89 .getElementById("element-22")
90 .getBoundingClientRect().top);''',
91 use_touch=True)
94 class GroupClonedListImagesPage(
95 key_mobile_sites_pages.GroupClonedListImagesPage):
97 def RunPageInteractions(self, action_runner):
98 with action_runner.CreateGestureInteraction('ScrollAction'):
99 action_runner.ScrollPage(
100 distance_expr='''
101 Math.max(0, 1250 +
102 document.getElementById("element-5")
103 .getBoundingClientRect().top);''',
104 use_touch=True)
106 class GoogleNewsMobile2SmoothPage(
107 key_mobile_sites_pages.GoogleNewsMobile2Page):
109 def RunPageInteractions(self, action_runner):
110 with action_runner.CreateGestureInteraction('ScrollAction'):
111 action_runner.ScrollElement(
112 element_function='document.getElementById(":5")',
113 distance_expr='''
114 Math.max(0, 2500 +
115 document.getElementById(':h').getBoundingClientRect().top)''',
116 use_touch=True)
119 class AmazonNicolasCageSmoothPage(
120 key_mobile_sites_pages.AmazonNicolasCagePage):
122 def RunPageInteractions(self, action_runner):
123 with action_runner.CreateGestureInteraction('ScrollAction'):
124 action_runner.ScrollElement(
125 selector='#search',
126 distance_expr='document.body.scrollHeight - window.innerHeight')
129 class KeyMobileSitesSmoothPageSet(story.StorySet):
131 """ Key mobile sites with smooth interactions. """
133 def __init__(self):
134 super(KeyMobileSitesSmoothPageSet, self).__init__(
135 archive_data_file='data/key_mobile_sites_smooth.json',
136 cloud_storage_bucket=story.PARTNER_BUCKET)
139 # Add pages with predefined classes that contain custom navigation logic.
140 predefined_page_classes = [
141 key_mobile_sites_pages.CapitolVolkswagenPage,
142 key_mobile_sites_pages.TheVergeArticlePage,
143 key_mobile_sites_pages.CnnArticlePage,
144 key_mobile_sites_pages.FacebookPage,
145 key_mobile_sites_pages.YoutubeMobilePage,
146 key_mobile_sites_pages.YahooAnswersPage,
147 key_mobile_sites_pages.GoogleNewsMobilePage,
149 for page_class in predefined_page_classes:
150 self.AddStory(
151 _CreatePageClassWithSmoothInteractions(page_class)(self))
153 self.AddStory(
154 _CreatePageClassWithSmoothInteractions(LinkedInSmoothPage)(self))
155 self.AddStory(WowwikiSmoothPage(self))
157 # Add pages with custom page interaction logic.
159 # Page behaves non-deterministically, replaced with test version for now.
160 # self.AddStory(GroupClonedSmoothPage(self))
161 # mean_input_event_latency cannot be tracked correctly for
162 # GroupClonedListImagesPage.
163 # See crbug.com/409086.
164 # self.AddStory(GroupClonedListImagesSmoothPage(self))
165 self.AddStory(GoogleNewsMobile2SmoothPage(self))
166 self.AddStory(AmazonNicolasCageSmoothPage(self))
168 # Add pages with custom labels.
170 # Why: Top news site.
171 self.AddStory(KeyMobileSitesSmoothPage(
172 url='http://nytimes.com/', page_set=self, labels=['fastpath']))
174 # Why: Image-heavy site.
175 self.AddStory(KeyMobileSitesSmoothPage(
176 url='http://cuteoverload.com', page_set=self, labels=['fastpath']))
178 # Why: #11 (Alexa global), google property; some blogger layouts
179 # have infinite scroll but more interesting.
180 self.AddStory(KeyMobileSitesSmoothPage(
181 url='http://googlewebmastercentral.blogspot.com/',
182 page_set=self, name='Blogger'))
184 # Why: #18 (Alexa global), Picked an interesting post """
185 self.AddStory(KeyMobileSitesSmoothPage(
186 # pylint: disable=line-too-long
187 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
188 page_set=self,
189 name='Wordpress'))
191 # Why: #6 (Alexa) most visited worldwide, picked an interesting page
192 self.AddStory(KeyMobileSitesSmoothPage(
193 url='http://en.wikipedia.org/wiki/Wikipedia',
194 page_set=self,
195 name='Wikipedia (1 tab)'))
197 # Why: Wikipedia page with a delayed scroll start
198 self.AddStory(KeyMobileSitesSmoothPage(
199 url='http://en.wikipedia.org/wiki/Wikipedia',
200 page_set=self,
201 name='Wikipedia (1 tab) - delayed scroll start',
202 action_on_load_complete=True))
204 # Why: #8 (Alexa global), picked an interesting page
205 # Forbidden (Rate Limit Exceeded)
206 # self.AddStory(KeyMobileSitesSmoothPage(
207 # url='http://twitter.com/katyperry', page_set=self, name='Twitter'))
209 # Why: #37 (Alexa global) """
210 self.AddStory(KeyMobileSitesSmoothPage(
211 url='http://pinterest.com',
212 page_set=self,
213 name='Pinterest'))
215 # Why: #1 sports.
216 # Fails often; crbug.com/249722'
217 # self.AddStory(KeyMobileSitesSmoothPage(
218 # url='http://espn.go.com', page_set=self, name='ESPN'))
219 # Why: crbug.com/231413
220 # Doesn't scroll; crbug.com/249736
221 # self.AddStory(KeyMobileSitesSmoothPage(
222 # url='http://forecast.io', page_set=self))
223 # Why: crbug.com/169827
224 self.AddStory(KeyMobileSitesSmoothPage(
225 url='http://slashdot.org/', page_set=self, labels=['fastpath']))
227 # Why: #5 Alexa news """
229 self.AddStory(KeyMobileSitesSmoothPage(
230 url='http://www.reddit.com/r/programming/comments/1g96ve',
231 page_set=self, labels=['fastpath']))
233 # Why: Problematic use of fixed position elements """
234 self.AddStory(KeyMobileSitesSmoothPage(
235 url='http://www.boingboing.net', page_set=self, labels=['fastpath']))
237 # Add simple pages with no custom navigation logic or labels.
238 urls_list = [
239 # Why: Social; top Google property; Public profile; infinite scrolls.
240 # pylint: disable=line-too-long
241 'https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
242 # Why: crbug.com/242544
243 ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
244 'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
245 'program/'),
246 # Why: crbug.com/149958
247 'http://gsp.ro',
248 # Why: Top tech blog
249 'http://theverge.com',
250 # Why: Top tech site
251 'http://digg.com',
252 # Why: Top Google property; a Google tab is often open
253 'https://www.google.com/#hl=en&q=barack+obama',
254 # Why: #1 news worldwide (Alexa global)
255 'http://news.yahoo.com',
256 # Why: #2 news worldwide
257 'http://www.cnn.com',
258 # Why: #1 commerce website by time spent by users in US
259 'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
260 # Why: #1 Alexa recreation
261 # pylint: disable=line-too-long
262 'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
263 # Why: Top tech blog
264 'http://techcrunch.com',
265 # Why: #6 Alexa sports
266 'http://mlb.com/',
267 # Why: #14 Alexa California
268 'http://www.sfgate.com/',
269 # Why: Non-latin character set
270 'http://worldjournal.com/',
271 # Why: #15 Alexa news
272 'http://online.wsj.com/home-page',
273 # Why: Image-heavy mobile site
274 'http://www.deviantart.com/',
275 # Why: Top search engine
276 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
277 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
278 # Why: Top search engine
279 'http://www.bing.com/search?q=sloths',
280 # Why: Good example of poor initial scrolling
281 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans'
284 for url in urls_list:
285 self.AddStory(KeyMobileSitesSmoothPage(url, self))