Home | History | Annotate | Download | only in page_sets
      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
      8 
      9 
     10 class KeyMobileSitesPage(page_module.Page):
     11 
     12   def __init__(self, url, page_set, name=''):
     13     super(KeyMobileSitesPage, self).__init__(url=url, page_set=page_set,
     14                                              name=name)
     15     self.credentials_path = 'data/credentials.json'
     16     self.user_agent_type = 'mobile'
     17     self.archive_data_file = 'data/key_mobile_sites.json'
     18 
     19   def RunSmoothness(self, action_runner):
     20     action_runner.RunAction(ScrollAction())
     21 
     22   def RunRepaint(self, action_runner):
     23     action_runner.RunAction(RepaintContinuouslyAction({'seconds': 5}))
     24 
     25 
     26 class Page1(KeyMobileSitesPage):
     27 
     28   """ Why: Top news site """
     29 
     30   def __init__(self, page_set):
     31     super(Page1, self).__init__(
     32       url='http://nytimes.com/',
     33       page_set=page_set)
     34 
     35     self.fastpath = True
     36 
     37 
     38 class Page2(KeyMobileSitesPage):
     39 
     40   """ Why: Typical mobile business site """
     41 
     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'),
     46       page_set=page_set)
     47 
     48   def RunNavigateSteps(self, action_runner):
     49     action_runner.NavigateToPage(self)
     50     action_runner.WaitForElement(text='Next 35')
     51     action_runner.WaitForJavaScriptCondition(
     52         'document.body.scrollHeight > 2560')
     53 
     54 
     55 class Page3(KeyMobileSitesPage):
     56 
     57   """ Why: Image-heavy site """
     58 
     59   def __init__(self, page_set):
     60     super(Page3, self).__init__(
     61       url='http://cuteoverload.com',
     62       page_set=page_set)
     63 
     64     self.fastpath = True
     65 
     66 
     67 class Page4(KeyMobileSitesPage):
     68 
     69   """ Why: Top tech blog """
     70 
     71   def __init__(self, page_set):
     72     super(Page4, self).__init__(
     73       # pylint: disable=C0301
     74       url='http://www.theverge.com/2012/10/28/3568746/amazon-7-inch-fire-hd-ipad-mini-ad-ballsy',
     75       page_set=page_set)
     76 
     77   def RunNavigateSteps(self, action_runner):
     78     action_runner.NavigateToPage(self)
     79     action_runner.WaitForJavaScriptCondition(
     80         'window.Chorus !== undefined &&'
     81         'window.Chorus.Comments !== undefined &&'
     82         'window.Chorus.Comments.Json !== undefined &&'
     83         '(window.Chorus.Comments.loaded ||'
     84         ' window.Chorus.Comments.Json.load_comments())')
     85 
     86 
     87 class Page5(KeyMobileSitesPage):
     88 
     89   """ Why: Top news site """
     90 
     91   def __init__(self, page_set):
     92     super(Page5, self).__init__(
     93       # pylint: disable=C0301
     94       url='http://www.cnn.com/2012/10/03/politics/michelle-obama-debate/index.html',
     95       page_set=page_set)
     96 
     97   def RunNavigateSteps(self, action_runner):
     98     action_runner.NavigateToPage(self)
     99     action_runner.Wait(8)
    100 
    101 
    102 class Page6(KeyMobileSitesPage):
    103 
    104   """ Why: Social; top Google property; Public profile; infinite scrolls """
    105 
    106   def __init__(self, page_set):
    107     super(Page6, self).__init__(
    108       # pylint: disable=C0301
    109       url='https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
    110       page_set=page_set)
    111 
    112   def RunSmoothness(self, action_runner):
    113     action_runner.RunAction(ScrollAction({'scroll_is_infinite': True}))
    114 
    115 
    116 class Page7(KeyMobileSitesPage):
    117 
    118   """ Why: #1 (Alexa global) """
    119 
    120   def __init__(self, page_set):
    121     super(Page7, self).__init__(
    122       url='https://facebook.com/barackobama',
    123       page_set=page_set)
    124 
    125   def RunNavigateSteps(self, action_runner):
    126     action_runner.NavigateToPage(self)
    127     action_runner.WaitForJavaScriptCondition(
    128         'document.getElementById("u_0_c") !== null &&'
    129         'document.body.scrollHeight > window.innerHeight')
    130 
    131 
    132 class Page8(KeyMobileSitesPage):
    133 
    134   """ Why: #3 (Alexa global) """
    135 
    136   def __init__(self, page_set):
    137     super(Page8, self).__init__(
    138       url='http://m.youtube.com/watch?v=9hBpF_Zj4OA',
    139       page_set=page_set)
    140 
    141   def RunNavigateSteps(self, action_runner):
    142     action_runner.NavigateToPage(self)
    143     action_runner.WaitForJavaScriptCondition(
    144         'document.getElementById("paginatortarget") !== null')
    145 
    146 
    147 class Page9(KeyMobileSitesPage):
    148 
    149   """
    150   Why: #11 (Alexa global), google property; some blogger layouts have infinite
    151   scroll but more interesting
    152   """
    153 
    154   def __init__(self, page_set):
    155     super(Page9, self).__init__(
    156       url='http://googlewebmastercentral.blogspot.com/',
    157       page_set=page_set,
    158       name='Blogger')
    159 
    160 
    161 class Page10(KeyMobileSitesPage):
    162 
    163   """ Why: #18 (Alexa global), Picked an interesting post """
    164 
    165   def __init__(self, page_set):
    166     super(Page10, self).__init__(
    167       # pylint: disable=C0301
    168       url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
    169       page_set=page_set,
    170       name='Wordpress')
    171 
    172 
    173 class Page11(KeyMobileSitesPage):
    174 
    175   """ Why: #12 (Alexa global),Public profile """
    176 
    177   def __init__(self, page_set):
    178     super(Page11, self).__init__(
    179       url='https://www.linkedin.com/in/linustorvalds',
    180       page_set=page_set,
    181       name='LinkedIn')
    182 
    183   def RunNavigateSteps(self, action_runner):
    184     action_runner.NavigateToPage(self)
    185     action_runner.WaitForJavaScriptCondition(
    186         'document.getElementById("profile-view-scroller") !== null')
    187 
    188 
    189 class Page12(KeyMobileSitesPage):
    190 
    191   """ Why: #6 (Alexa) most visited worldwide, picked an interesting page """
    192 
    193   def __init__(self, page_set):
    194     super(Page12, self).__init__(
    195       url='http://en.wikipedia.org/wiki/Wikipedia',
    196       page_set=page_set,
    197       name='Wikipedia (1 tab)')
    198 
    199 
    200 class Page13(KeyMobileSitesPage):
    201 
    202   """ Why: #8 (Alexa global), picked an interesting page """
    203 
    204   def __init__(self, page_set):
    205     super(Page13, self).__init__(
    206       url='http://twitter.com/katyperry',
    207       page_set=page_set,
    208       name='Twitter')
    209     self.disabled = 'Forbidden (Rate Limit Exceeded)'
    210 
    211 
    212 class Page14(KeyMobileSitesPage):
    213 
    214   """ Why: #37 (Alexa global) """
    215 
    216   def __init__(self, page_set):
    217     super(Page14, self).__init__(
    218       url='http://pinterest.com',
    219       page_set=page_set,
    220       name='Pinterest')
    221 
    222 
    223 class Page15(KeyMobileSitesPage):
    224 
    225   """ Why: #1 sports """
    226 
    227   def __init__(self, page_set):
    228     super(Page15, self).__init__(
    229       url='http://espn.go.com',
    230       page_set=page_set,
    231       name='ESPN')
    232     self.disabled = 'Fails often; crbug.com/249722'
    233 
    234 
    235 class Page16(KeyMobileSitesPage):
    236 
    237   """ Why: #1 Alexa reference """
    238 
    239   def __init__(self, page_set):
    240     super(Page16, self).__init__(
    241       # pylint: disable=C0301
    242       url='http://answers.yahoo.com/question/index?qid=20110117024343AAopj8f',
    243       page_set=page_set)
    244 
    245   def RunNavigateSteps(self, action_runner):
    246     action_runner.NavigateToPage(self)
    247     action_runner.WaitForElement(text='Other Answers (1 - 20 of 149)')
    248     action_runner.ClickElement(text='Other Answers (1 - 20 of 149)')
    249 
    250 
    251 class Page17(KeyMobileSitesPage):
    252 
    253   """ Why: productivity, top google properties """
    254 
    255   def __init__(self, page_set):
    256     super(Page17, self).__init__(
    257       url='https://mail.google.com/mail/',
    258       page_set=page_set)
    259 
    260     self.credentials = 'google'
    261 
    262   def RunNavigateSteps(self, action_runner):
    263     action_runner.NavigateToPage(self)
    264     action_runner.WaitForJavaScriptCondition(
    265         'document.getElementById("og_user_warning") !== null')
    266     action_runner.WaitForJavaScriptCondition(
    267         'document.getElementById("og_user_warning") === null')
    268 
    269   def RunSmoothness(self, action_runner):
    270     action_runner.RunAction(ScrollAction(
    271       {
    272         'scrollable_element_function':
    273           ('function(callback) {'
    274            'callback(document.getElementById("views")'
    275            '.childNodes[1].firstChild); }')
    276       }))
    277     action_runner.RunAction(ScrollAction(
    278       {
    279         'scrollable_element_function':
    280           ('function(callback) { '
    281            'callback(document.getElementById("views")'
    282            '.childNodes[1].firstChild); }')
    283       }))
    284 
    285 
    286 class Page18(KeyMobileSitesPage):
    287 
    288   """ Why: crbug.com/169827 """
    289 
    290   def __init__(self, page_set):
    291     super(Page18, self).__init__(
    292       url='http://slashdot.org/',
    293       page_set=page_set)
    294 
    295     self.fastpath = True
    296 
    297 
    298 class Page19(KeyMobileSitesPage):
    299 
    300   """ Why: #5 Alexa news """
    301 
    302   def __init__(self, page_set):
    303     super(Page19, self).__init__(
    304       url='http://www.reddit.com/r/programming/comments/1g96ve',
    305       page_set=page_set)
    306 
    307     self.fastpath = True
    308 
    309 
    310 class Page20(KeyMobileSitesPage):
    311 
    312   """ Why: Problematic use of fixed position elements """
    313 
    314   def __init__(self, page_set):
    315     super(Page20, self).__init__(
    316       url='http://www.boingboing.net',
    317       page_set=page_set)
    318 
    319     self.fastpath = True
    320 
    321 
    322 class Page21(KeyMobileSitesPage):
    323 
    324   """ Why: crbug.com/172906 """
    325 
    326   def __init__(self, page_set):
    327     super(Page21, self).__init__(
    328       url='http://groupcloned.com',
    329       page_set=page_set)
    330 
    331     self.disabled = ('Page behaves non-deterministically, replaced with test'
    332                      'version for now')
    333 
    334   def RunNavigateSteps(self, action_runner):
    335     action_runner.NavigateToPage(self)
    336     action_runner.Wait(5)
    337     action_runner.WaitForJavaScriptCondition('''
    338         document.getElementById("element-19") !== null &&
    339         document.getElementById("element-19").contentDocument
    340           .getElementById("element-22") !== null &&
    341         document.getElementById("element-19").contentDocument
    342           .getElementsByClassName(
    343               "container list-item gc-list-item stretched").length !== 0''')
    344 
    345   def RunSmoothness(self, action_runner):
    346     action_runner.RunAction(ScrollAction(
    347       {
    348         'scroll_distance_function': '''
    349           function() {
    350             return Math.max(0, 1250 + document.getElementById("element-19")
    351                                               .contentDocument
    352                                               .getElementById("element-22")
    353                                               .getBoundingClientRect().top);
    354           }''',
    355         'scroll_requires_touch': True
    356       }))
    357 
    358 
    359 class Page22(KeyMobileSitesPage):
    360 
    361   """ Why: crbug.com/172906 """
    362 
    363   def __init__(self, page_set):
    364     super(Page22, self).__init__(
    365       url='http://groupcloned.com/test/list-images-variable/index.html',
    366       page_set=page_set)
    367 
    368   def RunNavigateSteps(self, action_runner):
    369     action_runner.NavigateToPage(self)
    370     action_runner.WaitForJavaScriptCondition(
    371         'document.getElementById("element-5") !== null')
    372 
    373   def RunSmoothness(self, action_runner):
    374     action_runner.RunAction(ScrollAction(
    375       {
    376         'scroll_distance_function': '''
    377           function() {
    378             return Math.max(0, 1250 +
    379               document.getElementById("element-5").getBoundingClientRect().top);
    380           }''',
    381         'scroll_requires_touch': True
    382       }))
    383 
    384 
    385 class Page23(KeyMobileSitesPage):
    386 
    387   """ Why: crbug.com/231413 """
    388 
    389   def __init__(self, page_set):
    390     super(Page23, self).__init__(
    391       url='http://forecast.io',
    392       page_set=page_set)
    393 
    394     self.disabled = u"Doesn't scroll; crbug.com/249736"
    395 
    396 
    397 class Page24(KeyMobileSitesPage):
    398 
    399   """ Why: Google News: accelerated scrolling version """
    400 
    401   def __init__(self, page_set):
    402     super(Page24, self).__init__(
    403       url='http://mobile-news.sandbox.google.com/news/pt1',
    404       page_set=page_set)
    405 
    406   def RunNavigateSteps(self, action_runner):
    407     action_runner.NavigateToPage(self)
    408     action_runner.WaitForJavaScriptCondition(
    409         'typeof NEWS_telemetryReady !== "undefined" && '
    410         'NEWS_telemetryReady == true')
    411 
    412 
    413 class Page25(KeyMobileSitesPage):
    414 
    415   """
    416   Why: Google News: this iOS version is slower than accelerated scrolling
    417   """
    418 
    419   def __init__(self, page_set):
    420     super(Page25, self).__init__(
    421       url='http://mobile-news.sandbox.google.com/news/pt0',
    422       page_set=page_set)
    423 
    424   def RunNavigateSteps(self, action_runner):
    425     action_runner.NavigateToPage(self)
    426     action_runner.WaitForJavaScriptCondition(
    427         'document.getElementById(":h") != null')
    428     action_runner.Wait(1)
    429 
    430   def RunSmoothness(self, action_runner):
    431     action_runner.RunAction(ScrollAction(
    432       {
    433         'scroll_requires_touch': True,
    434         'scrollable_element_function': '''
    435           function(callback) {
    436             callback(document.getElementById(':5'));
    437           }''',
    438         'scroll_distance_function': '''
    439           function() {
    440             return Math.max(0, 2500 +
    441               document.getElementById(':h').getBoundingClientRect().top);
    442           }'''
    443       }))
    444 
    445 
    446 class Page26(KeyMobileSitesPage):
    447 
    448   """
    449   Why: #1 world commerce website by visits; #3 commerce in the US by time spent
    450   """
    451 
    452   def __init__(self, page_set):
    453     super(Page26, self).__init__(
    454       url='http://www.amazon.com/gp/aw/s/ref=is_box_?k=nicolas+cage',
    455       page_set=page_set)
    456 
    457   def RunSmoothness(self, action_runner):
    458     action_runner.RunAction(ScrollAction(
    459       {
    460         'scrollable_element_function': '''
    461           function(callback) {
    462             callback(document.getElementById('search'));
    463           }''',
    464         'scroll_distance_function': '''
    465           function() {
    466             return document.body.scrollHeight - window.innerHeight;
    467           }'''
    468       }))
    469 
    470 
    471 class KeyMobileSitesPageSet(page_set_module.PageSet):
    472 
    473   """ Key mobile sites """
    474 
    475   def __init__(self):
    476     super(KeyMobileSitesPageSet, self).__init__(
    477       credentials_path='data/credentials.json',
    478       user_agent_type='mobile',
    479       archive_data_file='data/key_mobile_sites.json',
    480       bucket=page_set_module.PARTNER_BUCKET)
    481 
    482     self.AddPage(Page1(self))
    483     self.AddPage(Page2(self))
    484     self.AddPage(Page3(self))
    485     self.AddPage(Page4(self))
    486     self.AddPage(Page5(self))
    487     self.AddPage(Page6(self))
    488     self.AddPage(Page7(self))
    489     self.AddPage(Page8(self))
    490     self.AddPage(Page9(self))
    491     self.AddPage(Page10(self))
    492     self.AddPage(Page11(self))
    493     self.AddPage(Page12(self))
    494 #    self.AddPage(Page13(self))
    495     self.AddPage(Page14(self))
    496 #    self.AddPage(Page15(self))
    497     self.AddPage(Page16(self))
    498     self.AddPage(Page17(self))
    499     self.AddPage(Page18(self))
    500     self.AddPage(Page19(self))
    501     self.AddPage(Page20(self))
    502     self.AddPage(Page21(self))
    503     self.AddPage(Page22(self))
    504 #    self.AddPage(Page23(self))
    505     self.AddPage(Page24(self))
    506     self.AddPage(Page25(self))
    507     self.AddPage(Page26(self))
    508 
    509     urls_list = [
    510       # Why: crbug.com/242544
    511       ('http://www.androidpolice.com/2012/10/03/rumor-evidence-mounts-that-an-'
    512        'lg-optimus-g-nexus-is-coming-along-with-a-nexus-phone-certification-'
    513        'program/'),
    514       # Why: crbug.com/149958
    515       'http://gsp.ro',
    516       # Why: Top tech blog
    517       'http://theverge.com',
    518       # Why: Top tech site
    519       'http://digg.com',
    520       # Why: Top Google property; a Google tab is often open
    521       'https://www.google.com/#hl=en&q=barack+obama',
    522       # Why: #1 news worldwide (Alexa global)
    523       'http://news.yahoo.com',
    524       # Why: #2 news worldwide
    525       'http://www.cnn.com',
    526       # Why: #1 commerce website by time spent by users in US
    527       'http://shop.mobileweb.ebay.com/searchresults?kw=viking+helmet',
    528       # Why: #1 Alexa recreation
    529       # pylint: disable=C0301
    530       'http://www.booking.com/searchresults.html?src=searchresults&latitude=65.0500&longitude=25.4667',
    531       # Why: #1 Alexa sports
    532       'http://sports.yahoo.com/',
    533       # Why: Top tech blog
    534       'http://techcrunch.com',
    535       # Why: #6 Alexa sports
    536       'http://mlb.com/',
    537       # Why: #14 Alexa California
    538       'http://www.sfgate.com/',
    539       # Why: Non-latin character set
    540       'http://worldjournal.com/',
    541       # Why: Mobile wiki
    542       'http://www.wowwiki.com/World_of_Warcraft:_Mists_of_Pandaria',
    543       # Why: #15 Alexa news
    544       'http://online.wsj.com/home-page',
    545       # Why: Image-heavy mobile site
    546       'http://www.deviantart.com/',
    547       # Why: Top search engine
    548       ('http://www.baidu.com/s?wd=barack+obama&rsv_bp=0&rsv_spt=3&rsv_sug3=9&'
    549        'rsv_sug=0&rsv_sug4=3824&rsv_sug1=3&inputT=4920'),
    550       # Why: Top search engine
    551       'http://www.bing.com/search?q=sloths'
    552     ]
    553 
    554     for url in urls_list:
    555       self.AddPage(KeyMobileSitesPage(url, self))
    556