OLD | NEW |
1 # Copyright 2016 The Chromium Authors. All rights reserved. | 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 | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 import logging | |
6 import sys | 5 import sys |
7 | 6 |
| 7 from page_sets.system_health import platforms |
| 8 from page_sets.system_health import system_health_story |
| 9 |
8 from page_sets.login_helpers import dropbox_login | 10 from page_sets.login_helpers import dropbox_login |
9 from page_sets.login_helpers import google_login | 11 from page_sets.login_helpers import google_login |
10 | 12 |
11 from telemetry.core import discover | |
12 from telemetry.page import page | |
13 | 13 |
14 | 14 class _SinglePageStory(system_health_story.SystemHealthStory): |
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.""" | 15 """Abstract base class for single-page System Health user stories.""" |
26 | 16 pass |
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, take_memory_measurement): | |
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 self._take_memory_measurement = take_memory_measurement | |
40 | |
41 def _Measure(self, action_runner): | |
42 if not self._take_memory_measurement: | |
43 return | |
44 # TODO(petrcermak): This method is essentially the same as | |
45 # MemoryHealthPage._TakeMemoryMeasurement() in memory_health_story.py. | |
46 # Consider sharing the common code. | |
47 action_runner.Wait(_DUMP_WAIT_TIME) | |
48 action_runner.ForceGarbageCollection() | |
49 action_runner.Wait(_DUMP_WAIT_TIME) | |
50 tracing_controller = action_runner.tab.browser.platform.tracing_controller | |
51 if not tracing_controller.is_tracing_running: | |
52 return # Tracing is not running, e.g., when recording a WPR archive. | |
53 if not action_runner.tab.browser.DumpMemory(): | |
54 logging.error('Unable to get a memory dump for %s.', self.name) | |
55 | |
56 def _Login(self, action_runner): | |
57 pass | |
58 | |
59 def _DidLoadDocument(self, action_runner): | |
60 pass | |
61 | |
62 def RunNavigateSteps(self, action_runner): | |
63 self._Login(action_runner) | |
64 super(_SinglePageStory, self).RunNavigateSteps(action_runner) | |
65 | |
66 def RunPageInteractions(self, action_runner): | |
67 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | |
68 self._DidLoadDocument(action_runner) | |
69 self._Measure(action_runner) | |
70 | 17 |
71 | 18 |
72 def IterAllStoryClasses(): | 19 def IterAllStoryClasses(): |
73 # Sort the classes by their names so that their order is stable and | 20 return system_health_story.IterAllStoryClasses( |
74 # deterministic. | 21 sys.modules[__name__], _SinglePageStory) |
75 for unused_cls_name, cls in sorted(discover.DiscoverClassesInModule( | |
76 module=sys.modules[__name__], | |
77 base_class=_SinglePageStory, | |
78 index_by_class_name=True).iteritems()): | |
79 yield cls | |
80 | 22 |
81 | 23 |
82 ################################################################################ | 24 ################################################################################ |
83 # Search and e-commerce. | 25 # Search and e-commerce. |
84 ################################################################################ | 26 ################################################################################ |
85 | 27 |
86 | 28 |
87 class LoadGoogleStory(_SinglePageStory): | 29 class LoadGoogleStory(_SinglePageStory): |
88 NAME = 'load:search:google' | 30 NAME = 'load:search:google' |
89 URL = 'https://www.google.com/#hl=en&q=science' | 31 URL = 'https://www.google.com/#hl=en&q=science' |
(...skipping 10 matching lines...) Expand all Loading... |
100 | 42 |
101 | 43 |
102 class LoadAmazonStory(_SinglePageStory): | 44 class LoadAmazonStory(_SinglePageStory): |
103 NAME = 'load:search:amazon' | 45 NAME = 'load:search:amazon' |
104 URL = 'https://www.amazon.com/s/?field-keywords=nexus' | 46 URL = 'https://www.amazon.com/s/?field-keywords=nexus' |
105 | 47 |
106 | 48 |
107 class LoadTaobaoDesktopStory(_SinglePageStory): | 49 class LoadTaobaoDesktopStory(_SinglePageStory): |
108 NAME = 'load:search:taobao' | 50 NAME = 'load:search:taobao' |
109 URL = 'https://world.taobao.com/' | 51 URL = 'https://world.taobao.com/' |
110 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | 52 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
111 | 53 |
112 | 54 |
113 class LoadTaobaoMobileStory(_SinglePageStory): | 55 class LoadTaobaoMobileStory(_SinglePageStory): |
114 NAME = 'load:search:taobao' | 56 NAME = 'load:search:taobao' |
115 # "ali_trackid" in the URL suppresses "Download app" interstitial. | 57 # "ali_trackid" in the URL suppresses "Download app" interstitial. |
116 URL = 'http://m.intl.taobao.com/?ali_trackid' | 58 URL = 'http://m.intl.taobao.com/?ali_trackid' |
117 SUPPORTED_PLATFORMS = _MOBILE_ONLY | 59 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
118 | 60 |
119 | 61 |
120 class LoadYandexStory(_SinglePageStory): | 62 class LoadYandexStory(_SinglePageStory): |
121 NAME = 'load:search:yandex' | 63 NAME = 'load:search:yandex' |
122 URL = 'https://yandex.ru/touchsearch?text=science' | 64 URL = 'https://yandex.ru/touchsearch?text=science' |
123 | 65 |
124 | 66 |
125 class LoadEbayStory(_SinglePageStory): | 67 class LoadEbayStory(_SinglePageStory): |
126 NAME = 'load:search:ebay' | 68 NAME = 'load:search:ebay' |
127 # Redirects to the "http://" version. | 69 # Redirects to the "http://" version. |
(...skipping 16 matching lines...) Expand all Loading... |
144 URL = 'https://www.twitter.com/justinbieber?skip_interstitial=true' | 86 URL = 'https://www.twitter.com/justinbieber?skip_interstitial=true' |
145 | 87 |
146 | 88 |
147 class LoadVkStory(_SinglePageStory): | 89 class LoadVkStory(_SinglePageStory): |
148 NAME = 'load:social:vk' | 90 NAME = 'load:social:vk' |
149 URL = 'https://vk.com/sbeatles' | 91 URL = 'https://vk.com/sbeatles' |
150 # Due to the deterministic date injected by WPR (February 2008), the cookie | 92 # Due to the deterministic date injected by WPR (February 2008), the cookie |
151 # set by https://vk.com immediately expires, so the page keeps refreshing | 93 # set by https://vk.com immediately expires, so the page keeps refreshing |
152 # indefinitely on mobile | 94 # indefinitely on mobile |
153 # (see https://github.com/chromium/web-page-replay/issues/71). | 95 # (see https://github.com/chromium/web-page-replay/issues/71). |
154 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | 96 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
155 | 97 |
156 | 98 |
157 class LoadInstagramStory(_SinglePageStory): | 99 class LoadInstagramStory(_SinglePageStory): |
158 NAME = 'load:social:instagram' | 100 NAME = 'load:social:instagram' |
159 URL = 'https://www.instagram.com/selenagomez/' | 101 URL = 'https://www.instagram.com/selenagomez/' |
160 | 102 |
161 | 103 |
162 class LoadPinterestStory(_SinglePageStory): | 104 class LoadPinterestStory(_SinglePageStory): |
163 NAME = 'load:social:pinterest' | 105 NAME = 'load:social:pinterest' |
164 URL = 'https://uk.pinterest.com/categories/popular/' | 106 URL = 'https://uk.pinterest.com/categories/popular/' |
(...skipping 20 matching lines...) Expand all Loading... |
185 NAME = 'load:news:cnn' | 127 NAME = 'load:news:cnn' |
186 # Using "https://" shows "Your connection is not private". | 128 # Using "https://" shows "Your connection is not private". |
187 URL = ( | 129 URL = ( |
188 'http://edition.cnn.com/2016/05/02/health/three-habitable-planets-earth-dw
arf-star/index.html') | 130 'http://edition.cnn.com/2016/05/02/health/three-habitable-planets-earth-dw
arf-star/index.html') |
189 | 131 |
190 | 132 |
191 class LoadRedditDesktopStory(_SinglePageStory): | 133 class LoadRedditDesktopStory(_SinglePageStory): |
192 NAME = 'load:news:reddit' | 134 NAME = 'load:news:reddit' |
193 URL = ( | 135 URL = ( |
194 'https://www.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_weddin
g_horror_story/') | 136 'https://www.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_weddin
g_horror_story/') |
195 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | 137 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
196 | 138 |
197 | 139 |
198 class LoadRedditMobileStory(_SinglePageStory): | 140 class LoadRedditMobileStory(_SinglePageStory): |
199 NAME = 'load:news:reddit' | 141 NAME = 'load:news:reddit' |
200 URL = ( | 142 URL = ( |
201 'https://m.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_wedding_
horror_story/') | 143 'https://m.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_wedding_
horror_story/') |
202 SUPPORTED_PLATFORMS = _MOBILE_ONLY | 144 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
203 | 145 |
204 | 146 |
205 class LoadQqMobileStory(_SinglePageStory): | 147 class LoadQqMobileStory(_SinglePageStory): |
206 NAME = 'load:news:qq' | 148 NAME = 'load:news:qq' |
207 # Using "https://" hangs and shows "This site can't be reached". | 149 # Using "https://" hangs and shows "This site can't be reached". |
208 URL = 'http://news.qq.com/a/20160503/003186.htm' | 150 URL = 'http://news.qq.com/a/20160503/003186.htm' |
209 | 151 |
210 | 152 |
211 class LoadSohuStory(_SinglePageStory): | 153 class LoadSohuStory(_SinglePageStory): |
212 NAME = 'load:news:sohu' | 154 NAME = 'load:news:sohu' |
213 # Using "https://" leads to missing images and scripts on mobile (due to | 155 # Using "https://" leads to missing images and scripts on mobile (due to |
214 # mixed content). | 156 # mixed content). |
215 URL = 'http://m.sohu.com/n/447433356/' | 157 URL = 'http://m.sohu.com/n/447433356/' |
216 # The desktop page (http://news.sohu.com/20160503/n447433356.shtml) almost | 158 # The desktop page (http://news.sohu.com/20160503/n447433356.shtml) almost |
217 # always fails to completely load due to | 159 # always fails to completely load due to |
218 # https://github.com/chromium/web-page-replay/issues/74. | 160 # https://github.com/chromium/web-page-replay/issues/74. |
219 SUPPORTED_PLATFORMS = _MOBILE_ONLY | 161 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
220 | 162 |
221 | 163 |
222 class LoadWikipediaStory(_SinglePageStory): | 164 class LoadWikipediaStory(_SinglePageStory): |
223 NAME = 'load:news:wikipedia' | 165 NAME = 'load:news:wikipedia' |
224 URL = 'https://en.wikipedia.org/wiki/Science' | 166 URL = 'https://en.wikipedia.org/wiki/Science' |
225 | 167 |
226 | 168 |
227 ################################################################################ | 169 ################################################################################ |
228 # Audio and video. | 170 # Audio and video. |
229 ################################################################################ | 171 ################################################################################ |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 221 |
280 class LoadDocsStory(_SinglePageStory): | 222 class LoadDocsStory(_SinglePageStory): |
281 NAME = 'load:tools:docs' | 223 NAME = 'load:tools:docs' |
282 URL = ( | 224 URL = ( |
283 'https://docs.google.com/document/d/1GvzDP-tTLmJ0myRhUAfTYWs3ZUFilUICg8psN
HyccwQ/edit?usp=sharing') | 225 'https://docs.google.com/document/d/1GvzDP-tTLmJ0myRhUAfTYWs3ZUFilUICg8psN
HyccwQ/edit?usp=sharing') |
284 | 226 |
285 | 227 |
286 class _LoadGmailBaseStory(_SinglePageStory): | 228 class _LoadGmailBaseStory(_SinglePageStory): |
287 NAME = 'load:tools:gmail' | 229 NAME = 'load:tools:gmail' |
288 URL = 'https://mail.google.com/mail/' | 230 URL = 'https://mail.google.com/mail/' |
289 SUPPORTED_PLATFORMS = _NO_PLATFORMS | 231 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
290 | 232 |
291 def _Login(self, action_runner): | 233 def _Login(self, action_runner): |
292 google_login.LoginGoogleAccount(action_runner, 'googletest', | 234 google_login.LoginGoogleAccount(action_runner, 'googletest', |
293 self.credentials_path) | 235 self.credentials_path) |
294 | 236 |
295 # Navigating to https://mail.google.com immediately leads to an infinite | 237 # Navigating to https://mail.google.com immediately leads to an infinite |
296 # redirection loop due to a bug in WPR (see | 238 # redirection loop due to a bug in WPR (see |
297 # https://github.com/chromium/web-page-replay/issues/70). We therefore first | 239 # https://github.com/chromium/web-page-replay/issues/70). We therefore first |
298 # navigate to a sub-URL to set up the session and hit the resulting | 240 # navigate to a sub-URL to set up the session and hit the resulting |
299 # redirection loop. Afterwards, we can safely navigate to | 241 # redirection loop. Afterwards, we can safely navigate to |
300 # https://mail.google.com. | 242 # https://mail.google.com. |
301 action_runner.Navigate( | 243 action_runner.Navigate( |
302 'https://mail.google.com/mail/mu/mp/872/trigger_redirection_loop') | 244 'https://mail.google.com/mail/mu/mp/872/trigger_redirection_loop') |
303 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | 245 action_runner.tab.WaitForDocumentReadyStateToBeComplete() |
304 | 246 |
305 | 247 |
306 class LoadGmailDesktopStory(_LoadGmailBaseStory): | 248 class LoadGmailDesktopStory(_LoadGmailBaseStory): |
307 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | 249 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
308 | 250 |
309 def _DidLoadDocument(self, action_runner): | 251 def _DidLoadDocument(self, action_runner): |
310 # Wait until the UI loads. | 252 # Wait until the UI loads. |
311 action_runner.WaitForJavaScriptCondition( | 253 action_runner.WaitForJavaScriptCondition( |
312 'document.getElementById("loading").style.display === "none"') | 254 'document.getElementById("loading").style.display === "none"') |
313 | 255 |
314 class LoadGmailMobileStory(_LoadGmailBaseStory): | 256 class LoadGmailMobileStory(_LoadGmailBaseStory): |
315 SUPPORTED_PLATFORMS = _MOBILE_ONLY | 257 SUPPORTED_PLATFORMS = platforms.MOBILE_ONLY |
316 | 258 |
317 def _DidLoadDocument(self, action_runner): | 259 def _DidLoadDocument(self, action_runner): |
318 # Close the "Get Inbox by Gmail" interstitial. | 260 # Close the "Get Inbox by Gmail" interstitial. |
319 action_runner.WaitForJavaScriptCondition( | 261 action_runner.WaitForJavaScriptCondition( |
320 'document.querySelector("#isppromo a") !== null') | 262 'document.querySelector("#isppromo a") !== null') |
321 action_runner.ExecuteJavaScript( | 263 action_runner.ExecuteJavaScript( |
322 'document.querySelector("#isppromo a").click()') | 264 'document.querySelector("#isppromo a").click()') |
323 # Wait until the UI loads. | 265 # Wait until the UI loads. |
324 action_runner.WaitForJavaScriptCondition( | 266 action_runner.WaitForJavaScriptCondition( |
325 'document.getElementById("apploadingdiv").style.height === "0px"') | 267 'document.getElementById("apploadingdiv").style.height === "0px"') |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
390 # caption is displayed. | 332 # caption is displayed. |
391 action_runner.WaitForJavaScriptCondition( | 333 action_runner.WaitForJavaScriptCondition( |
392 'document.querySelector("#game canvas").style.background !== ""') | 334 'document.querySelector("#game canvas").style.background !== ""') |
393 | 335 |
394 | 336 |
395 class LoadMiniclipStory(_SinglePageStory): | 337 class LoadMiniclipStory(_SinglePageStory): |
396 NAME = 'load:games:miniclip' | 338 NAME = 'load:games:miniclip' |
397 # Using "https://" causes "404 Not Found" during WPR recording. | 339 # Using "https://" causes "404 Not Found" during WPR recording. |
398 URL = 'http://www.miniclip.com/games/en/' | 340 URL = 'http://www.miniclip.com/games/en/' |
399 # Desktop only (requires Flash). | 341 # Desktop only (requires Flash). |
400 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | 342 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
401 | 343 |
402 | 344 |
403 class LoadAlphabettyStory(_SinglePageStory): | 345 class LoadAlphabettyStory(_SinglePageStory): |
404 NAME = 'load:games:alphabetty' | 346 NAME = 'load:games:alphabetty' |
405 URL = 'https://king.com/play/alphabetty' | 347 URL = 'https://king.com/play/alphabetty' |
406 # Desktop only (requires Flash). | 348 # Desktop only (requires Flash). |
407 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | 349 SUPPORTED_PLATFORMS = platforms.DESKTOP_ONLY |
OLD | NEW |