Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(11)

Side by Side Diff: tools/perf/page_sets/system_health/single_page_stories.py

Issue 2092163002: [system-health] Generalize loading stories to single-page stories (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Define stories explicitly (avoid declarative JSON) Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 # Copyright 2016 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
5 import logging
6 import sys
7
8 from page_sets.login_helpers import dropbox_login
9 from page_sets.login_helpers import google_login
10
11 from telemetry.core import discover
12 from telemetry.page import page
13
14
15 _ALL_PLATFORMS = frozenset({'desktop', 'mobile'})
16 _DESKTOP_ONLY = frozenset({'desktop'})
17 _MOBILE_ONLY = frozenset({'mobile'})
18 _NO_PLATFORMS = frozenset()
19
20
21 _DUMP_WAIT_TIME = 3
22
23
24 class _SinglePageStory(page.Page):
25 """Abstract base class for single-page System Health user stories."""
26
27 # The full name of a single page story has the form CASE:GROUP:PAGE (e.g.
28 # 'load:search:google').
29 NAME = NotImplemented
30 URL = NotImplemented
31 SUPPORTED_PLATFORMS = _ALL_PLATFORMS
32
33 def __init__(self, story_set):
34 case, group, _ = self.NAME.split(':')
35 super(_SinglePageStory, self).__init__(
36 page_set=story_set, name=self.NAME, url=self.URL,
37 credentials_path='../data/credentials.json',
38 grouping_keys={'case': case, 'group': group})
39
40 def _Measure(self, action_runner):
41 # TODO(petrcermak): This method is essentially the same as
42 # MemoryHealthPage._TakeMemoryMeasurement() in memory_health_story.py.
43 # Consider sharing the common code.
44 action_runner.Wait(_DUMP_WAIT_TIME)
45 action_runner.ForceGarbageCollection()
46 action_runner.Wait(_DUMP_WAIT_TIME)
47 tracing_controller = action_runner.tab.browser.platform.tracing_controller
48 if not tracing_controller.is_tracing_running:
49 return # Tracing is not running, e.g., when recording a WPR archive.
50 if not action_runner.tab.browser.DumpMemory():
51 logging.error('Unable to get a memory dump for %s.', self.name)
52
53 def _Login(self, action_runner):
54 pass
55
56 def _DocumentLoaded(self, action_runner):
nednguyen 2016/06/27 22:32:09 Rename this to _DidLoadDocument?
petrcermak 2016/06/28 13:21:36 Done.
57 pass
58
59 def RunNavigateSteps(self, action_runner):
60 self._Login(action_runner)
61 super(_SinglePageStory, self).RunNavigateSteps(action_runner)
62
63 def RunPageInteractions(self, action_runner):
64 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
65 self._DocumentLoaded(action_runner)
66 self._Measure(action_runner)
67
68
69 def IterAllStoryClasses():
70 # Sort the classes by their names so that their order is stable and
71 # deterministic.
72 for unused_cls_name, cls in sorted(discover.DiscoverClassesInModule(
73 module=sys.modules[__name__],
74 base_class=_SinglePageStory,
75 index_by_class_name=True).iteritems()):
76 yield cls
77
78
79 ################################################################################
80 # Search and e-commerce.
81 ################################################################################
82
83
84 class LoadGoogleStory(_SinglePageStory):
85 NAME = 'load:search:google'
86 URL = 'https://www.google.com/#hl=en&q=science'
87
88
89 class LoadBaiduStory(_SinglePageStory):
90 NAME = 'load:search:baidu'
91 URL = 'https://www.baidu.com/s?word=google'
92
93
94 class LoadYahooStory(_SinglePageStory):
95 NAME = 'load:search:yahoo'
96 URL = 'https://search.yahoo.com/search;_ylt=?p=google'
97
98
99 class LoadAmazonStory(_SinglePageStory):
100 NAME = 'load:search:amazon'
101 URL = 'https://www.amazon.com/s/?field-keywords=nexus'
102
103
104 class LoadTaobaoDesktopStory(_SinglePageStory):
105 NAME = 'load:search:taobao'
106 URL = 'https://world.taobao.com/'
107 SUPPORTED_PLATFORMS = _DESKTOP_ONLY
108
109
110 class LoadTaobaoMobileStory(_SinglePageStory):
111 NAME = 'load:search:taobao'
112 # "ali_trackid" in the URL suppresses "Download app" interstitial.
113 URL = 'http://m.intl.taobao.com/?ali_trackid'
114 SUPPORTED_PLATFORMS = _MOBILE_ONLY
115
116
117 class LoadYandexStory(_SinglePageStory):
118 NAME = 'load:search:yandex'
119 URL = 'https://yandex.ru/touchsearch?text=science'
120
121
122 class LoadEbayStory(_SinglePageStory):
123 NAME = 'load:search:ebay'
124 # Redirects to the "http://" version.
125 URL = 'https://www.ebay.com/sch/i.html?_nkw=headphones'
126
127
128 ################################################################################
129 # Social networks.
130 ################################################################################
131
132
133 class LoadFacebookStory(_SinglePageStory):
134 # Using Facebook login often causes "404 Not Found" with WPR.
135 NAME = 'load:social:facebook'
136 URL = 'https://www.facebook.com/rihanna'
137
138
139 class LoadTwitterStory(_SinglePageStory):
140 NAME = 'load:social:twitter'
141 URL = 'https://www.twitter.com/justinbieber?skip_interstitial=true'
142
143
144 class LoadVkStory(_SinglePageStory):
145 NAME = 'load:social:vk'
146 URL = 'https://vk.com/sbeatles'
147 # Due to the deterministic date injected by WPR (February 2008), the cookie
148 # set by https://vk.com immediately expires, so the page keeps refreshing
149 # indefinitely on mobile
150 # (see https://github.com/chromium/web-page-replay/issues/71).
151 SUPPORTED_PLATFORMS = _DESKTOP_ONLY
152
153
154 class LoadInstagramStory(_SinglePageStory):
155 NAME = 'load:social:instagram'
156 URL = 'https://www.instagram.com/selenagomez/'
157
158
159 class LoadPinterestStory(_SinglePageStory):
160 NAME = 'load:social:pinterest'
161 URL = 'https://uk.pinterest.com/categories/popular/'
162
163
164 class LoadTumblrStory(_SinglePageStory):
165 NAME = 'load:social:tumblr'
166 # Redirects to the "http://" version.
167 URL = 'https://50thousand.tumblr.com/'
168
169
170 ################################################################################
171 # News, discussion and knowledge portals and blogs.
172 ################################################################################
173
174
175 class LoadBbcStory(_SinglePageStory):
176 NAME = 'load:news:bbc'
177 # Redirects to the "http://" version.
178 URL = 'https://www.bbc.co.uk/news/world-asia-china-36189636'
179
180
181 class LoadCnnStory(_SinglePageStory):
182 NAME = 'load:news:cnn'
183 # Using "https://" shows "Your connection is not private".
184 URL = (
185 'http://edition.cnn.com/2016/05/02/health/three-habitable-planets-earth-dw arf-star/index.html')
186
187
188 class LoadRedditDesktopStory(_SinglePageStory):
189 NAME = 'load:news:reddit'
190 URL = (
191 'https://www.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_weddin g_horror_story/')
192 SUPPORTED_PLATFORMS = _DESKTOP_ONLY
193
194
195 class LoadRedditMobileStory(_SinglePageStory):
196 NAME = 'load:news:reddit'
197 URL = (
198 'https://m.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_wedding_ horror_story/')
199 SUPPORTED_PLATFORMS = _MOBILE_ONLY
200
201
202 class LoadQqMobileStory(_SinglePageStory):
203 NAME = 'load:news:qq'
204 # Using "https://" hangs and shows "This site can't be reached".
205 URL = 'http://news.qq.com/a/20160503/003186.htm'
206
207
208 class LoadSohuStory(_SinglePageStory):
209 NAME = 'load:news:sohu'
210 # Using "https://" leads to missing images and scripts on mobile (due to
211 # mixed content).
212 URL = 'http://m.sohu.com/n/447433356/'
213 # The desktop page (http://news.sohu.com/20160503/n447433356.shtml) almost
214 # always fails to completely load due to
215 # https://github.com/chromium/web-page-replay/issues/74.
216 SUPPORTED_PLATFORMS = _MOBILE_ONLY
217
218
219 class LoadWikipediaStory(_SinglePageStory):
220 NAME = 'load:news:wikipedia'
221 URL = 'https://en.wikipedia.org/wiki/Science'
222
223
224 ################################################################################
225 # Audio and video.
226 ################################################################################
227
228
229 class LoadYouTubeStory(_SinglePageStory):
230 # No way to disable autoplay on desktop.
231 NAME = 'load:media:youtube'
232 URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false'
233
234
235 class LoadDailymotionStory(_SinglePageStory):
236 # The side panel with related videos doesn't show on desktop due to
237 # https://github.com/chromium/web-page-replay/issues/74.
238 NAME = 'load:media:dailymotion'
239 URL = (
240 'https://www.dailymotion.com/video/x489k7d_street-performer-shows-off-slin ky-skills_fun?autoplay=false')
241
242
243 class LoadGoogleImagesStory(_SinglePageStory):
244 NAME = 'load:media:google_images'
245 URL = 'https://www.google.co.uk/search?tbm=isch&q=love'
246
247
248 class LoadSoundCloudStory(_SinglePageStory):
249 # No way to disable autoplay on desktop. Album artwork doesn't load due to
250 # https://github.com/chromium/web-page-replay/issues/73.
251 NAME = 'load:media:soundcloud'
252 URL = 'https://soundcloud.com/lifeofdesiigner/desiigner-panda'
253
254
255 class Load9GagStory(_SinglePageStory):
256 NAME = 'load:media:9gag'
257 URL = 'https://www.9gag.com/'
258
259
260 class LoadFlickr(_SinglePageStory):
261 NAME = 'load:media:flickr'
262 URL = 'https://www.flickr.com/photos/tags/farm'
263
264 def _DocumentLoaded(self, action_runner):
265 # Wait until the 'Recently tagged' view loads.
266 action_runner.WaitForJavaScriptCondition('''
267 document.querySelector(
268 '.search-photos-everyone-trending-view .photo-list-view')
269 !== null''')
270
271
272 ################################################################################
273 # Online tools (documents, emails, storage, ...).
274 ################################################################################
275
276
277 class LoadDocsStory(_SinglePageStory):
278 NAME = 'load:tools:docs'
279 URL = (
280 'https://docs.google.com/document/d/1GvzDP-tTLmJ0myRhUAfTYWs3ZUFilUICg8psN HyccwQ/edit?usp=sharing')
281
282
283 class _LoadGmailBaseStory(_SinglePageStory):
284 NAME = 'load:tools:gmail'
285 URL = 'https://mail.google.com/mail/'
286 SUPPORTED_PLATFORMS = _NO_PLATFORMS
287
288 def _Login(self, action_runner):
289 google_login.LoginGoogleAccount(action_runner, 'googletest',
290 self.credentials_path)
291
292 # Navigating to https://mail.google.com immediately leads to an infinite
293 # redirection loop due to a bug in WPR (see
294 # https://github.com/chromium/web-page-replay/issues/70). We therefore first
295 # navigate to a sub-URL to set up the session and hit the resulting
296 # redirection loop. Afterwards, we can safely navigate to
297 # https://mail.google.com.
298 action_runner.Navigate(
299 'https://mail.google.com/mail/mu/mp/872/trigger_redirection_loop')
300 action_runner.tab.WaitForDocumentReadyStateToBeComplete()
301
302
303 class LoadGmailDesktopStory(_LoadGmailBaseStory):
304 SUPPORTED_PLATFORMS = _DESKTOP_ONLY
305
306 def _DocumentLoaded(self, action_runner):
307 # Wait until the UI loads.
308 action_runner.WaitForJavaScriptCondition(
309 'document.getElementById("loading").style.display === "none"')
310
311 class LoadGmailMobileStory(_LoadGmailBaseStory):
312 SUPPORTED_PLATFORMS = _MOBILE_ONLY
313
314 def _DocumentLoaded(self, action_runner):
315 # Close the "Get Inbox by Gmail" interstitial.
316 action_runner.WaitForJavaScriptCondition(
317 'document.querySelector("#isppromo a") !== null')
318 action_runner.ExecuteJavaScript(
319 'document.querySelector("#isppromo a").click()')
320 # Wait until the UI loads.
321 action_runner.WaitForJavaScriptCondition(
322 'document.getElementById("apploadingdiv").style.height === "0px"')
323
324
325 class LoadMapsStory(_SinglePageStory):
326 NAME = 'load:tools:maps'
327 URL = 'https://www.google.com/maps/place/London,+UK/'
328
329
330 class LoadStackOverflowStory(_SinglePageStory):
331 NAME = 'load:tools:stackoverflow'
332 URL = (
333 'https://stackoverflow.com/questions/36827659/compiling-an-application-for -use-in-highly-radioactive-environments')
334
335
336 class LoadDropboxStory(_SinglePageStory):
337 NAME = 'load:tools:dropbox'
338 URL = 'https://www.dropbox.com'
339
340 def _Login(self, action_runner):
341 dropbox_login.LoginAccount(action_runner, 'dropbox', self.credentials_path)
342
343
344 class LoadWeatherStory(_SinglePageStory):
345 NAME = 'load:tools:weather'
346 URL = 'https://weather.com/en-GB/weather/today/l/USCA0286:1:US'
347
348
349 class LoadDriveStory(_SinglePageStory):
350 NAME = 'load:tools:drive'
351 URL = 'https://drive.google.com/drive/my-drive'
352
353 def _Login(self, action_runner):
354 google_login.LoginGoogleAccount(action_runner, 'googletest',
355 self.credentials_path)
356
357
358 ################################################################################
359 # In-browser games (HTML5 and Flash).
360 ################################################################################
361
362
363 class LoadBubblesStory(_SinglePageStory):
364 NAME = 'load:games:bubbles'
365 URL = (
366 'https://games.cdn.famobi.com/html5games/s/smarty-bubbles/v010/?fg_domain= play.famobi.com&fg_uid=d8f24956-dc91-4902-9096-a46cb1353b6f&fg_pid=4638e320-4444 -4514-81c4-d80a8c662371&fg_beat=620')
367
368 def _DocumentLoaded(self, action_runner):
369 # The #logo element is removed right before the main menu is displayed.
370 action_runner.WaitForJavaScriptCondition(
371 'document.getElementById("logo") === null')
372
373
374 class LoadLazorsStory(_SinglePageStory):
375 NAME = 'load:games:lazors'
376 # Using "https://" hangs and shows "This site can't be reached".
377 URL = 'http://www8.games.mobi/games/html5/lazors/lazors.html'
378
379
380 class LoadSpyChaseStory(_SinglePageStory):
381 NAME = 'load:games:spychase'
382 # Using "https://" shows "Your connection is not private".
383 URL = 'http://playstar.mobi/games/spychase/index.php'
384
385 def _DocumentLoaded(self, action_runner):
386 # The background of the game canvas is set when the "Tap screen to play"
387 # caption is displayed.
388 action_runner.WaitForJavaScriptCondition(
389 'document.querySelector("#game canvas").style.background !== ""')
390
391
392 class LoadMiniclipStory(_SinglePageStory):
393 NAME = 'load:games:miniclip'
394 # Using "https://" causes "404 Not Found" during WPR recording.
395 URL = 'http://www.miniclip.com/games/en/'
396 # Desktop only (requires Flash).
397 SUPPORTED_PLATFORMS = _DESKTOP_ONLY
398
399
400 class LoadAlphabettyStory(_SinglePageStory):
401 NAME = 'load:games:alphabetty'
402 URL = 'https://king.com/play/alphabetty'
403 # Desktop only (requires Flash).
404 SUPPORTED_PLATFORMS = _DESKTOP_ONLY
OLDNEW
« no previous file with comments | « tools/perf/page_sets/system_health/loading_stories.py ('k') | tools/perf/page_sets/system_health/system_health_stories.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698