| OLD | NEW |
| (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, 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 | |
| 71 | |
| 72 def IterAllStoryClasses(): | |
| 73 # Sort the classes by their names so that their order is stable and | |
| 74 # deterministic. | |
| 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 | |
| 81 | |
| 82 ################################################################################ | |
| 83 # Search and e-commerce. | |
| 84 ################################################################################ | |
| 85 | |
| 86 | |
| 87 class LoadGoogleStory(_SinglePageStory): | |
| 88 NAME = 'load:search:google' | |
| 89 URL = 'https://www.google.com/#hl=en&q=science' | |
| 90 | |
| 91 | |
| 92 class LoadBaiduStory(_SinglePageStory): | |
| 93 NAME = 'load:search:baidu' | |
| 94 URL = 'https://www.baidu.com/s?word=google' | |
| 95 | |
| 96 | |
| 97 class LoadYahooStory(_SinglePageStory): | |
| 98 NAME = 'load:search:yahoo' | |
| 99 URL = 'https://search.yahoo.com/search;_ylt=?p=google' | |
| 100 | |
| 101 | |
| 102 class LoadAmazonStory(_SinglePageStory): | |
| 103 NAME = 'load:search:amazon' | |
| 104 URL = 'https://www.amazon.com/s/?field-keywords=nexus' | |
| 105 | |
| 106 | |
| 107 class LoadTaobaoDesktopStory(_SinglePageStory): | |
| 108 NAME = 'load:search:taobao' | |
| 109 URL = 'https://world.taobao.com/' | |
| 110 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | |
| 111 | |
| 112 | |
| 113 class LoadTaobaoMobileStory(_SinglePageStory): | |
| 114 NAME = 'load:search:taobao' | |
| 115 # "ali_trackid" in the URL suppresses "Download app" interstitial. | |
| 116 URL = 'http://m.intl.taobao.com/?ali_trackid' | |
| 117 SUPPORTED_PLATFORMS = _MOBILE_ONLY | |
| 118 | |
| 119 | |
| 120 class LoadYandexStory(_SinglePageStory): | |
| 121 NAME = 'load:search:yandex' | |
| 122 URL = 'https://yandex.ru/touchsearch?text=science' | |
| 123 | |
| 124 | |
| 125 class LoadEbayStory(_SinglePageStory): | |
| 126 NAME = 'load:search:ebay' | |
| 127 # Redirects to the "http://" version. | |
| 128 URL = 'https://www.ebay.com/sch/i.html?_nkw=headphones' | |
| 129 | |
| 130 | |
| 131 ################################################################################ | |
| 132 # Social networks. | |
| 133 ################################################################################ | |
| 134 | |
| 135 | |
| 136 class LoadFacebookStory(_SinglePageStory): | |
| 137 # Using Facebook login often causes "404 Not Found" with WPR. | |
| 138 NAME = 'load:social:facebook' | |
| 139 URL = 'https://www.facebook.com/rihanna' | |
| 140 | |
| 141 | |
| 142 class LoadTwitterStory(_SinglePageStory): | |
| 143 NAME = 'load:social:twitter' | |
| 144 URL = 'https://www.twitter.com/justinbieber?skip_interstitial=true' | |
| 145 | |
| 146 | |
| 147 class LoadVkStory(_SinglePageStory): | |
| 148 NAME = 'load:social:vk' | |
| 149 URL = 'https://vk.com/sbeatles' | |
| 150 # 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 | |
| 152 # indefinitely on mobile | |
| 153 # (see https://github.com/chromium/web-page-replay/issues/71). | |
| 154 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | |
| 155 | |
| 156 | |
| 157 class LoadInstagramStory(_SinglePageStory): | |
| 158 NAME = 'load:social:instagram' | |
| 159 URL = 'https://www.instagram.com/selenagomez/' | |
| 160 | |
| 161 | |
| 162 class LoadPinterestStory(_SinglePageStory): | |
| 163 NAME = 'load:social:pinterest' | |
| 164 URL = 'https://uk.pinterest.com/categories/popular/' | |
| 165 | |
| 166 | |
| 167 class LoadTumblrStory(_SinglePageStory): | |
| 168 NAME = 'load:social:tumblr' | |
| 169 # Redirects to the "http://" version. | |
| 170 URL = 'https://50thousand.tumblr.com/' | |
| 171 | |
| 172 | |
| 173 ################################################################################ | |
| 174 # News, discussion and knowledge portals and blogs. | |
| 175 ################################################################################ | |
| 176 | |
| 177 | |
| 178 class LoadBbcStory(_SinglePageStory): | |
| 179 NAME = 'load:news:bbc' | |
| 180 # Redirects to the "http://" version. | |
| 181 URL = 'https://www.bbc.co.uk/news/world-asia-china-36189636' | |
| 182 | |
| 183 | |
| 184 class LoadCnnStory(_SinglePageStory): | |
| 185 NAME = 'load:news:cnn' | |
| 186 # Using "https://" shows "Your connection is not private". | |
| 187 URL = ( | |
| 188 'http://edition.cnn.com/2016/05/02/health/three-habitable-planets-earth-dw
arf-star/index.html') | |
| 189 | |
| 190 | |
| 191 class LoadRedditDesktopStory(_SinglePageStory): | |
| 192 NAME = 'load:news:reddit' | |
| 193 URL = ( | |
| 194 'https://www.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_weddin
g_horror_story/') | |
| 195 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | |
| 196 | |
| 197 | |
| 198 class LoadRedditMobileStory(_SinglePageStory): | |
| 199 NAME = 'load:news:reddit' | |
| 200 URL = ( | |
| 201 'https://m.reddit.com/r/AskReddit/comments/4hi90e/whats_your_best_wedding_
horror_story/') | |
| 202 SUPPORTED_PLATFORMS = _MOBILE_ONLY | |
| 203 | |
| 204 | |
| 205 class LoadQqMobileStory(_SinglePageStory): | |
| 206 NAME = 'load:news:qq' | |
| 207 # Using "https://" hangs and shows "This site can't be reached". | |
| 208 URL = 'http://news.qq.com/a/20160503/003186.htm' | |
| 209 | |
| 210 | |
| 211 class LoadSohuStory(_SinglePageStory): | |
| 212 NAME = 'load:news:sohu' | |
| 213 # Using "https://" leads to missing images and scripts on mobile (due to | |
| 214 # mixed content). | |
| 215 URL = 'http://m.sohu.com/n/447433356/' | |
| 216 # The desktop page (http://news.sohu.com/20160503/n447433356.shtml) almost | |
| 217 # always fails to completely load due to | |
| 218 # https://github.com/chromium/web-page-replay/issues/74. | |
| 219 SUPPORTED_PLATFORMS = _MOBILE_ONLY | |
| 220 | |
| 221 | |
| 222 class LoadWikipediaStory(_SinglePageStory): | |
| 223 NAME = 'load:news:wikipedia' | |
| 224 URL = 'https://en.wikipedia.org/wiki/Science' | |
| 225 | |
| 226 | |
| 227 ################################################################################ | |
| 228 # Audio and video. | |
| 229 ################################################################################ | |
| 230 | |
| 231 | |
| 232 class LoadYouTubeStory(_SinglePageStory): | |
| 233 # No way to disable autoplay on desktop. | |
| 234 NAME = 'load:media:youtube' | |
| 235 URL = 'https://www.youtube.com/watch?v=QGfhS1hfTWw&autoplay=false' | |
| 236 | |
| 237 | |
| 238 class LoadDailymotionStory(_SinglePageStory): | |
| 239 # The side panel with related videos doesn't show on desktop due to | |
| 240 # https://github.com/chromium/web-page-replay/issues/74. | |
| 241 NAME = 'load:media:dailymotion' | |
| 242 URL = ( | |
| 243 'https://www.dailymotion.com/video/x489k7d_street-performer-shows-off-slin
ky-skills_fun?autoplay=false') | |
| 244 | |
| 245 | |
| 246 class LoadGoogleImagesStory(_SinglePageStory): | |
| 247 NAME = 'load:media:google_images' | |
| 248 URL = 'https://www.google.co.uk/search?tbm=isch&q=love' | |
| 249 | |
| 250 | |
| 251 class LoadSoundCloudStory(_SinglePageStory): | |
| 252 # No way to disable autoplay on desktop. Album artwork doesn't load due to | |
| 253 # https://github.com/chromium/web-page-replay/issues/73. | |
| 254 NAME = 'load:media:soundcloud' | |
| 255 URL = 'https://soundcloud.com/lifeofdesiigner/desiigner-panda' | |
| 256 | |
| 257 | |
| 258 class Load9GagStory(_SinglePageStory): | |
| 259 NAME = 'load:media:9gag' | |
| 260 URL = 'https://www.9gag.com/' | |
| 261 | |
| 262 | |
| 263 class LoadFlickr(_SinglePageStory): | |
| 264 NAME = 'load:media:flickr' | |
| 265 URL = 'https://www.flickr.com/photos/tags/farm' | |
| 266 | |
| 267 def _DidLoadDocument(self, action_runner): | |
| 268 # Wait until the 'Recently tagged' view loads. | |
| 269 action_runner.WaitForJavaScriptCondition(''' | |
| 270 document.querySelector( | |
| 271 '.search-photos-everyone-trending-view .photo-list-view') | |
| 272 !== null''') | |
| 273 | |
| 274 | |
| 275 ################################################################################ | |
| 276 # Online tools (documents, emails, storage, ...). | |
| 277 ################################################################################ | |
| 278 | |
| 279 | |
| 280 class LoadDocsStory(_SinglePageStory): | |
| 281 NAME = 'load:tools:docs' | |
| 282 URL = ( | |
| 283 'https://docs.google.com/document/d/1GvzDP-tTLmJ0myRhUAfTYWs3ZUFilUICg8psN
HyccwQ/edit?usp=sharing') | |
| 284 | |
| 285 | |
| 286 class _LoadGmailBaseStory(_SinglePageStory): | |
| 287 NAME = 'load:tools:gmail' | |
| 288 URL = 'https://mail.google.com/mail/' | |
| 289 SUPPORTED_PLATFORMS = _NO_PLATFORMS | |
| 290 | |
| 291 def _Login(self, action_runner): | |
| 292 google_login.LoginGoogleAccount(action_runner, 'googletest', | |
| 293 self.credentials_path) | |
| 294 | |
| 295 # Navigating to https://mail.google.com immediately leads to an infinite | |
| 296 # redirection loop due to a bug in WPR (see | |
| 297 # 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 | |
| 299 # redirection loop. Afterwards, we can safely navigate to | |
| 300 # https://mail.google.com. | |
| 301 action_runner.Navigate( | |
| 302 'https://mail.google.com/mail/mu/mp/872/trigger_redirection_loop') | |
| 303 action_runner.tab.WaitForDocumentReadyStateToBeComplete() | |
| 304 | |
| 305 | |
| 306 class LoadGmailDesktopStory(_LoadGmailBaseStory): | |
| 307 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | |
| 308 | |
| 309 def _DidLoadDocument(self, action_runner): | |
| 310 # Wait until the UI loads. | |
| 311 action_runner.WaitForJavaScriptCondition( | |
| 312 'document.getElementById("loading").style.display === "none"') | |
| 313 | |
| 314 class LoadGmailMobileStory(_LoadGmailBaseStory): | |
| 315 SUPPORTED_PLATFORMS = _MOBILE_ONLY | |
| 316 | |
| 317 def _DidLoadDocument(self, action_runner): | |
| 318 # Close the "Get Inbox by Gmail" interstitial. | |
| 319 action_runner.WaitForJavaScriptCondition( | |
| 320 'document.querySelector("#isppromo a") !== null') | |
| 321 action_runner.ExecuteJavaScript( | |
| 322 'document.querySelector("#isppromo a").click()') | |
| 323 # Wait until the UI loads. | |
| 324 action_runner.WaitForJavaScriptCondition( | |
| 325 'document.getElementById("apploadingdiv").style.height === "0px"') | |
| 326 | |
| 327 | |
| 328 class LoadMapsStory(_SinglePageStory): | |
| 329 NAME = 'load:tools:maps' | |
| 330 URL = 'https://www.google.com/maps/place/London,+UK/' | |
| 331 | |
| 332 | |
| 333 class LoadStackOverflowStory(_SinglePageStory): | |
| 334 NAME = 'load:tools:stackoverflow' | |
| 335 URL = ( | |
| 336 'https://stackoverflow.com/questions/36827659/compiling-an-application-for
-use-in-highly-radioactive-environments') | |
| 337 | |
| 338 | |
| 339 class LoadDropboxStory(_SinglePageStory): | |
| 340 NAME = 'load:tools:dropbox' | |
| 341 URL = 'https://www.dropbox.com' | |
| 342 | |
| 343 def _Login(self, action_runner): | |
| 344 dropbox_login.LoginAccount(action_runner, 'dropbox', self.credentials_path) | |
| 345 | |
| 346 | |
| 347 class LoadWeatherStory(_SinglePageStory): | |
| 348 NAME = 'load:tools:weather' | |
| 349 URL = 'https://weather.com/en-GB/weather/today/l/USCA0286:1:US' | |
| 350 | |
| 351 | |
| 352 class LoadDriveStory(_SinglePageStory): | |
| 353 NAME = 'load:tools:drive' | |
| 354 URL = 'https://drive.google.com/drive/my-drive' | |
| 355 | |
| 356 def _Login(self, action_runner): | |
| 357 google_login.LoginGoogleAccount(action_runner, 'googletest', | |
| 358 self.credentials_path) | |
| 359 | |
| 360 | |
| 361 ################################################################################ | |
| 362 # In-browser games (HTML5 and Flash). | |
| 363 ################################################################################ | |
| 364 | |
| 365 | |
| 366 class LoadBubblesStory(_SinglePageStory): | |
| 367 NAME = 'load:games:bubbles' | |
| 368 URL = ( | |
| 369 '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') | |
| 370 | |
| 371 def _DidLoadDocument(self, action_runner): | |
| 372 # The #logo element is removed right before the main menu is displayed. | |
| 373 action_runner.WaitForJavaScriptCondition( | |
| 374 'document.getElementById("logo") === null') | |
| 375 | |
| 376 | |
| 377 class LoadLazorsStory(_SinglePageStory): | |
| 378 NAME = 'load:games:lazors' | |
| 379 # Using "https://" hangs and shows "This site can't be reached". | |
| 380 URL = 'http://www8.games.mobi/games/html5/lazors/lazors.html' | |
| 381 | |
| 382 | |
| 383 class LoadSpyChaseStory(_SinglePageStory): | |
| 384 NAME = 'load:games:spychase' | |
| 385 # Using "https://" shows "Your connection is not private". | |
| 386 URL = 'http://playstar.mobi/games/spychase/index.php' | |
| 387 | |
| 388 def _DidLoadDocument(self, action_runner): | |
| 389 # The background of the game canvas is set when the "Tap screen to play" | |
| 390 # caption is displayed. | |
| 391 action_runner.WaitForJavaScriptCondition( | |
| 392 'document.querySelector("#game canvas").style.background !== ""') | |
| 393 | |
| 394 | |
| 395 class LoadMiniclipStory(_SinglePageStory): | |
| 396 NAME = 'load:games:miniclip' | |
| 397 # Using "https://" causes "404 Not Found" during WPR recording. | |
| 398 URL = 'http://www.miniclip.com/games/en/' | |
| 399 # Desktop only (requires Flash). | |
| 400 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | |
| 401 | |
| 402 | |
| 403 class LoadAlphabettyStory(_SinglePageStory): | |
| 404 NAME = 'load:games:alphabetty' | |
| 405 URL = 'https://king.com/play/alphabetty' | |
| 406 # Desktop only (requires Flash). | |
| 407 SUPPORTED_PLATFORMS = _DESKTOP_ONLY | |
| OLD | NEW |