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 MobileMemoryPage(page_module.Page):
     11 
     12   def __init__(self, url, page_set):
     13     super(MobileMemoryPage, self).__init__(url=url, page_set=page_set)
     14     self.credentials_path = 'data/credentials.json'
     15     self.user_agent_type = 'mobile'
     16     self.archive_data_file = 'data/mobile_memory.json'
     17 
     18 
     19 class GmailPage(MobileMemoryPage):
     20 
     21   def __init__(self, page_set):
     22     super(GmailPage, self).__init__(
     23         url='https://mail.google.com/mail/mu',
     24         page_set=page_set)
     25 
     26     self.reload_and_gc = [{'action': 'reload'},
     27                           {'action': 'wait',
     28                            'seconds': 15},
     29                           {'action': 'js_collect_garbage'}]
     30     self.credentials = 'google'
     31 
     32   def ReloadAndGc(self, action_runner):
     33     action_runner.RunAction(ReloadAction())
     34     action_runner.Wait(15)
     35     action_runner.ForceGarbageCollection()
     36 
     37   def RunStressMemory(self, action_runner):
     38     for _ in xrange(3):
     39       self.ReloadAndGc(action_runner)
     40 
     41 
     42 class GoogleSearchPage(MobileMemoryPage):
     43 
     44   """ Why: Tests usage of discardable memory """
     45 
     46   def __init__(self, page_set):
     47     super(GoogleSearchPage, self).__init__(
     48         url='https://www.google.com/search?site=&tbm=isch&q=google',
     49         page_set=page_set)
     50 
     51   def RunStressMemory(self, action_runner):
     52     action_runner.RunAction(ScrollAction())
     53     action_runner.Wait(3)
     54     action_runner.RunAction(ScrollAction())
     55     action_runner.Wait(3)
     56     action_runner.RunAction(ScrollAction())
     57     action_runner.Wait(3)
     58     action_runner.RunAction(ScrollAction())
     59     action_runner.WaitForJavaScriptCondition(
     60         'document.getElementById("rg_s").childElementCount > 300')
     61 
     62 
     63 class ScrollPage(MobileMemoryPage):
     64 
     65   def __init__(self, url, page_set):
     66     super(ScrollPage, self).__init__(url=url, page_set=page_set)
     67 
     68   def RunStressMemory(self, action_runner):
     69     action_runner.RunAction(ScrollAction())
     70 
     71 
     72 class MobileMemoryPageSet(page_set_module.PageSet):
     73 
     74   """ Mobile sites with interesting memory characteristics """
     75 
     76   def __init__(self):
     77     super(MobileMemoryPageSet, self).__init__(
     78         credentials_path='data/credentials.json',
     79         user_agent_type='mobile',
     80         archive_data_file='data/mobile_memory.json',
     81         bucket=page_set_module.PARTNER_BUCKET)
     82 
     83     self.AddPage(GmailPage(self))
     84     self.AddPage(GoogleSearchPage(self))
     85 
     86     urls_list = [
     87       # Why: Renderer process memory bloat
     88       'http://techcrunch.com',
     89       # pylint: disable=C0301
     90       'http://techcrunch.com/2014/02/17/pixel-brings-brings-old-school-video-game-art-to-life-in-your-home/',
     91       'http://techcrunch.com/2014/02/15/kickstarter-coins-2/',
     92       'http://techcrunch.com/2014/02/15/was-y-combinator-worth-it/',
     93     ]
     94 
     95     for url in urls_list:
     96       self.AddPage(ScrollPage(url, self))
     97