| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 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 from telemetry.page import page as page_module | 4 from telemetry.page import page as page_module |
| 5 from telemetry.page import page_set as page_set_module | 5 from telemetry.page import page_set as page_set_module |
| 6 | 6 |
| 7 | 7 |
| 8 def _GetCurrentLocation(action_runner): | 8 def _GetCurrentLocation(action_runner): |
| 9 return action_runner.EvaluateJavaScript('document.location.href') | 9 return action_runner.EvaluateJavaScript('document.location.href') |
| 10 | 10 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 39 | 39 |
| 40 def __init__(self, page_set): | 40 def __init__(self, page_set): |
| 41 super(GoogleWebSearchPage, self).__init__( | 41 super(GoogleWebSearchPage, self).__init__( |
| 42 url='https://www.google.com/#hl=en&q=barack+obama', | 42 url='https://www.google.com/#hl=en&q=barack+obama', |
| 43 page_set=page_set) | 43 page_set=page_set) |
| 44 | 44 |
| 45 def RunNavigateSteps(self, action_runner): | 45 def RunNavigateSteps(self, action_runner): |
| 46 action_runner.NavigateToPage(self) | 46 action_runner.NavigateToPage(self) |
| 47 action_runner.WaitForElement(text='Next') | 47 action_runner.WaitForElement(text='Next') |
| 48 | 48 |
| 49 def RunStressMemory(self, action_runner): | |
| 50 interaction = action_runner.BeginGestureInteraction( | |
| 51 'ScrollAction', is_smooth=True) | |
| 52 action_runner.ScrollPage() | |
| 53 interaction.End() | |
| 54 old_href = _GetCurrentLocation(action_runner) | |
| 55 action_runner.ClickElement(text='Next') | |
| 56 _WaitForLocationChange(action_runner, old_href) | |
| 57 action_runner.WaitForElement(text='Next') | |
| 58 interaction = action_runner.BeginGestureInteraction( | |
| 59 'ScrollAction', is_smooth=True) | |
| 60 action_runner.ScrollPage() | |
| 61 interaction.End() | |
| 62 old_href = _GetCurrentLocation(action_runner) | |
| 63 action_runner.ClickElement(text='Next') | |
| 64 _WaitForLocationChange(action_runner, old_href) | |
| 65 action_runner.WaitForElement(text='Next') | |
| 66 interaction = action_runner.BeginGestureInteraction( | |
| 67 'ScrollAction', is_smooth=True) | |
| 68 action_runner.ScrollPage() | |
| 69 interaction.End() | |
| 70 old_href = _GetCurrentLocation(action_runner) | |
| 71 action_runner.ClickElement(text='Next') | |
| 72 _WaitForLocationChange(action_runner, old_href) | |
| 73 action_runner.WaitForElement(text='Previous') | |
| 74 interaction = action_runner.BeginGestureInteraction( | |
| 75 'ScrollAction', is_smooth=True) | |
| 76 action_runner.ScrollPage() | |
| 77 interaction.End() | |
| 78 old_href = _GetCurrentLocation(action_runner) | |
| 79 action_runner.ClickElement(text='Previous') | |
| 80 _WaitForLocationChange(action_runner, old_href) | |
| 81 action_runner.WaitForElement(text='Previous') | |
| 82 interaction = action_runner.BeginGestureInteraction( | |
| 83 'ScrollAction', is_smooth=True) | |
| 84 action_runner.ScrollPage() | |
| 85 interaction.End() | |
| 86 old_href = _GetCurrentLocation(action_runner) | |
| 87 action_runner.ClickElement(text='Previous') | |
| 88 _WaitForLocationChange(action_runner, old_href) | |
| 89 action_runner.WaitForElement(text='Previous') | |
| 90 interaction = action_runner.BeginGestureInteraction( | |
| 91 'ScrollAction', is_smooth=True) | |
| 92 action_runner.ScrollPage() | |
| 93 interaction.End() | |
| 94 old_href = _GetCurrentLocation(action_runner) | |
| 95 action_runner.ClickElement(text='Previous') | |
| 96 _WaitForLocationChange(action_runner, old_href) | |
| 97 action_runner.WaitForElement(text='Images') | |
| 98 interaction = action_runner.BeginGestureInteraction( | |
| 99 'ScrollAction', is_smooth=True) | |
| 100 action_runner.ScrollPage() | |
| 101 interaction.End() | |
| 102 old_href = _GetCurrentLocation(action_runner) | |
| 103 action_runner.ClickElement(text='Images') | |
| 104 _WaitForLocationChange(action_runner, old_href) | |
| 105 action_runner.WaitForElement(text='Images') | |
| 106 | |
| 107 | 49 |
| 108 class GmailPage(Top25Page): | 50 class GmailPage(Top25Page): |
| 109 | 51 |
| 110 """ Why: productivity, top google properties """ | 52 """ Why: productivity, top google properties """ |
| 111 | 53 |
| 112 def __init__(self, page_set): | 54 def __init__(self, page_set): |
| 113 super(GmailPage, self).__init__( | 55 super(GmailPage, self).__init__( |
| 114 url='https://mail.google.com/mail/', | 56 url='https://mail.google.com/mail/', |
| 115 page_set=page_set) | 57 page_set=page_set) |
| 116 | 58 |
| 117 self.credentials = 'google' | 59 self.credentials = 'google' |
| 118 | 60 |
| 119 def RunNavigateSteps(self, action_runner): | 61 def RunNavigateSteps(self, action_runner): |
| 120 action_runner.NavigateToPage(self) | 62 action_runner.NavigateToPage(self) |
| 121 action_runner.WaitForJavaScriptCondition( | 63 action_runner.WaitForJavaScriptCondition( |
| 122 'window.gmonkey !== undefined &&' | 64 'window.gmonkey !== undefined &&' |
| 123 'document.getElementById("gb") !== null') | 65 'document.getElementById("gb") !== null') |
| 124 | 66 |
| 125 def RunStressMemory(self, action_runner): | |
| 126 old_href = _GetCurrentLocation(action_runner) | |
| 127 action_runner.ClickElement( | |
| 128 'a[href="https://mail.google.com/mail/u/0/?shva=1#starred"]') | |
| 129 _WaitForLocationChange(action_runner, old_href) | |
| 130 old_href = _GetCurrentLocation(action_runner) | |
| 131 action_runner.ClickElement( | |
| 132 'a[href="https://mail.google.com/mail/u/0/?shva=1#inbox"]') | |
| 133 _WaitForLocationChange(action_runner, old_href) | |
| 134 | |
| 135 def RunSmoothness(self, action_runner): | 67 def RunSmoothness(self, action_runner): |
| 136 action_runner.ExecuteJavaScript(''' | 68 action_runner.ExecuteJavaScript(''' |
| 137 gmonkey.load('2.0', function(api) { | 69 gmonkey.load('2.0', function(api) { |
| 138 window.__scrollableElementForTelemetry = api.getScrollableElement(); | 70 window.__scrollableElementForTelemetry = api.getScrollableElement(); |
| 139 });''') | 71 });''') |
| 140 action_runner.WaitForJavaScriptCondition( | 72 action_runner.WaitForJavaScriptCondition( |
| 141 'window.__scrollableElementForTelemetry != null') | 73 'window.__scrollableElementForTelemetry != null') |
| 142 interaction = action_runner.BeginGestureInteraction( | 74 interaction = action_runner.BeginGestureInteraction( |
| 143 'ScrollAction', is_smooth=True) | 75 'ScrollAction', is_smooth=True) |
| 144 action_runner.ScrollElement( | 76 action_runner.ScrollElement( |
| (...skipping 18 matching lines...) Expand all Loading... |
| 163 action_runner.WaitForElement('div[class~="navForward"]') | 95 action_runner.WaitForElement('div[class~="navForward"]') |
| 164 action_runner.ExecuteJavaScript(''' | 96 action_runner.ExecuteJavaScript(''' |
| 165 (function() { | 97 (function() { |
| 166 var elem = document.createElement('meta'); | 98 var elem = document.createElement('meta'); |
| 167 elem.name='viewport'; | 99 elem.name='viewport'; |
| 168 elem.content='initial-scale=1'; | 100 elem.content='initial-scale=1'; |
| 169 document.body.appendChild(elem); | 101 document.body.appendChild(elem); |
| 170 })();''') | 102 })();''') |
| 171 action_runner.Wait(1) | 103 action_runner.Wait(1) |
| 172 | 104 |
| 173 def RunStressMemory(self, action_runner): | |
| 174 action_runner.ClickElement('div[class~="navForward"]') | |
| 175 action_runner.Wait(2) | |
| 176 action_runner.WaitForElement('div[class~="navForward"]') | |
| 177 action_runner.ClickElement('div[class~="navForward"]') | |
| 178 action_runner.Wait(2) | |
| 179 action_runner.WaitForElement('div[class~="navForward"]') | |
| 180 action_runner.ClickElement('div[class~="navForward"]') | |
| 181 action_runner.Wait(2) | |
| 182 action_runner.WaitForElement('div[class~="navForward"]') | |
| 183 action_runner.ClickElement('div[class~="navForward"]') | |
| 184 action_runner.Wait(2) | |
| 185 action_runner.WaitForElement('div[class~="navBack"]') | |
| 186 action_runner.ClickElement('div[class~="navBack"]') | |
| 187 action_runner.Wait(2) | |
| 188 action_runner.WaitForElement('div[class~="navBack"]') | |
| 189 action_runner.ClickElement('div[class~="navBack"]') | |
| 190 action_runner.Wait(2) | |
| 191 action_runner.WaitForElement('div[class~="navBack"]') | |
| 192 action_runner.ClickElement('div[class~="navBack"]') | |
| 193 action_runner.Wait(2) | |
| 194 action_runner.WaitForElement('div[class~="navBack"]') | |
| 195 action_runner.ClickElement('div[class~="navBack"]') | |
| 196 action_runner.Wait(2) | |
| 197 action_runner.WaitForElement('div[class~="navBack"]') | |
| 198 | |
| 199 def RunSmoothness(self, action_runner): | 105 def RunSmoothness(self, action_runner): |
| 200 interaction = action_runner.BeginGestureInteraction( | 106 interaction = action_runner.BeginGestureInteraction( |
| 201 'ScrollAction', is_smooth=True) | 107 'ScrollAction', is_smooth=True) |
| 202 action_runner.ScrollElement(selector='#scrolltimedeventswk') | 108 action_runner.ScrollElement(selector='#scrolltimedeventswk') |
| 203 interaction.End() | 109 interaction.End() |
| 204 | 110 |
| 205 | 111 |
| 206 class GoogleImageSearchPage(Top25Page): | 112 class GoogleImageSearchPage(Top25Page): |
| 207 | 113 |
| 208 """ Why: tough image case; top google properties """ | 114 """ Why: tough image case; top google properties """ |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 super(GooglePlusPage, self).__init__( | 155 super(GooglePlusPage, self).__init__( |
| 250 url='https://plus.google.com/110031535020051778989/posts', | 156 url='https://plus.google.com/110031535020051778989/posts', |
| 251 page_set=page_set) | 157 page_set=page_set) |
| 252 | 158 |
| 253 self.credentials = 'google' | 159 self.credentials = 'google' |
| 254 | 160 |
| 255 def RunNavigateSteps(self, action_runner): | 161 def RunNavigateSteps(self, action_runner): |
| 256 action_runner.NavigateToPage(self) | 162 action_runner.NavigateToPage(self) |
| 257 action_runner.WaitForElement(text='Home') | 163 action_runner.WaitForElement(text='Home') |
| 258 | 164 |
| 259 def RunStressMemory(self, action_runner): | |
| 260 action_runner.ClickElement(text='Home') | |
| 261 action_runner.Wait(2) | |
| 262 action_runner.WaitForElement(text='Profile') | |
| 263 action_runner.ClickElement(text='Profile') | |
| 264 action_runner.Wait(2) | |
| 265 action_runner.WaitForElement(text='Explore') | |
| 266 action_runner.ClickElement(text='Explore') | |
| 267 action_runner.Wait(2) | |
| 268 action_runner.WaitForElement(text='Events') | |
| 269 action_runner.ClickElement(text='Events') | |
| 270 action_runner.Wait(2) | |
| 271 action_runner.WaitForElement(text='Communities') | |
| 272 action_runner.ClickElement(text='Communities') | |
| 273 action_runner.Wait(2) | |
| 274 action_runner.WaitForElement(text='Home') | |
| 275 | |
| 276 def RunSmoothness(self, action_runner): | 165 def RunSmoothness(self, action_runner): |
| 277 interaction = action_runner.BeginGestureInteraction( | 166 interaction = action_runner.BeginGestureInteraction( |
| 278 'ScrollAction', is_smooth=True) | 167 'ScrollAction', is_smooth=True) |
| 279 action_runner.ScrollPage() | 168 action_runner.ScrollPage() |
| 280 interaction.End() | 169 interaction.End() |
| 281 | 170 |
| 282 | 171 |
| 283 class YoutubePage(Top25Page): | 172 class YoutubePage(Top25Page): |
| 284 | 173 |
| 285 """ Why: #3 (Alexa global) """ | 174 """ Why: #3 (Alexa global) """ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 304 def __init__(self, page_set): | 193 def __init__(self, page_set): |
| 305 super(BlogspotPage, self).__init__( | 194 super(BlogspotPage, self).__init__( |
| 306 url='http://googlewebmastercentral.blogspot.com/', | 195 url='http://googlewebmastercentral.blogspot.com/', |
| 307 page_set=page_set, | 196 page_set=page_set, |
| 308 name='Blogger') | 197 name='Blogger') |
| 309 | 198 |
| 310 def RunNavigateSteps(self, action_runner): | 199 def RunNavigateSteps(self, action_runner): |
| 311 action_runner.NavigateToPage(self) | 200 action_runner.NavigateToPage(self) |
| 312 action_runner.WaitForElement(text='accessibility') | 201 action_runner.WaitForElement(text='accessibility') |
| 313 | 202 |
| 314 def RunStressMemory(self, action_runner): | |
| 315 action_runner.ClickElement(text='accessibility') | |
| 316 action_runner.WaitForNavigate() | |
| 317 interaction = action_runner.BeginGestureInteraction( | |
| 318 'ScrollAction', is_smooth=True) | |
| 319 action_runner.ScrollPage() | |
| 320 interaction.End() | |
| 321 action_runner.ClickElement(text='advanced') | |
| 322 action_runner.WaitForNavigate() | |
| 323 interaction = action_runner.BeginGestureInteraction( | |
| 324 'ScrollAction', is_smooth=True) | |
| 325 action_runner.ScrollPage() | |
| 326 interaction.End() | |
| 327 action_runner.ClickElement(text='beginner') | |
| 328 action_runner.WaitForNavigate() | |
| 329 interaction = action_runner.BeginGestureInteraction( | |
| 330 'ScrollAction', is_smooth=True) | |
| 331 action_runner.ScrollPage() | |
| 332 interaction.End() | |
| 333 action_runner.ClickElement(text='Home') | |
| 334 action_runner.WaitForNavigate() | |
| 335 | |
| 336 | 203 |
| 337 class WordpressPage(Top25Page): | 204 class WordpressPage(Top25Page): |
| 338 | 205 |
| 339 """ Why: #18 (Alexa global), Picked an interesting post """ | 206 """ Why: #18 (Alexa global), Picked an interesting post """ |
| 340 | 207 |
| 341 def __init__(self, page_set): | 208 def __init__(self, page_set): |
| 342 super(WordpressPage, self).__init__( | 209 super(WordpressPage, self).__init__( |
| 343 # pylint: disable=C0301 | 210 # pylint: disable=C0301 |
| 344 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks
-for-august-2012/', | 211 url='http://en.blog.wordpress.com/2012/09/04/freshly-pressed-editors-picks
-for-august-2012/', |
| 345 page_set=page_set, | 212 page_set=page_set, |
| 346 name='Wordpress') | 213 name='Wordpress') |
| 347 | 214 |
| 348 def RunNavigateSteps(self, action_runner): | 215 def RunNavigateSteps(self, action_runner): |
| 349 action_runner.NavigateToPage(self) | 216 action_runner.NavigateToPage(self) |
| 350 action_runner.WaitForElement( | 217 action_runner.WaitForElement( |
| 351 # pylint: disable=C0301 | 218 # pylint: disable=C0301 |
| 352 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sig
ht/"]') | 219 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sig
ht/"]') |
| 353 | 220 |
| 354 def RunStressMemory(self, action_runner): | |
| 355 interaction = action_runner.BeginGestureInteraction( | |
| 356 'ScrollAction', is_smooth=True) | |
| 357 action_runner.ScrollPage() | |
| 358 interaction.End() | |
| 359 action_runner.ClickElement( | |
| 360 # pylint: disable=C0301 | |
| 361 'a[href="http://en.blog.wordpress.com/2012/08/30/new-themes-able-and-sig
ht/"]') | |
| 362 action_runner.WaitForNavigate() | |
| 363 interaction = action_runner.BeginGestureInteraction( | |
| 364 'ScrollAction', is_smooth=True) | |
| 365 action_runner.ScrollPage() | |
| 366 interaction.End() | |
| 367 action_runner.ClickElement(text='Features') | |
| 368 action_runner.WaitForNavigate() | |
| 369 interaction = action_runner.BeginGestureInteraction( | |
| 370 'ScrollAction', is_smooth=True) | |
| 371 action_runner.ScrollPage() | |
| 372 interaction.End() | |
| 373 action_runner.ClickElement(text='News') | |
| 374 action_runner.WaitForNavigate() | |
| 375 interaction = action_runner.BeginGestureInteraction( | |
| 376 'ScrollAction', is_smooth=True) | |
| 377 action_runner.ScrollPage() | |
| 378 interaction.End() | |
| 379 | |
| 380 | |
| 381 class FacebookPage(Top25Page): | 221 class FacebookPage(Top25Page): |
| 382 | 222 |
| 383 """ Why: top social,Public profile """ | 223 """ Why: top social,Public profile """ |
| 384 | 224 |
| 385 def __init__(self, page_set): | 225 def __init__(self, page_set): |
| 386 super(FacebookPage, self).__init__( | 226 super(FacebookPage, self).__init__( |
| 387 url='http://www.facebook.com/barackobama', | 227 url='http://www.facebook.com/barackobama', |
| 388 page_set=page_set, | 228 page_set=page_set, |
| 389 name='Facebook') | 229 name='Facebook') |
| 390 self.credentials = 'facebook' | 230 self.credentials = 'facebook' |
| 391 | 231 |
| 392 def RunNavigateSteps(self, action_runner): | 232 def RunNavigateSteps(self, action_runner): |
| 393 action_runner.NavigateToPage(self) | 233 action_runner.NavigateToPage(self) |
| 394 action_runner.WaitForElement(text='About') | 234 action_runner.WaitForElement(text='About') |
| 395 | 235 |
| 396 def RunStressMemory(self, action_runner): | |
| 397 action_runner.ClickElement(text='About') | |
| 398 action_runner.WaitForNavigate() | |
| 399 action_runner.ClickElement(text='The Audacity of Hope') | |
| 400 action_runner.WaitForNavigate() | |
| 401 action_runner.ClickElement(text='Back to Barack Obama\'s Timeline') | |
| 402 action_runner.WaitForNavigate() | |
| 403 action_runner.ClickElement(text='About') | |
| 404 action_runner.WaitForNavigate() | |
| 405 action_runner.ClickElement(text='Elected to U.S. Senate') | |
| 406 action_runner.WaitForNavigate() | |
| 407 action_runner.ClickElement(text='Home') | |
| 408 action_runner.WaitForNavigate() | |
| 409 | |
| 410 def RunSmoothness(self, action_runner): | 236 def RunSmoothness(self, action_runner): |
| 411 interaction = action_runner.BeginGestureInteraction( | 237 interaction = action_runner.BeginGestureInteraction( |
| 412 'ScrollAction', is_smooth=True) | 238 'ScrollAction', is_smooth=True) |
| 413 action_runner.ScrollPage() | 239 action_runner.ScrollPage() |
| 414 interaction.End() | 240 interaction.End() |
| 415 | 241 |
| 416 | 242 |
| 417 class LinkedinPage(Top25Page): | 243 class LinkedinPage(Top25Page): |
| 418 | 244 |
| 419 """ Why: #12 (Alexa global),Public profile """ | 245 """ Why: #12 (Alexa global),Public profile """ |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 560 # Why: #1 Alexa reference | 386 # Why: #1 Alexa reference |
| 561 'http://answers.yahoo.com', | 387 'http://answers.yahoo.com', |
| 562 # Why: #1 Alexa sports | 388 # Why: #1 Alexa sports |
| 563 'http://sports.yahoo.com/', | 389 'http://sports.yahoo.com/', |
| 564 # Why: top tech blog | 390 # Why: top tech blog |
| 565 'http://techcrunch.com' | 391 'http://techcrunch.com' |
| 566 ] | 392 ] |
| 567 | 393 |
| 568 for url in other_urls: | 394 for url in other_urls: |
| 569 self.AddPage(Top25Page(url, self)) | 395 self.AddPage(Top25Page(url, self)) |
| OLD | NEW |