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