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 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module
10 class KeyMobileSitesPage(page_module.Page):
12 def __init__(self, url, page_set, name=''):
13 super(KeyMobileSitesPage, self).__init__(url=url, page_set=page_set,
15 self.credentials_path = 'data/credentials.json'
16 self.user_agent_type = 'mobile'
17 self.archive_data_file = 'data/key_mobile_sites.json'
19 def RunSmoothness(self, action_runner):
20 action_runner.RunAction(ScrollAction())
22 def RunRepaint(self, action_runner):
23 action_runner.RunAction(RepaintContinuouslyAction({'seconds': 5}))
26 class Page1(KeyMobileSitesPage):
28 """ Why: Top news site """
30 def __init__(self, page_set):
31 super(Page1, self).__init__(
32 url='http://nytimes.com/',
38 class Page2(KeyMobileSitesPage):
40 """ Why: Typical mobile business site """
42 def __init__(self, page_set):
43 super(Page2, self).__init__(
44 url=('http://iphone.capitolvolkswagen.com/index.htm'
45 '#new-inventory_p_2Fsb-new_p_2Ehtm_p_3Freset_p_3DInventoryListing'),
48 def RunNavigateSteps(self, action_runner):
49 action_runner.RunAction(NavigateAction())
50 action_runner.RunAction(WaitAction(
53 'condition': 'element'
55 action_runner.RunAction(WaitAction(
57 'javascript': 'document.body.scrollHeight > 2560'
61 class Page3(KeyMobileSitesPage):
63 """ Why: Image-heavy site """
65 def __init__(self, page_set):
66 super(Page3, self).__init__(
67 url='http://cuteoverload.com',
73 class Page4(KeyMobileSitesPage):
75 """ Why: Top tech blog """
77 def __init__(self, page_set):
78 super(Page4, self).__init__(
79 # pylint: disable=C0301
80 url='http://www.theverge.com/2012/10/28/3568746/amazon-7-inch-fire-hd-ipad-mini-ad-ballsy',
83 def RunNavigateSteps(self, action_runner):
84 action_runner.RunAction(NavigateAction())
85 action_runner.RunAction(WaitAction(
87 'javascript': ('window.Chorus !== undefined &&'
88 'window.Chorus.Comments !== undefined &&'
89 'window.Chorus.Comments.Json !== undefined &&'
90 '(window.Chorus.Comments.loaded ||'
91 ' window.Chorus.Comments.Json.load_comments())')
95 class Page5(KeyMobileSitesPage):
97 """ Why: Top news site """
99 def __init__(self, page_set):
100 super(Page5, self).__init__(
101 # pylint: disable=C0301
102 url='http://www.cnn.com/2012/10/03/politics/michelle-obama-debate/index.html',
105 def RunNavigateSteps(self, action_runner):
106 action_runner.RunAction(NavigateAction())
107 action_runner.RunAction(WaitAction({'seconds': 8}))
110 class Page6(KeyMobileSitesPage):
112 """ Why: Social; top Google property; Public profile; infinite scrolls """
114 def __init__(self, page_set):
115 super(Page6, self).__init__(
116 # pylint: disable=C0301
117 url='https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
120 def RunSmoothness(self, action_runner):
121 action_runner.RunAction(ScrollAction({'scroll_is_infinite': True}))
124 class Page7(KeyMobileSitesPage):
126 """ Why: #1 (Alexa global) """
128 def __init__(self, page_set):
129 super(Page7, self).__init__(
130 url='https://facebook.com/barackobama',
133 def RunNavigateSteps(self, action_runner):
134 action_runner.RunAction(NavigateAction())
135 action_runner.RunAction(WaitAction(
137 'javascript': ('document.getElementById("u_0_c") !== null &&'
138 'document.body.scrollHeight > window.innerHeight')
142 class Page8(KeyMobileSitesPage):
144 """ Why: #3 (Alexa global) """
146 def __init__(self, page_set):
147 super(Page8, self).__init__(
148 url='http://m.youtube.com/watch?v=9hBpF_Zj4OA',
151 def RunNavigateSteps(self, action_runner):
152 action_runner.RunAction(NavigateAction())
153 action_runner.RunAction(WaitAction(
155 'javascript': 'document.getElementById("paginatortarget") !== null'
159 class Page9(KeyMobileSitesPage):
162 Why: #11 (Alexa global), google property; some blogger layouts have infinite
163 scroll but more interesting
166 def __init__(self, page_set):
167 super(Page9, self).__init__(
168 url='http://googlewebmastercentral.blogspot.com/',
173 class Page10(KeyMobileSitesPage):
175 """ Why: #18 (Alexa global), Picked an interesting post """
177 def __init__(self, page_set):
178 super(Page10, self).__init__(
179 # pylint: disable=C0301
180 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
185 class Page11(KeyMobileSitesPage):
187 """ Why: #12 (Alexa global),Public profile """
189 def __init__(self, page_set):
190 super(Page11, self).__init__(
191 url='https://www.linkedin.com/in/linustorvalds',
195 def RunNavigateSteps(self, action_runner):
196 action_runner.RunAction(NavigateAction())
197 action_runner.RunAction(WaitAction(
200 'document.getElementById("profile-view-scroller") !== null'
204 class Page12(KeyMobileSitesPage):
206 """ Why: #6 (Alexa) most visited worldwide, picked an interesting page """
208 def __init__(self, page_set):
209 super(Page12, self).__init__(
210 url='http://en.wikipedia.org/wiki/Wikipedia',
212 name='Wikipedia (1 tab)')
215 class Page13(KeyMobileSitesPage):
217 """ Why: #8 (Alexa global), picked an interesting page """
219 def __init__(self, page_set):
220 super(Page13, self).__init__(
221 url='http://twitter.com/katyperry',
224 self.disabled = 'Forbidden (Rate Limit Exceeded)'
227 class Page14(KeyMobileSitesPage):
229 """ Why: #37 (Alexa global) """
231 def __init__(self, page_set):
232 super(Page14, self).__init__(
233 url='http://pinterest.com',
238 class Page15(KeyMobileSitesPage):
240 """ Why: #1 sports """
242 def __init__(self, page_set):
243 super(Page15, self).__init__(
244 url='http://espn.go.com',
247 self.disabled = 'Fails often; crbug.com/249722'
250 class Page16(KeyMobileSitesPage):
252 """ Why: #1 Alexa reference """
254 def __init__(self, page_set):
255 super(Page16, self).__init__(
256 # pylint: disable=C0301
257 url='http://answers.yahoo.com/question/index?qid=20110117024343AAopj8f',
260 def RunNavigateSteps(self, action_runner):
261 action_runner.RunAction(NavigateAction())
262 action_runner.RunAction(WaitAction(
264 'text': 'Other Answers (1 - 20 of 149)',
265 'condition': 'element'
267 action_runner.RunAction(ClickElementAction(
269 'text': 'Other Answers (1 - 20 of 149)'
273 class Page17(KeyMobileSitesPage):
275 """ Why: productivity, top google properties """
277 def __init__(self, page_set):
278 super(Page17, self).__init__(
279 url='https://mail.google.com/mail/',
282 self.credentials = 'google'
284 def RunNavigateSteps(self, action_runner):
285 action_runner.RunAction(NavigateAction())
286 action_runner.RunAction(WaitAction(
288 'javascript': 'document.getElementById("og_user_warning") !== null'
290 action_runner.RunAction(WaitAction(
292 'javascript': 'document.getElementById("og_user_warning") === null'
295 def RunSmoothness(self, action_runner):
296 action_runner.RunAction(ScrollAction(
298 'scrollable_element_function':
299 ('function(callback) {'
300 'callback(document.getElementById("views")'
301 '.childNodes[1].firstChild); }')
303 action_runner.RunAction(ScrollAction(
305 'scrollable_element_function':
306 ('function(callback) { '
307 'callback(document.getElementById("views")'
308 '.childNodes[1].firstChild); }')
312 class Page18(KeyMobileSitesPage):
314 """ Why: crbug.com/169827 """
316 def __init__(self, page_set):
317 super(Page18, self).__init__(
318 url='http://slashdot.org/',
324 class Page19(KeyMobileSitesPage):
326 """ Why: #5 Alexa news """
328 def __init__(self, page_set):
329 super(Page19, self).__init__(
330 url='http://www.reddit.com/r/programming/comments/1g96ve',
336 class Page20(KeyMobileSitesPage):
338 """ Why: Problematic use of fixed position elements """
340 def __init__(self, page_set):
341 super(Page20, self).__init__(
342 url='http://www.boingboing.net',
348 class Page21(KeyMobileSitesPage):
350 """ Why: crbug.com/172906 """
352 def __init__(self, page_set):
353 super(Page21, self).__init__(
354 url='http://groupcloned.com',
357 self.disabled = ('Page behaves non-deterministically, replaced with test'
360 def RunNavigateSteps(self, action_runner):
361 action_runner.RunAction(NavigateAction())
362 action_runner.RunAction(WaitAction({'seconds': 5}))
363 action_runner.RunAction(WaitAction(
366 document.getElementById("element-19") !== null &&
367 document.getElementById("element-19").contentDocument
368 .getElementById("element-22") !== null &&
369 document.getElementById("element-19").contentDocument
370 .getElementsByClassName(
371 "container list-item gc-list-item stretched").length !== 0'''
374 def RunSmoothness(self, action_runner):
375 action_runner.RunAction(ScrollAction(
377 'scroll_distance_function': '''
379 return Math.max(0, 1250 + document.getElementById("element-19")
381 .getElementById("element-22")
382 .getBoundingClientRect().top);
384 'scroll_requires_touch': True
388 class Page22(KeyMobileSitesPage):
390 """ Why: crbug.com/172906 """
392 def __init__(self, page_set):
393 super(Page22, self).__init__(
394 url='http://groupcloned.com/test/list-images-variable/index.html',
397 def RunNavigateSteps(self, action_runner):
398 action_runner.RunAction(NavigateAction())
399 action_runner.RunAction(WaitAction(
401 'javascript': 'document.getElementById("element-5") !== null'
404 def RunSmoothness(self, action_runner):
405 action_runner.RunAction(ScrollAction(
407 'scroll_distance_function': '''
409 return Math.max(0, 1250 +
410 document.getElementById("element-5").getBoundingClientRect().top);
412 'scroll_requires_touch': True
416 class Page23(KeyMobileSitesPage):
418 """ Why: crbug.com/231413 """
420 def __init__(self, page_set):
421 super(Page23, self).__init__(
422 url='http://forecast.io',
425 self.disabled = u"Doesn't scroll; crbug.com/249736"
428 class Page24(KeyMobileSitesPage):
430 """ Why: Google News: accelerated scrolling version """
432 def __init__(self, page_set):
433 super(Page24, self).__init__(
434 url='http://mobile-news.sandbox.google.com/news/pt1',
437 def RunNavigateSteps(self, action_runner):
438 action_runner.RunAction(NavigateAction())
439 action_runner.RunAction(WaitAction(
441 'javascript': ('typeof NEWS_telemetryReady !== "undefined" && '
442 'NEWS_telemetryReady == true')
446 class Page25(KeyMobileSitesPage):
449 Why: Google News: this iOS version is slower than accelerated scrolling
452 def __init__(self, page_set):
453 super(Page25, self).__init__(
454 url='http://mobile-news.sandbox.google.com/news/pt0',
457 def RunNavigateSteps(self, action_runner):
458 action_runner.RunAction(NavigateAction())
459 action_runner.RunAction(WaitAction(
461 'javascript': 'document.getElementById(":h") != null'
463 action_runner.RunAction(WaitAction(
468 def RunSmoothness(self, action_runner):
469 action_runner.RunAction(ScrollAction(
471 'scroll_requires_touch': True,
472 'scrollable_element_function': '''
474 callback(document.getElementById(':5'));
476 'scroll_distance_function': '''
478 return Math.max(0, 2500 +
479 document.getElementById(':h').getBoundingClientRect().top);
484 class Page26(KeyMobileSitesPage):
487 Why: #1 world commerce website by visits; #3 commerce in the US by time spent
490 def __init__(self, page_set):
491 super(Page26, self).__init__(
492 url='http://www.amazon.com/gp/aw/s/ref=is_box_?k=nicolas+cage',
495 def RunSmoothness(self, action_runner):
496 action_runner.RunAction(ScrollAction(
498 'scrollable_element_function': '''
500 callback(document.getElementById('search'));
502 'scroll_distance_function': '''
504 return document.body.scrollHeight - window.innerHeight;
509 class KeyMobileSitesPageSet(page_set_module.PageSet):
511 """ Key mobile sites """
514 super(KeyMobileSitesPageSet, self).__init__(
515 credentials_path='data/credentials.json',
516 user_agent_type='mobile',
517 archive_data_file='data/key_mobile_sites.json')
519 self.AddPage(Page1(self))
520 self.AddPage(Page2(self))
521 self.AddPage(Page3(self))
522 self.AddPage(Page4(self))
523 self.AddPage(Page5(self))
524 self.AddPage(Page6(self))
525 self.AddPage(Page7(self))
526 self.AddPage(Page8(self))
527 self.AddPage(Page9(self))
528 self.AddPage(Page10(self))
529 self.AddPage(Page11(self))
530 self.AddPage(Page12(self))
531 # self.AddPage(Page13(self))
532 self.AddPage(Page14(self))
533 # self.AddPage(Page15(self))
534 self.AddPage(Page16(self))
535 self.AddPage(Page17(self))
536 self.AddPage(Page18(self))
537 self.AddPage(Page19(self))
538 self.AddPage(Page20(self))
539 self.AddPage(Page21(self))
540 self.AddPage(Page22(self))
541 # self.AddPage(Page23(self))
542 self.AddPage(Page24(self))
543 self.AddPage(Page25(self))
544 self.AddPage(Page26(self))
547 # Why: crbug.com/242544
548 ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
549 'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
551 # Why: crbug.com/149958
554 'http://theverge.com',
557 # Why: Top Google property; a Google tab is often open
558 'https://www.google.com/#hl=en&q=barack+obama',
559 # Why: #1 news worldwide (Alexa global)
560 'http://news.yahoo.com',
561 # Why: #2 news worldwide
562 'http://www.cnn.com',
563 # Why: #1 commerce website by time spent by users in US
564 'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
565 # Why: #1 Alexa recreation
566 # pylint: disable=C0301
567 'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
568 # Why: #1 Alexa sports
569 'http://sports.yahoo.com/',
571 'http://techcrunch.com',
572 # Why: #6 Alexa sports
574 # Why: #14 Alexa California
575 'http://www.sfgate.com/',
576 # Why: Non-latin character set
577 'http://worldjournal.com/',
579 'http://www.wowwiki.com/World_of_Warcraft:_Mists_of_Pandaria',
580 # Why: #15 Alexa news
581 'http://online.wsj.com/home-page',
582 # Why: Image-heavy mobile site
583 'http://www.deviantart.com/',
584 # Why: Top search engine
585 ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
586 'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
587 # Why: Top search engine
588 'http://www.bing.com/search?q=sloths'
591 for url in urls_list:
592 self.AddPage(KeyMobileSitesPage(url, self))