Fix OOP <webview> resize and autosize.
[chromium-blink-merge.git] / tools / perf / page_sets / key_mobile_sites_smooth.py
blob813740ddf52907e54283c5d389e52f6f7675e86f
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 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
187 page_set=self,
188 name='Wordpress'))
190 # Why: #6 (Alexa) most visited worldwide, picked an interesting page
191 self.AddStory(KeyMobileSitesSmoothPage(
192 url='http://en.wikipedia.org/wiki/Wikipedia',
193 page_set=self,
194 name='Wikipedia (1 tab)'))
196 # Why: Wikipedia page with a delayed scroll start
197 self.AddStory(KeyMobileSitesSmoothPage(
198 url='http://en.wikipedia.org/wiki/Wikipedia',
199 page_set=self,
200 name='Wikipedia (1 tab) - delayed scroll start',
201 action_on_load_complete=True))
203 # Why: #8 (Alexa global), picked an interesting page
204 # Forbidden (Rate Limit Exceeded)
205 # self.AddStory(KeyMobileSitesSmoothPage(
206 # url='http://twitter.com/katyperry', page_set=self, name='Twitter'))
208 # Why: #37 (Alexa global) """
209 self.AddStory(KeyMobileSitesSmoothPage(
210 url='http://pinterest.com',
211 page_set=self,
212 name='Pinterest'))
214 # Why: #1 sports.
215 # Fails often; crbug.com/249722'
216 # self.AddStory(KeyMobileSitesSmoothPage(
217 # url='http://espn.go.com', page_set=self, name='ESPN'))
218 # Why: crbug.com/231413
219 # Doesn't scroll; crbug.com/249736
220 # self.AddStory(KeyMobileSitesSmoothPage(
221 # url='http://forecast.io', page_set=self))
222 # Why: crbug.com/169827
223 self.AddStory(KeyMobileSitesSmoothPage(
224 url='http://slashdot.org/', page_set=self, labels=['fastpath']))
226 # Why: #5 Alexa news """
228 self.AddStory(KeyMobileSitesSmoothPage(
229 url='http://www.reddit.com/r/programming/comments/1g96ve',
230 page_set=self, labels=['fastpath']))
232 # Why: Problematic use of fixed position elements """
233 self.AddStory(KeyMobileSitesSmoothPage(
234 url='http://www.boingboing.net', page_set=self, labels=['fastpath']))
236 # Add simple pages with no custom navigation logic or labels.
237 urls_list = [
238 # Why: Social; top Google property; Public profile; infinite scrolls.
239 'https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
240 # Why: crbug.com/242544
241 ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
242 'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
243 'program/'),
244 # Why: crbug.com/149958
245 'http://gsp.ro',
246 # Why: Top tech blog
247 'http://theverge.com',
248 # Why: Top tech site
249 'http://digg.com',
250 # Why: Top Google property; a Google tab is often open
251 'https://www.google.com/#hl=en&q=barack+obama',
252 # Why: #1 news worldwide (Alexa global)
253 'http://news.yahoo.com',
254 # Why: #2 news worldwide
255 'http://www.cnn.com',
256 # Why: #1 commerce website by time spent by users in US
257 'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
258 # Why: #1 Alexa recreation
259 'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
260 # Why: Top tech blog
261 'http://techcrunch.com',
262 # Why: #6 Alexa sports
263 'http://mlb.com/',
264 # Why: #14 Alexa California
265 'http://www.sfgate.com/',
266 # Why: Non-latin character set
267 'http://worldjournal.com/',
268 # Why: #15 Alexa news
269 'http://online.wsj.com/home-page',
270 # Why: Image-heavy mobile site
271 'http://www.deviantart.com/',
272 # Why: Top search engine
273 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
274 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
275 # Why: Top search engine
276 'http://www.bing.com/search?q=sloths',
277 # Why: Good example of poor initial scrolling
278 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans'
281 for url in urls_list:
282 self.AddStory(KeyMobileSitesSmoothPage(url, self))