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
3 # found in the LICENSE file.
4 from telemetry
.page
import page
as page_module
5 from telemetry
.page
import page_set
as page_set_module
8 class KeySilkCasesPage(page_module
.Page
):
10 def __init__(self
, url
, page_set
):
11 super(KeySilkCasesPage
, self
).__init
__(
12 url
=url
, page_set
=page_set
, credentials_path
= 'data/credentials.json')
13 self
.user_agent_type
= 'mobile'
14 self
.archive_data_file
= 'data/key_silk_cases.json'
16 def RunNavigateSteps(self
, action_runner
):
17 super(KeySilkCasesPage
, self
).RunNavigateSteps(action_runner
)
20 def RunPageInteractions(self
, action_runner
):
21 interaction
= action_runner
.BeginGestureInteraction(
22 'ScrollAction', is_smooth
=True)
23 action_runner
.ScrollPage()
27 class Page1(KeySilkCasesPage
):
29 """ Why: Infinite scroll. Brings out all of our perf issues. """
31 def __init__(self
, page_set
):
32 super(Page1
, self
).__init
__(
33 url
='http://groupcloned.com/test/plain/list-recycle-transform.html',
36 def RunPageInteractions(self
, action_runner
):
37 interaction
= action_runner
.BeginGestureInteraction(
38 'ScrollAction', is_smooth
=True)
39 action_runner
.ScrollElement(selector
='#scrollable')
43 class Page2(KeySilkCasesPage
):
45 """ Why: Brings out layer management bottlenecks. """
47 def __init__(self
, page_set
):
48 super(Page2
, self
).__init
__(
49 url
='http://groupcloned.com/test/plain/list-animation-simple.html',
52 def RunPageInteractions(self
, action_runner
):
56 class Page3(KeySilkCasesPage
):
59 Why: Best-known method for fake sticky. Janks sometimes. Interacts badly with
63 def __init__(self
, page_set
):
64 super(Page3
, self
).__init
__(
65 # pylint: disable=C0301
66 url
='http://groupcloned.com/test/plain/sticky-using-webkit-backface-visibility.html',
69 def RunPageInteractions(self
, action_runner
):
70 interaction
= action_runner
.BeginGestureInteraction(
71 'ScrollAction', is_smooth
=True)
72 action_runner
.ScrollElement(selector
='#container')
76 class Page4(KeySilkCasesPage
):
79 Why: Card expansion: only the card should repaint, but in reality lots of
83 def __init__(self
, page_set
):
84 super(Page4
, self
).__init
__(
85 url
='http://jsfiddle.net/3yDKh/15/show/',
88 def RunPageInteractions(self
, action_runner
):
92 class Page5(KeySilkCasesPage
):
95 Why: Card expansion with animated contents, using will-change on the card
98 def __init__(self
, page_set
):
99 super(Page5
, self
).__init
__(
100 url
='http://jsfiddle.net/jx5De/14/show/',
103 self
.gpu_raster
= True
105 def RunPageInteractions(self
, action_runner
):
106 action_runner
.Wait(4)
109 class Page6(KeySilkCasesPage
):
112 Why: Card fly-in: It should be fast to animate in a bunch of cards using
113 margin-top and letting layout do the rest.
116 def __init__(self
, page_set
):
117 super(Page6
, self
).__init
__(
118 url
='http://jsfiddle.net/3yDKh/16/show/',
121 def RunPageInteractions(self
, action_runner
):
122 action_runner
.Wait(3)
125 class Page7(KeySilkCasesPage
):
128 Why: Image search expands a spacer div when you click an image to accomplish
129 a zoomin effect. Each image has a layer. Even so, this triggers a lot of
130 unnecessary repainting.
133 def __init__(self
, page_set
):
134 super(Page7
, self
).__init
__(
135 url
='http://jsfiddle.net/R8DX9/4/show/',
138 def RunPageInteractions(self
, action_runner
):
139 action_runner
.Wait(3)
142 class Page8(KeySilkCasesPage
):
145 Why: Swipe to dismiss of an element that has a fixed-position child that is
146 its pseudo-sticky header. Brings out issues with layer creation and
150 def __init__(self
, page_set
):
151 super(Page8
, self
).__init
__(
152 url
='http://jsfiddle.net/rF9Gh/7/show/',
155 def RunPageInteractions(self
, action_runner
):
156 action_runner
.Wait(3)
159 class Page9(KeySilkCasesPage
):
162 Why: Horizontal and vertical expansion of a card that is cheap to layout but
166 def __init__(self
, page_set
):
167 super(Page9
, self
).__init
__(
168 url
='http://jsfiddle.net/TLXLu/3/show/',
171 self
.gpu_raster
= True
173 def RunPageInteractions(self
, action_runner
):
174 action_runner
.Wait(4)
177 class Page10(KeySilkCasesPage
):
180 Why: Vertical Expansion of a card that is cheap to layout but costly to
184 def __init__(self
, page_set
):
185 super(Page10
, self
).__init
__(
186 url
='http://jsfiddle.net/cKB9D/7/show/',
189 self
.gpu_raster
= True
191 def RunPageInteractions(self
, action_runner
):
192 action_runner
.Wait(4)
195 class Page11(KeySilkCasesPage
):
198 Why: Parallax effect is common on photo-viewer-like applications, overloading
199 software rasterization
202 def __init__(self
, page_set
):
203 super(Page11
, self
).__init
__(
204 url
='http://jsfiddle.net/vBQHH/11/show/',
207 self
.gpu_raster
= True
209 def RunPageInteractions(self
, action_runner
):
210 action_runner
.Wait(4)
213 class Page12(KeySilkCasesPage
):
215 """ Why: Addressing paint storms during coordinated animations. """
217 def __init__(self
, page_set
):
218 super(Page12
, self
).__init
__(
219 url
='http://jsfiddle.net/ugkd4/10/show/',
222 def RunPageInteractions(self
, action_runner
):
223 action_runner
.Wait(5)
226 class Page13(KeySilkCasesPage
):
228 """ Why: Mask transitions are common mobile use cases. """
230 def __init__(self
, page_set
):
231 super(Page13
, self
).__init
__(
232 url
='http://jsfiddle.net/xLuvC/1/show/',
235 self
.gpu_raster
= True
237 def RunPageInteractions(self
, action_runner
):
238 action_runner
.Wait(4)
241 class Page14(KeySilkCasesPage
):
243 """ Why: Card expansions with images and text are pretty and common. """
245 def __init__(self
, page_set
):
246 super(Page14
, self
).__init
__(
247 url
='http://jsfiddle.net/bNp2h/3/show/',
250 self
.gpu_raster
= True
252 def RunPageInteractions(self
, action_runner
):
253 action_runner
.Wait(4)
256 class Page15(KeySilkCasesPage
):
258 """ Why: Coordinated animations for expanding elements. """
260 def __init__(self
, page_set
):
261 super(Page15
, self
).__init
__(
262 url
='file://key_silk_cases/font_wipe.html',
265 def RunPageInteractions(self
, action_runner
):
266 action_runner
.Wait(5)
269 class Page16(KeySilkCasesPage
):
271 def __init__(self
, page_set
):
272 super(Page16
, self
).__init
__(
273 url
='file://key_silk_cases/inbox_app.html?swipe_to_dismiss',
276 def SwipeToDismiss(self
, action_runner
):
277 interaction
= action_runner
.BeginGestureInteraction(
278 'SwipeAction', is_smooth
=True)
279 action_runner
.SwipeElement(
280 left_start_ratio
=0.8, top_start_ratio
=0.2,
281 direction
='left', distance
=400, speed_in_pixels_per_second
=5000,
282 element_function
='document.getElementsByClassName("message")[2]')
285 def RunPageInteractions(self
, action_runner
):
286 self
.SwipeToDismiss(action_runner
)
289 class Page17(KeySilkCasesPage
):
291 def __init__(self
, page_set
):
292 super(Page17
, self
).__init
__(
293 url
='file://key_silk_cases/inbox_app.html?stress_hidey_bars',
296 def RunPageInteractions(self
, action_runner
):
297 self
.StressHideyBars(action_runner
)
299 def StressHideyBars(self
, action_runner
):
300 interaction
= action_runner
.BeginGestureInteraction(
301 'ScrollAction', is_smooth
=True)
302 action_runner
.ScrollElement(
303 selector
='#messages', direction
='down', speed_in_pixels_per_second
=200)
305 interaction
= action_runner
.BeginGestureInteraction(
306 'ScrollAction', is_smooth
=True)
307 action_runner
.ScrollElement(
308 selector
='#messages', direction
='up', speed_in_pixels_per_second
=200)
310 interaction
= action_runner
.BeginGestureInteraction(
311 'ScrollAction', is_smooth
=True)
312 action_runner
.ScrollElement(
313 selector
='#messages', direction
='down', speed_in_pixels_per_second
=200)
317 class Page18(KeySilkCasesPage
):
319 def __init__(self
, page_set
):
320 super(Page18
, self
).__init
__(
321 url
='file://key_silk_cases/inbox_app.html?toggle_drawer',
324 def RunPageInteractions(self
, action_runner
):
326 self
.ToggleDrawer(action_runner
)
328 def ToggleDrawer(self
, action_runner
):
329 interaction
= action_runner
.BeginInteraction(
330 'Action_TapAction', is_smooth
=True)
331 action_runner
.TapElement('#menu-button')
332 action_runner
.Wait(1)
336 class Page19(KeySilkCasesPage
):
338 def __init__(self
, page_set
):
339 super(Page19
, self
).__init
__(
340 url
='file://key_silk_cases/inbox_app.html?slide_drawer',
343 def ToggleDrawer(self
, action_runner
):
344 interaction
= action_runner
.BeginGestureInteraction(
345 'TapAction', is_smooth
=True)
346 action_runner
.TapElement('#menu-button')
349 interaction
= action_runner
.BeginInteraction('Wait', is_smooth
=True)
350 action_runner
.WaitForJavaScriptCondition('''
351 document.getElementById("nav-drawer").active &&
352 document.getElementById("nav-drawer").children[0]
353 .getBoundingClientRect().left == 0''')
356 def RunNavigateSteps(self
, action_runner
):
357 super(Page19
, self
).RunNavigateSteps(action_runner
)
358 action_runner
.Wait(2)
359 self
.ToggleDrawer(action_runner
)
361 def RunPageInteractions(self
, action_runner
):
362 self
.SlideDrawer(action_runner
)
364 def SlideDrawer(self
, action_runner
):
365 interaction
= action_runner
.BeginInteraction(
366 'Action_SwipeAction', is_smooth
=True)
367 action_runner
.SwipeElement(
368 left_start_ratio
=0.8, top_start_ratio
=0.2,
369 direction
='left', distance
=200,
370 element_function
='document.getElementById("nav-drawer").children[0]')
371 action_runner
.WaitForJavaScriptCondition(
372 '!document.getElementById("nav-drawer").active')
376 class Page20(KeySilkCasesPage
):
378 """ Why: Shadow DOM infinite scrolling. """
380 def __init__(self
, page_set
):
381 super(Page20
, self
).__init
__(
382 url
='file://key_silk_cases/infinite_scrolling.html',
385 def RunPageInteractions(self
, action_runner
):
386 interaction
= action_runner
.BeginGestureInteraction(
387 'ScrollAction', is_smooth
=True)
388 action_runner
.ScrollElement(
389 selector
='#container', speed_in_pixels_per_second
=5000)
393 class GwsExpansionPage(KeySilkCasesPage
):
394 """Abstract base class for pages that expand Google knowledge panels."""
396 def NavigateWait(self
, action_runner
):
397 super(GwsExpansionPage
, self
).RunNavigateSteps(action_runner
)
398 action_runner
.Wait(3)
400 def ExpandKnowledgeCard(self
, action_runner
):
402 interaction
= action_runner
.BeginInteraction(
403 'Action_TapAction', is_smooth
=True)
404 action_runner
.TapElement(
405 element_function
='document.getElementsByClassName("vk_arc")[0]')
406 action_runner
.Wait(2)
409 def ScrollKnowledgeCardToTop(self
, action_runner
, card_id
):
410 # scroll until the knowledge card is at the top
411 action_runner
.ExecuteJavaScript(
412 "document.getElementById('%s').scrollIntoView()" % card_id
)
414 def RunPageInteractions(self
, action_runner
):
415 self
.ExpandKnowledgeCard(action_runner
)
418 class GwsGoogleExpansion(GwsExpansionPage
):
420 """ Why: Animating height of a complex content card is common. """
422 def __init__(self
, page_set
):
423 super(GwsGoogleExpansion
, self
).__init
__(
424 url
='http://www.google.com/#q=google',
427 def RunNavigateSteps(self
, action_runner
):
428 self
.NavigateWait(action_runner
)
429 self
.ScrollKnowledgeCardToTop(action_runner
, 'kno-result')
432 class GwsBoogieExpansion(GwsExpansionPage
):
434 """ Why: Same case as Google expansion but text-heavy rather than image. """
436 def __init__(self
, page_set
):
437 super(GwsBoogieExpansion
, self
).__init
__(
438 url
='https://www.google.com/search?hl=en&q=define%3Aboogie',
441 def RunNavigateSteps(self
, action_runner
):
442 self
.NavigateWait(action_runner
)
443 self
.ScrollKnowledgeCardToTop(action_runner
, 'rso')
446 class Page22(KeySilkCasesPage
):
448 def __init__(self
, page_set
):
449 super(Page22
, self
).__init
__(
450 url
='http://plus.google.com/app/basic/stream',
453 self
.credentials
= 'google'
455 def RunNavigateSteps(self
, action_runner
):
456 super(Page22
, self
).RunNavigateSteps(action_runner
)
457 action_runner
.WaitForJavaScriptCondition(
458 'document.getElementsByClassName("fHa").length > 0')
459 action_runner
.Wait(2)
461 def RunPageInteractions(self
, action_runner
):
462 interaction
= action_runner
.BeginGestureInteraction(
463 'ScrollAction', is_smooth
=True)
464 action_runner
.ScrollElement(selector
='#mainContent')
468 class Page23(KeySilkCasesPage
):
471 Why: Physical simulation demo that does a lot of element.style mutation
472 triggering JS and recalc slowness
475 def __init__(self
, page_set
):
476 super(Page23
, self
).__init
__(
477 url
='http://jsbin.com/UVIgUTa/38/quiet',
480 def RunPageInteractions(self
, action_runner
):
481 interaction
= action_runner
.BeginGestureInteraction(
482 'ScrollAction', is_smooth
=True)
483 action_runner
.ScrollPage(
484 distance_expr
='window.innerHeight / 2',
488 interaction
= action_runner
.BeginInteraction('Wait', is_smooth
=True)
489 action_runner
.Wait(1)
493 class Page24(KeySilkCasesPage
):
496 Why: Google News: this iOS version is slower than accelerated scrolling
499 def __init__(self
, page_set
):
500 super(Page24
, self
).__init
__(
501 url
='http://mobile-news.sandbox.google.com/news/pt0?scroll',
504 def RunNavigateSteps(self
, action_runner
):
505 super(Page24
, self
).RunNavigateSteps(action_runner
)
506 action_runner
.WaitForJavaScriptCondition(
507 'document.getElementById(":h") != null')
508 action_runner
.Wait(1)
510 def RunPageInteractions(self
, action_runner
):
511 interaction
= action_runner
.BeginGestureInteraction(
512 'ScrollAction', is_smooth
=True)
513 action_runner
.ScrollElement(
514 element_function
='document.getElementById(":5")',
520 class Page25(KeySilkCasesPage
):
522 def __init__(self
, page_set
):
523 super(Page25
, self
).__init
__(
524 url
='http://mobile-news.sandbox.google.com/news/pt0?swipe',
527 def RunNavigateSteps(self
, action_runner
):
528 super(Page25
, self
).RunNavigateSteps(action_runner
)
529 action_runner
.WaitForJavaScriptCondition(
530 'document.getElementById(":h") != null')
531 action_runner
.Wait(1)
533 def RunPageInteractions(self
, action_runner
):
534 interaction
= action_runner
.BeginGestureInteraction(
535 'SwipeAction', is_smooth
=True)
536 action_runner
.SwipeElement(
537 direction
='left', distance
=100,
538 element_function
='document.getElementById(":f")')
540 interaction
= action_runner
.BeginInteraction('Wait', is_smooth
=True)
541 action_runner
.Wait(1)
545 class Page26(KeySilkCasesPage
):
547 """ Why: famo.us twitter demo """
549 def __init__(self
, page_set
):
550 super(Page26
, self
).__init
__(
551 url
='http://s.codepen.io/befamous/fullpage/pFsqb?scroll',
554 def RunNavigateSteps(self
, action_runner
):
555 super(Page26
, self
).RunNavigateSteps(action_runner
)
556 action_runner
.WaitForJavaScriptCondition(
557 'document.getElementsByClassName("tweet").length > 0')
558 action_runner
.Wait(1)
560 def RunPageInteractions(self
, action_runner
):
561 interaction
= action_runner
.BeginGestureInteraction(
562 'ScrollAction', is_smooth
=True)
563 action_runner
.ScrollPage(distance
=5000)
567 class SVGIconRaster(KeySilkCasesPage
):
569 """ Why: Mutating SVG icons; these paint storm and paint slowly. """
571 def __init__(self
, page_set
):
572 super(SVGIconRaster
, self
).__init
__(
573 url
='http://wiltzius.github.io/shape-shifter/',
576 def RunNavigateSteps(self
, action_runner
):
577 super(SVGIconRaster
, self
).RunNavigateSteps(action_runner
)
578 action_runner
.WaitForJavaScriptCondition(
580 action_runner
.Wait(1)
582 def RunPageInteractions(self
, action_runner
):
584 button_func
= ('document.getElementById("demo").$.'
585 'buttons.children[%d]') % i
586 interaction
= action_runner
.BeginInteraction(
587 'Action_TapAction', is_smooth
=True)
588 action_runner
.TapElement(element_function
=button_func
)
589 action_runner
.Wait(1)
593 class UpdateHistoryState(KeySilkCasesPage
):
595 """ Why: Modern apps often update history state, which currently is janky."""
597 def __init__(self
, page_set
):
598 super(UpdateHistoryState
, self
).__init
__(
599 url
='file://key_silk_cases/pushState.html',
602 def RunNavigateSteps(self
, action_runner
):
603 super(UpdateHistoryState
, self
).RunNavigateSteps(action_runner
)
604 action_runner
.ExecuteJavaScript('''
605 window.requestAnimationFrame(function() {
606 window.__history_state_loaded = true;
609 action_runner
.WaitForJavaScriptCondition(
610 'window.__history_state_loaded == true;')
612 def RunPageInteractions(self
, action_runner
):
613 interaction
= action_runner
.BeginInteraction('animation_interaction',
615 action_runner
.Wait(5) # JS runs the animation continuously on the page
619 class SilkFinance(KeySilkCasesPage
):
621 """ Why: Some effects repaint the page, possibly including plenty of text. """
623 def __init__(self
, page_set
):
624 super(SilkFinance
, self
).__init
__(
625 url
='file://key_silk_cases/silk_finance.html',
628 def RunPageInteractions(self
, action_runner
):
629 interaction
= action_runner
.BeginInteraction('animation_interaction',
631 action_runner
.Wait(10) # animation runs automatically
635 class KeySilkCasesPageSet(page_set_module
.PageSet
):
637 """ Pages hand-picked for project Silk. """
640 super(KeySilkCasesPageSet
, self
).__init
__(
641 user_agent_type
='mobile',
642 archive_data_file
='data/key_silk_cases.json',
643 bucket
=page_set_module
.PARTNER_BUCKET
)
645 self
.AddUserStory(Page1(self
))
646 self
.AddUserStory(Page2(self
))
647 self
.AddUserStory(Page3(self
))
648 self
.AddUserStory(Page4(self
))
649 self
.AddUserStory(Page5(self
))
650 self
.AddUserStory(Page6(self
))
651 self
.AddUserStory(Page7(self
))
652 self
.AddUserStory(Page8(self
))
653 self
.AddUserStory(Page9(self
))
654 self
.AddUserStory(Page10(self
))
655 self
.AddUserStory(Page11(self
))
656 self
.AddUserStory(Page12(self
))
657 self
.AddUserStory(Page13(self
))
658 self
.AddUserStory(Page14(self
))
659 self
.AddUserStory(Page15(self
))
660 self
.AddUserStory(Page16(self
))
661 self
.AddUserStory(Page17(self
))
662 self
.AddUserStory(Page18(self
))
663 # Missing frames during tap interaction; crbug.com/446332
664 # self.AddUserStory(Page19(self))
665 self
.AddUserStory(Page20(self
))
666 self
.AddUserStory(GwsGoogleExpansion(self
))
667 self
.AddUserStory(GwsBoogieExpansion(self
))
668 # Times out on Windows; crbug.com/338838
669 # self.AddUserStory(Page22(self))
670 self
.AddUserStory(Page23(self
))
671 self
.AddUserStory(Page24(self
))
672 self
.AddUserStory(Page25(self
))
673 self
.AddUserStory(Page26(self
))
674 self
.AddUserStory(SVGIconRaster(self
))
675 self
.AddUserStory(UpdateHistoryState(self
))
676 self
.AddUserStory(SilkFinance(self
))