[refactor] More post-NSS WebCrypto cleanups (utility functions).
[chromium-blink-merge.git] / tools / perf / page_sets / blink_memory_mobile.py
blob3c18085caf5003ccb88281b339eec0a0e13c2aee
1 # Copyright 2015 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.
5 import logging
7 from telemetry.page import page as page_module
8 from telemetry.page import shared_page_state
9 from telemetry import story
11 from page_sets.login_helpers import google_login
14 DUMP_WAIT_TIME = 3
17 class BlinkMemoryMobilePage(page_module.Page):
18 def __init__(self, url, page_set, name):
19 super(BlinkMemoryMobilePage, self).__init__(
20 url=url, page_set=page_set, name=name,
21 shared_page_state_class=shared_page_state.SharedMobilePageState,
22 credentials_path='data/credentials.json')
23 self.archive_data_file = 'data/blink_memory_mobile.json'
25 def _DumpMemory(self, action_runner, phase):
26 with action_runner.CreateInteraction(phase):
27 action_runner.Wait(DUMP_WAIT_TIME)
28 action_runner.ForceGarbageCollection()
29 action_runner.Wait(DUMP_WAIT_TIME)
30 if not action_runner.tab.browser.DumpMemory():
31 logging.error('Unable to get a memory dump for %s.', self.name)
33 def RunPageInteractions(self, action_runner):
34 action_runner.ScrollPage()
35 self._DumpMemory(action_runner, 'scrolled')
38 class TheVergePage(BlinkMemoryMobilePage):
39 COMMENT_LINK_SELECTOR = '.show_comments_link'
41 def __init__(self, page_set):
42 super(TheVergePage, self).__init__(
43 'http://www.theverge.com/2015/8/11/9133883/taylor-swift-spotify-discover-weekly-what-is-going-on',
44 page_set=page_set,
45 name='TheVerge')
47 def RunPageInteractions(self, action_runner):
48 action_runner.WaitForElement(selector=TheVergePage.COMMENT_LINK_SELECTOR)
49 action_runner.ExecuteJavaScript(
50 'window.location.hash = "comments"')
51 action_runner.TapElement(
52 selector=TheVergePage.COMMENT_LINK_SELECTOR)
53 action_runner.WaitForJavaScriptCondition(
54 'window.Chorus.Comments.collection.length > 0')
55 super(TheVergePage, self).RunPageInteractions(action_runner)
58 class FacebookPage(BlinkMemoryMobilePage):
59 def __init__(self, page_set):
60 super(FacebookPage, self).__init__(
61 'https://facebook.com/barackobama',
62 page_set=page_set,
63 name='Facebook')
65 def RunNavigateSteps(self, action_runner):
66 super(FacebookPage, self).RunNavigateSteps(action_runner)
67 action_runner.WaitForJavaScriptCondition(
68 'document.getElementById("u_0_c") !== null &&'
69 'document.body.scrollHeight > window.innerHeight')
72 class GmailPage(BlinkMemoryMobilePage):
73 def __init__(self, page_set):
74 super(GmailPage, self).__init__(
75 'https://mail.google.com/mail/',
76 page_set=page_set,
77 name='Gmail')
79 def RunNavigateSteps(self, action_runner):
80 google_login.LoginGoogleAccount(action_runner, 'google',
81 self.credentials_path)
82 super(GmailPage, self).RunNavigateSteps(action_runner)
83 # Needs to wait for navigation to handle redirects.
84 action_runner.WaitForNavigate()
85 action_runner.WaitForElement(selector='#apploadingdiv')
86 action_runner.WaitForJavaScriptCondition(
87 'document.querySelector("#apploadingdiv").style.opacity == "0"')
90 class BlinkMemoryMobilePageSet(story.StorySet):
91 """Key mobile sites for Blink memory reduction."""
93 def __init__(self):
94 super(BlinkMemoryMobilePageSet, self).__init__(
95 archive_data_file='data/blink_memory_mobile.json',
96 cloud_storage_bucket=story.PARTNER_BUCKET)
98 # Why: High rate of Blink's memory consumption rate.
99 self.AddStory(BlinkMemoryMobilePage(
100 'https://www.pinterest.com',
101 page_set=self,
102 name='Pinterest'))
103 self.AddStory(FacebookPage(self))
104 # TODO(bashi): Enable TheVergePage. http://crbug.com/522381
105 # self.AddStory(TheVergePage(self))
107 # Why: High rate of Blink's memory comsumption rate on low-RAM devices.
108 self.AddStory(BlinkMemoryMobilePage(
109 'http://en.m.wikipedia.org/wiki/Wikipedia',
110 page_set=self,
111 name='Wikipedia (1 tab) - delayed scroll start',))
112 self.AddStory(BlinkMemoryMobilePage(
113 url='http://www.reddit.com/r/programming/comments/1g96ve',
114 page_set=self,
115 name='Reddit'))
116 self.AddStory(BlinkMemoryMobilePage(
117 'https://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks-for-august-2012/',
118 page_set=self,
119 name='Wordpress'))
121 # Why: Renderer memory usage is high.
122 self.AddStory(BlinkMemoryMobilePage(
123 'http://worldjournal.com/',
124 page_set=self,
125 name='Worldjournal'))
127 # Why: Key products.
128 self.AddStory(GmailPage(page_set=self))
129 self.AddStory(BlinkMemoryMobilePage(
130 'http://googlewebmastercentral.blogspot.com/2015/04/rolling-out-mobile-friendly-update.html?m=1',
131 page_set=self,
132 name='Blogger'))
133 self.AddStory(BlinkMemoryMobilePage(
134 'https://plus.google.com/app/basic/110031535020051778989/posts?source=apppromo',
135 page_set=self,
136 name='GooglePlus'))