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
8 class KeyMobileSitesPage(page_module
.Page
):
10 def __init__(self
, url
, page_set
, name
='', labels
=None):
11 super(KeyMobileSitesPage
, self
).__init
__(
12 url
=url
, page_set
=page_set
, name
=name
,
13 credentials_path
='data/credentials.json', labels
=labels
)
14 self
.user_agent_type
= 'mobile'
15 self
.archive_data_file
= 'data/key_mobile_sites.json'
17 def RunSmoothness(self
, action_runner
):
18 interaction
= action_runner
.BeginGestureInteraction(
19 'ScrollAction', is_smooth
=True)
20 action_runner
.ScrollPage()
23 def RunRepaint(self
, action_runner
):
24 action_runner
.RepaintContinuously(seconds
=5)
27 class CapitolVolkswagenPage(KeyMobileSitesPage
):
29 """ Why: Typical mobile business site """
31 def __init__(self
, page_set
):
32 super(CapitolVolkswagenPage
, self
).__init
__(
33 url
=('http://iphone.capitolvolkswagen.com/index.htm'
34 '#new-inventory_p_2Fsb-new_p_2Ehtm_p_3Freset_p_3DInventoryListing'),
37 def RunNavigateSteps(self
, action_runner
):
38 action_runner
.NavigateToPage(self
)
39 action_runner
.WaitForElement(text
='Next 35')
40 action_runner
.WaitForJavaScriptCondition(
41 'document.body.scrollHeight > 2560')
45 class TheVergePage(KeyMobileSitesPage
):
47 """ Why: Top tech blog """
49 def __init__(self
, page_set
):
50 super(TheVergePage
, self
).__init
__(
51 # pylint: disable=C0301
52 url
='http://www.theverge.com/2012/10/28/3568746/amazon-7-inch-fire-hd-ipad-mini-ad-ballsy',
55 def RunNavigateSteps(self
, action_runner
):
56 action_runner
.NavigateToPage(self
)
57 action_runner
.WaitForJavaScriptCondition(
58 'window.Chorus !== undefined &&'
59 'window.Chorus.Comments !== undefined &&'
60 'window.Chorus.Comments.Json !== undefined &&'
61 '(window.Chorus.Comments.loaded ||'
62 ' window.Chorus.Comments.Json.load_comments())')
65 class CnnPage(KeyMobileSitesPage
):
67 """ Why: Top news site """
69 def __init__(self
, page_set
):
70 super(CnnPage
, self
).__init
__(
71 # pylint: disable=C0301
72 url
='http://www.cnn.com/2012/10/03/politics/michelle-obama-debate/index.html',
75 def RunNavigateSteps(self
, action_runner
):
76 action_runner
.NavigateToPage(self
)
81 class FacebookPage(KeyMobileSitesPage
):
83 """ Why: #1 (Alexa global) """
85 def __init__(self
, page_set
):
86 super(FacebookPage
, self
).__init
__(
87 url
='https://facebook.com/barackobama',
90 def RunNavigateSteps(self
, action_runner
):
91 action_runner
.NavigateToPage(self
)
92 action_runner
.WaitForJavaScriptCondition(
93 'document.getElementById("u_0_c") !== null &&'
94 'document.body.scrollHeight > window.innerHeight')
97 class YoutubeMobilePage(KeyMobileSitesPage
):
99 """ Why: #3 (Alexa global) """
101 def __init__(self
, page_set
):
102 super(YoutubeMobilePage
, self
).__init
__(
103 url
='http://m.youtube.com/watch?v=9hBpF_Zj4OA',
106 def RunNavigateSteps(self
, action_runner
):
107 action_runner
.NavigateToPage(self
)
108 action_runner
.WaitForJavaScriptCondition(
109 'document.getElementById("paginatortarget") !== null')
112 class LinkedInPage(KeyMobileSitesPage
):
114 """ Why: #12 (Alexa global),Public profile """
116 def __init__(self
, page_set
):
117 super(LinkedInPage
, self
).__init
__(
118 url
='https://www.linkedin.com/in/linustorvalds',
122 def RunNavigateSteps(self
, action_runner
):
123 action_runner
.NavigateToPage(self
)
124 action_runner
.WaitForJavaScriptCondition(
125 'document.getElementById("profile-view-scroller") !== null')
129 class YahooAnswersPage(KeyMobileSitesPage
):
131 """ Why: #1 Alexa reference """
133 def __init__(self
, page_set
):
134 super(YahooAnswersPage
, self
).__init
__(
135 # pylint: disable=C0301
136 url
='http://answers.yahoo.com/question/index?qid=20110117024343AAopj8f',
139 def RunNavigateSteps(self
, action_runner
):
140 action_runner
.NavigateToPage(self
)
141 action_runner
.WaitForElement(text
='Other Answers (1 - 20 of 149)')
142 action_runner
.ClickElement(text
='Other Answers (1 - 20 of 149)')
145 class GmailPage(KeyMobileSitesPage
):
147 """ Why: productivity, top google properties """
149 def __init__(self
, page_set
):
150 super(GmailPage
, self
).__init
__(
151 url
='https://mail.google.com/mail/',
154 self
.credentials
= 'google'
156 def RunNavigateSteps(self
, action_runner
):
157 action_runner
.NavigateToPage(self
)
158 action_runner
.WaitForJavaScriptCondition(
159 'document.getElementById("og_user_warning") !== null')
160 action_runner
.WaitForJavaScriptCondition(
161 'document.getElementById("og_user_warning") === null')
163 def RunSmoothness(self
, action_runner
):
164 interaction
= action_runner
.BeginGestureInteraction(
165 'ScrollAction', is_smooth
=True)
166 action_runner
.ScrollElement(element_function
=(
167 'document.getElementById("views").childNodes[1].firstChild'))
169 interaction
= action_runner
.BeginGestureInteraction(
170 'ScrollAction', is_smooth
=True)
171 action_runner
.ScrollElement(element_function
=(
172 'document.getElementById("views").childNodes[1].firstChild'))
178 class GroupClonedPage(KeyMobileSitesPage
):
180 """ Why: crbug.com/172906 """
182 def __init__(self
, page_set
):
183 super(GroupClonedPage
, self
).__init
__(
184 url
='http://groupcloned.com',
188 def RunNavigateSteps(self
, action_runner
):
189 action_runner
.NavigateToPage(self
)
190 action_runner
.Wait(5)
191 action_runner
.WaitForJavaScriptCondition('''
192 document.getElementById("element-19") !== null &&
193 document.getElementById("element-19").contentDocument
194 .getElementById("element-22") !== null &&
195 document.getElementById("element-19").contentDocument
196 .getElementsByClassName(
197 "container list-item gc-list-item stretched").length !== 0''')
199 def RunSmoothness(self
, action_runner
):
200 interaction
= action_runner
.BeginGestureInteraction(
201 'ScrollAction', is_smooth
=True)
202 action_runner
.ScrollPage(
204 Math.max(0, 1250 + document.getElementById("element-19")
206 .getElementById("element-22")
207 .getBoundingClientRect().top);''',
212 class GroupClonedListImagesPage(KeyMobileSitesPage
):
214 """ Why: crbug.com/172906 """
216 def __init__(self
, page_set
):
217 super(GroupClonedListImagesPage
, self
).__init
__(
218 url
='http://groupcloned.com/test/list-images-variable/index.html',
221 def RunNavigateSteps(self
, action_runner
):
222 action_runner
.NavigateToPage(self
)
223 action_runner
.WaitForJavaScriptCondition(
224 'document.getElementById("element-5") !== null')
226 def RunSmoothness(self
, action_runner
):
227 interaction
= action_runner
.BeginGestureInteraction(
228 'ScrollAction', is_smooth
=True)
229 action_runner
.ScrollPage(
232 document.getElementById("element-5")
233 .getBoundingClientRect().top);''',
239 class GoogleNewsMobilePage(KeyMobileSitesPage
):
241 """ Why: Google News: accelerated scrolling version """
243 def __init__(self
, page_set
):
244 super(GoogleNewsMobilePage
, self
).__init
__(
245 url
='http://mobile-news.sandbox.google.com/news/pt1',
248 def RunNavigateSteps(self
, action_runner
):
249 action_runner
.NavigateToPage(self
)
250 action_runner
.WaitForJavaScriptCondition(
251 'typeof NEWS_telemetryReady !== "undefined" && '
252 'NEWS_telemetryReady == true')
255 class GoogleNewsMobile2Page(KeyMobileSitesPage
):
258 Why: Google News: this iOS version is slower than accelerated scrolling
261 def __init__(self
, page_set
):
262 super(GoogleNewsMobile2Page
, self
).__init
__(
263 url
='http://mobile-news.sandbox.google.com/news/pt0',
266 def RunNavigateSteps(self
, action_runner
):
267 action_runner
.NavigateToPage(self
)
268 action_runner
.WaitForJavaScriptCondition(
269 'document.getElementById(":h") != null')
270 action_runner
.Wait(1)
272 def RunSmoothness(self
, action_runner
):
273 interaction
= action_runner
.BeginGestureInteraction(
274 'ScrollAction', is_smooth
=True)
275 action_runner
.ScrollElement(
276 element_function
='document.getElementById(":5")',
279 document.getElementById(':h').getBoundingClientRect().top)''',
284 class AmazonNicolasCagePage(KeyMobileSitesPage
):
287 Why: #1 world commerce website by visits; #3 commerce in the US by time spent
290 def __init__(self
, page_set
):
291 super(AmazonNicolasCagePage
, self
).__init
__(
292 url
='http://www.amazon.com/gp/aw/s/ref=is_box_?k=nicolas+cage',
295 def RunSmoothness(self
, action_runner
):
296 interaction
= action_runner
.BeginGestureInteraction(
297 'ScrollAction', is_smooth
=True)
298 action_runner
.ScrollElement(
300 distance_expr
='document.body.scrollHeight - window.innerHeight')
304 class KeyMobileSitesPageSet(page_set_module
.PageSet
):
306 """ Key mobile sites """
309 super(KeyMobileSitesPageSet
, self
).__init
__(
310 user_agent_type
='mobile',
311 archive_data_file
='data/key_mobile_sites.json',
312 bucket
=page_set_module
.PARTNER_BUCKET
)
315 self
.AddPage(CapitolVolkswagenPage(self
))
316 self
.AddPage(TheVergePage(self
))
317 self
.AddPage(CnnPage(self
))
318 self
.AddPage(FacebookPage(self
))
319 self
.AddPage(YoutubeMobilePage(self
))
320 self
.AddPage(LinkedInPage(self
))
321 self
.AddPage(YahooAnswersPage(self
))
322 self
.AddPage(GmailPage(self
))
323 # Page behaves non-deterministically, replaced with test version for now.
324 # self.AddPage(GroupClonedPage(self))
325 # mean_input_event_latency cannot be tracked correctly for
326 # GroupClonedListImagesPage.
327 # See crbug.com/409086.
328 # self.AddPage(GroupClonedListImagesPage(self))
329 self
.AddPage(GoogleNewsMobilePage(self
))
330 self
.AddPage(GoogleNewsMobile2Page(self
))
331 self
.AddPage(AmazonNicolasCagePage(self
))
333 # Why: Top news site.
334 self
.AddPage(KeyMobileSitesPage(
335 url
='http://nytimes.com/', page_set
=self
, labels
=['fastpath']))
337 # Why: Image-heavy site.
338 self
.AddPage(KeyMobileSitesPage(
339 url
='http://cuteoverload.com', page_set
=self
, labels
=['fastpath']))
341 # Why: #11 (Alexa global), google property; some blogger layouts
342 # have infinite scroll but more interesting.
343 self
.AddPage(KeyMobileSitesPage(
344 url
='http://googlewebmastercentral.blogspot.com/',
345 page_set
=self
, name
='Blogger'))
347 # Why: #18 (Alexa global), Picked an interesting post """
348 self
.AddPage(KeyMobileSitesPage(
349 # pylint: disable=C0301
350 url
='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
354 # Why: #6 (Alexa) most visited worldwide, picked an interesting page
355 self
.AddPage(KeyMobileSitesPage(
356 url
='http://en.wikipedia.org/wiki/Wikipedia',
358 name
='Wikipedia (1 tab)'))
361 # Why: #8 (Alexa global), picked an interesting page
362 # Forbidden (Rate Limit Exceeded)
363 # self.AddPage(KeyMobileSitesPage(
364 # url='http://twitter.com/katyperry', page_set=self, name='Twitter'))
366 # Why: #37 (Alexa global) """
367 self
.AddPage(KeyMobileSitesPage(
368 url
='http://pinterest.com',
373 # Fails often; crbug.com/249722'
374 # self.AddPage(KeyMobileSitesPage(
375 # url='http://espn.go.com', page_set=self, name='ESPN'))
376 # Why: crbug.com/231413
377 # Doesn't scroll; crbug.com/249736
378 # self.AddPage(KeyMobileSitesPage(url='http://forecast.io', page_set=self))
379 # Why: crbug.com/169827
380 self
.AddPage(KeyMobileSitesPage(
381 url
='http://slashdot.org/', page_set
=self
, labels
=['fastpath']))
383 # Why: #5 Alexa news """
385 self
.AddPage(KeyMobileSitesPage(
386 url
='http://www.reddit.com/r/programming/comments/1g96ve',
387 page_set
=self
, labels
=['fastpath']))
389 # Why: Problematic use of fixed position elements """
390 self
.AddPage(KeyMobileSitesPage(
391 url
='http://www.boingboing.net', page_set
=self
, labels
=['fastpath']))
394 # Why: Social; top Google property; Public profile; infinite scrolls.
395 # pylint: disable=C0301
396 'https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
397 # Why: crbug.com/242544
398 ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
399 'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
401 # Why: crbug.com/149958
404 'http://theverge.com',
407 # Why: Top Google property; a Google tab is often open
408 'https://www.google.com/#hl=en&q=barack+obama',
409 # Why: #1 news worldwide (Alexa global)
410 'http://news.yahoo.com',
411 # Why: #2 news worldwide
412 'http://www.cnn.com',
413 # Why: #1 commerce website by time spent by users in US
414 'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
415 # Why: #1 Alexa recreation
416 # pylint: disable=C0301
417 'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
418 # Why: #1 Alexa sports
419 'http://sports.yahoo.com/',
421 'http://techcrunch.com',
422 # Why: #6 Alexa sports
424 # Why: #14 Alexa California
425 'http://www.sfgate.com/',
426 # Why: Non-latin character set
427 'http://worldjournal.com/',
429 'http://www.wowwiki.com/World_of_Warcraft:_Mists_of_Pandaria',
430 # Why: #15 Alexa news
431 'http://online.wsj.com/home-page',
432 # Why: Image-heavy mobile site
433 'http://www.deviantart.com/',
434 # Why: Top search engine
435 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
436 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
437 # Why: Top search engine
438 'http://www.bing.com/search?q=sloths',
439 # Why: Good example of poor initial scrolling
440 'http://ftw.usatoday.com/2014/05/spelling-bee-rules-shenanigans'
443 for url
in urls_list
:
444 self
.AddPage(KeyMobileSitesPage(url
, self
))