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 # pylint: disable=W0401,W0614
5 from telemetry.page.actions.all_page_actions import *
6 from telemetry.page import page as page_module
7 from telemetry.page import page_set as page_set_module
8 from telemetry.web_perf import timeline_interaction_record as tir_module
11 class KeySilkCasesPage(page_module.Page):
13 def __init__(self, url, page_set):
14 super(KeySilkCasesPage, self).__init__(url=url, page_set=page_set)
15 self.credentials_path = 'data/credentials.json'
16 self.user_agent_type = 'mobile'
17 self.archive_data_file = 'data/key_silk_cases.json'
19 def RunNavigateSteps(self, action_runner):
20 action_runner.RunAction(NavigateAction())
21 action_runner.RunAction(WaitAction(
26 def RunSmoothness(self, action_runner):
27 action_runner.RunAction(ScrollAction())
30 class Page1(KeySilkCasesPage):
32 """ Why: Infinite scroll. Brings out all of our perf issues. """
34 def __init__(self, page_set):
35 super(Page1, self).__init__(
36 url='http://groupcloned.com/test/plain/list-recycle-transform.html',
39 def RunSmoothness(self, action_runner):
40 action_runner.RunAction(ScrollAction(
42 'scrollable_element_function': '''
44 callback(document.getElementById('scrollable'));
49 class Page2(KeySilkCasesPage):
51 """ Why: Brings out layer management bottlenecks. """
53 def __init__(self, page_set):
54 super(Page2, self).__init__(
55 url='http://groupcloned.com/test/plain/list-animation-simple.html',
58 def RunSmoothness(self, action_runner):
59 action_runner.RunAction(WaitAction({'seconds': 2}))
62 class Page3(KeySilkCasesPage):
65 Why: Best-known method for fake sticky. Janks sometimes. Interacts badly with
69 def __init__(self, page_set):
70 super(Page3, self).__init__(
71 # pylint: disable=C0301
72 url='http://groupcloned.com/test/plain/sticky-using-webkit-backface-visibility.html',
75 def RunSmoothness(self, action_runner):
76 action_runner.RunAction(ScrollAction(
78 'scrollable_element_function': '''
80 callback(document.getElementById('container'));
85 class Page4(KeySilkCasesPage):
88 Why: Card expansion: only the card should repaint, but in reality lots of
92 def __init__(self, page_set):
93 super(Page4, self).__init__(
94 url='http://jsfiddle.net/3yDKh/4/embedded/result',
97 def RunSmoothness(self, action_runner):
98 action_runner.RunAction(WaitAction({'seconds': 3}))
101 class Page5(KeySilkCasesPage):
104 Why: Card expansion with animated contents, using will-change on the card
107 def __init__(self, page_set):
108 super(Page5, self).__init__(
109 url='http://jsfiddle.net/jx5De/13/embedded/result',
112 self.gpu_raster = True
114 def RunSmoothness(self, action_runner):
115 action_runner.RunAction(WaitAction({'seconds': 4}))
118 class Page6(KeySilkCasesPage):
121 Why: Card fly-in: It should be fast to animate in a bunch of cards using
122 margin-top and letting layout do the rest.
125 def __init__(self, page_set):
126 super(Page6, self).__init__(
127 url='http://jsfiddle.net/3yDKh/6/embedded/result',
130 def RunSmoothness(self, action_runner):
131 action_runner.RunAction(WaitAction({'seconds': 3}))
134 class Page7(KeySilkCasesPage):
137 Why: Image search expands a spacer div when you click an image to accomplish
138 a zoomin effect. Each image has a layer. Even so, this triggers a lot of
139 unnecessary repainting.
142 def __init__(self, page_set):
143 super(Page7, self).__init__(
144 url='http://jsfiddle.net/R8DX9/1/embedded/result/',
147 def RunSmoothness(self, action_runner):
148 action_runner.RunAction(WaitAction({'seconds': 3}))
151 class Page8(KeySilkCasesPage):
154 Why: Swipe to dismiss of an element that has a fixed-position child that is
155 its pseudo-sticky header. Brings out issues with layer creation and
159 def __init__(self, page_set):
160 super(Page8, self).__init__(
161 url='http://jsfiddle.net/rF9Gh/3/embedded/result/',
164 def RunSmoothness(self, action_runner):
165 action_runner.RunAction(WaitAction({'seconds': 3}))
168 class Page9(KeySilkCasesPage):
171 Why: Horizontal and vertical expansion of a card that is cheap to layout but
175 def __init__(self, page_set):
176 super(Page9, self).__init__(
177 url='http://jsfiddle.net/TLXLu/2/embedded/result/',
180 self.gpu_raster = True
182 def RunSmoothness(self, action_runner):
183 action_runner.RunAction(WaitAction({'seconds': 4}))
186 class Page10(KeySilkCasesPage):
189 Why: Vertical Expansion of a card that is cheap to layout but costly to
193 def __init__(self, page_set):
194 super(Page10, self).__init__(
195 url='http://jsfiddle.net/cKB9D/6/embedded/result/',
198 self.gpu_raster = True
200 def RunSmoothness(self, action_runner):
201 action_runner.RunAction(WaitAction({'seconds': 4}))
204 class Page11(KeySilkCasesPage):
207 Why: Parallax effect is common on photo-viewer-like applications, overloading
208 software rasterization
211 def __init__(self, page_set):
212 super(Page11, self).__init__(
213 url='http://jsfiddle.net/vBQHH/10/embedded/result/',
216 self.gpu_raster = True
218 def RunSmoothness(self, action_runner):
219 action_runner.RunAction(WaitAction({'seconds': 4}))
222 class Page12(KeySilkCasesPage):
224 """ Why: Addressing paint storms during coordinated animations. """
226 def __init__(self, page_set):
227 super(Page12, self).__init__(
228 url='http://jsfiddle.net/ugkd4/9/embedded/result/',
231 def RunSmoothness(self, action_runner):
232 action_runner.RunAction(WaitAction({'seconds': 5}))
235 class Page13(KeySilkCasesPage):
237 """ Why: Mask transitions are common mobile use cases. """
239 def __init__(self, page_set):
240 super(Page13, self).__init__(
241 url='http://jsfiddle.net/xLuvC/embedded/result/',
244 self.gpu_raster = True
246 def RunSmoothness(self, action_runner):
247 action_runner.RunAction(WaitAction({'seconds': 4}))
250 class Page14(KeySilkCasesPage):
252 """ Why: Card expansions with images and text are pretty and common. """
254 def __init__(self, page_set):
255 super(Page14, self).__init__(
256 url='http://jsfiddle.net/bNp2h/1/embedded/result/',
259 self.gpu_raster = True
261 def RunSmoothness(self, action_runner):
262 action_runner.RunAction(WaitAction({'seconds': 4}))
265 class Page15(KeySilkCasesPage):
267 """ Why: Coordinated animations for expanding elements. """
269 def __init__(self, page_set):
270 super(Page15, self).__init__(
271 url='file://key_silk_cases/font_wipe.html',
274 def RunSmoothness(self, action_runner):
275 action_runner.RunAction(WaitAction({'seconds': 5}))
278 class Page16(KeySilkCasesPage):
280 def __init__(self, page_set):
281 super(Page16, self).__init__(
282 url='file://key_silk_cases/inbox_app.html?swipe_to_dismiss',
285 def RunNavigateSteps(self, action_runner):
286 action_runner.RunAction(NavigateAction())
287 action_runner.RunAction(WaitAction({'seconds': 2}))
289 def SwipeToDismiss(self, action_runner):
290 action_runner.RunAction(SwipeAction(
292 'left_start_percentage': 0.8,
295 'top_start_percentage': 0.2,
296 'element_function': '''
298 callback(document.getElementsByClassName('message')[2]);
302 action_runner.BeginInteraction('Wait', [tir_module.IS_SMOOTH])
303 action_runner.RunAction(WaitAction({
304 'javascript': 'document.getElementsByClassName("message").length < 18'
306 action_runner.EndInteraction('Wait', [tir_module.IS_SMOOTH])
308 def RunSmoothness(self, action_runner):
309 self.SwipeToDismiss(action_runner)
312 class Page17(KeySilkCasesPage):
314 def __init__(self, page_set):
315 super(Page17, self).__init__(
316 url='file://key_silk_cases/inbox_app.html?stress_hidey_bars',
319 def RunNavigateSteps(self, action_runner):
320 action_runner.RunAction(NavigateAction())
321 action_runner.RunAction(WaitAction({'seconds': 2}))
323 def RunSmoothness(self, action_runner):
324 self.StressHideyBars(action_runner)
326 def StressHideyBars(self, action_runner):
327 action_runner.RunAction(ScrollAction(
331 'scrollable_element_function': '''
333 callback(document.getElementById('messages'));
336 action_runner.RunAction(ScrollAction(
340 'scrollable_element_function': '''
342 callback(document.getElementById('messages'));
345 action_runner.RunAction(ScrollAction(
349 'scrollable_element_function': '''
351 callback(document.getElementById('messages'));
356 class Page18(KeySilkCasesPage):
358 def __init__(self, page_set):
359 super(Page18, self).__init__(
360 url='file://key_silk_cases/inbox_app.html?toggle_drawer',
363 def RunNavigateSteps(self, action_runner):
364 action_runner.RunAction(NavigateAction())
365 action_runner.RunAction(WaitAction(
370 def RunSmoothness(self, action_runner):
372 self.ToggleDrawer(action_runner)
374 def ToggleDrawer(self, action_runner):
375 action_runner.RunAction(TapAction(
377 'selector': '#menu-button',
378 'wait_after' : {'seconds': 1}
382 class Page19(KeySilkCasesPage):
384 def __init__(self, page_set):
385 super(Page19, self).__init__(
386 url='file://key_silk_cases/inbox_app.html?slide_drawer',
389 def ToggleDrawer(self, action_runner):
390 action_runner.RunAction(TapAction(
392 'selector': '#menu-button'
394 action_runner.BeginInteraction('Wait', [tir_module.IS_SMOOTH])
395 action_runner.RunAction(WaitAction({
396 'javascript': 'document.getElementById("nav-drawer").active'
398 action_runner.EndInteraction('Wait', [tir_module.IS_SMOOTH])
401 def RunNavigateSteps(self, action_runner):
402 action_runner.RunAction(NavigateAction())
403 action_runner.RunAction(WaitAction({'seconds': 2}))
404 self.ToggleDrawer(action_runner)
406 def RunSmoothness(self, action_runner):
407 self.SlideDrawer(action_runner)
409 def SlideDrawer(self, action_runner):
410 action_runner.RunAction(SwipeAction(
412 'left_start_percentage': 0.8,
415 'top_start_percentage': 0.2,
416 'element_function': '''
418 callback(document.getElementById('nav-drawer').children[0]);
421 'javascript': '!document.getElementById("nav-drawer").active'
426 class Page20(KeySilkCasesPage):
428 """ Why: Shadow DOM infinite scrolling. """
430 def __init__(self, page_set):
431 super(Page20, self).__init__(
432 url='file://key_silk_cases/infinite_scrolling.html',
435 def RunSmoothness(self, action_runner):
436 action_runner.RunAction(ScrollAction(
439 'scrollable_element_function': '''
441 callback(document.getElementById('container'));
446 class Page21(KeySilkCasesPage):
448 def __init__(self, page_set):
449 super(Page21, self).__init__(
450 url='http://www.google.com/#q=google',
453 def ScrollKnowledgeCardToTop(self, action_runner):
454 # scroll until the knowledge card is at the top
455 action_runner.RunAction(ScrollAction(
457 'scroll_distance_function': '''
459 var el = document.getElementById('kno-result');
460 var bound = el.getBoundingClientRect();
461 return bound.top - document.body.scrollTop;
466 def ExpandKnowledgeCard(self, action_runner):
468 action_runner.RunAction(TapAction(
470 'element_function': '''
472 callback(document.getElementsByClassName("vk_arc")[0]);
474 'wait_after': {'seconds': 2}
478 def RunNavigateSteps(self, action_runner):
479 action_runner.RunAction(NavigateAction())
480 action_runner.RunAction(WaitAction({'seconds': 3}))
481 self.ScrollKnowledgeCardToTop(action_runner)
483 def RunSmoothness(self, action_runner):
484 self.ExpandKnowledgeCard(action_runner)
487 class Page22(KeySilkCasesPage):
489 def __init__(self, page_set):
490 super(Page22, self).__init__(
491 url='http://plus.google.com/app/basic/stream',
494 self.disabled = 'Times out on Windows; crbug.com/338838'
495 self.credentials = 'google'
497 def RunNavigateSteps(self, action_runner):
498 action_runner.RunAction(NavigateAction())
499 action_runner.RunAction(WaitAction(
501 'javascript': 'document.getElementsByClassName("fHa").length > 0'
503 action_runner.RunAction(WaitAction(
508 def RunSmoothness(self, action_runner):
509 action_runner.RunAction(ScrollAction(
511 'scrollable_element_function': '''
513 callback(document.getElementById('mainContent'));
518 class Page23(KeySilkCasesPage):
521 Why: Physical simulation demo that does a lot of element.style mutation
522 triggering JS and recalc slowness
525 def __init__(self, page_set):
526 super(Page23, self).__init__(
527 url='http://jsbin.com/UVIgUTa/6/quiet',
530 def RunSmoothness(self, action_runner):
531 action_runner.RunAction(ScrollAction(
534 'scroll_requires_touch': True,
535 'scroll_distance_function':
536 'function() { return window.innerHeight / 2; }'
538 action_runner.BeginInteraction('Wait', [tir_module.IS_SMOOTH])
539 action_runner.RunAction(WaitAction({'seconds' : 1}))
540 action_runner.EndInteraction('Wait', [tir_module.IS_SMOOTH])
543 class Page24(KeySilkCasesPage):
546 Why: Google News: this iOS version is slower than accelerated scrolling
549 def __init__(self, page_set):
550 super(Page24, self).__init__(
551 url='http://mobile-news.sandbox.google.com/news/pt0?scroll',
554 def RunNavigateSteps(self, action_runner):
555 action_runner.RunAction(NavigateAction())
556 action_runner.RunAction(WaitAction(
558 'javascript': 'document.getElementById(":h") != null'
560 action_runner.RunAction(WaitAction(
565 def RunSmoothness(self, action_runner):
566 action_runner.RunAction(ScrollAction(
568 'scroll_distance_function': 'function() { return 2500; }',
569 'scrollable_element_function':
570 'function(callback) { callback(document.getElementById(":5")); }',
571 'scroll_requires_touch': True
575 class Page25(KeySilkCasesPage):
577 def __init__(self, page_set):
578 super(Page25, self).__init__(
579 url='http://mobile-news.sandbox.google.com/news/pt0?swipe',
582 def RunNavigateSteps(self, action_runner):
583 action_runner.RunAction(NavigateAction())
584 action_runner.RunAction(WaitAction(
586 'javascript': 'document.getElementById(":h") != null'
588 action_runner.RunAction(WaitAction(
593 def RunSmoothness(self, action_runner):
594 action_runner.RunAction(SwipeAction(
598 'element_function': '''
600 callback(document.getElementById(':f'));
603 action_runner.BeginInteraction('Wait', [tir_module.IS_SMOOTH])
604 action_runner.RunAction(WaitAction({'seconds' : 1}))
605 action_runner.EndInteraction('Wait', [tir_module.IS_SMOOTH])
608 class Page26(KeySilkCasesPage):
610 """ Why: famo.us twitter demo """
612 def __init__(self, page_set):
613 super(Page26, self).__init__(
614 url='http://s.codepen.io/befamous/fullpage/pFsqb?scroll',
617 def RunNavigateSteps(self, action_runner):
618 action_runner.RunAction(NavigateAction())
619 action_runner.RunAction(WaitAction(
621 'javascript': 'document.getElementsByClassName("tweet").length > 0'
623 action_runner.RunAction(WaitAction(
628 def RunSmoothness(self, action_runner):
629 action_runner.RunAction(ScrollAction(
631 'scroll_distance_function': 'function() { return 5000; }'
635 class KeySilkCasesPageSet(page_set_module.PageSet):
637 """ Pages hand-picked for project Silk. """
640 super(KeySilkCasesPageSet, self).__init__(
641 credentials_path='data/credentials.json',
642 user_agent_type='mobile',
643 archive_data_file='data/key_silk_cases.json')
645 self.AddPage(Page1(self))
646 self.AddPage(Page2(self))
647 self.AddPage(Page3(self))
648 self.AddPage(Page4(self))
649 self.AddPage(Page5(self))
650 self.AddPage(Page6(self))
651 self.AddPage(Page7(self))
652 self.AddPage(Page8(self))
653 self.AddPage(Page9(self))
654 self.AddPage(Page10(self))
655 self.AddPage(Page11(self))
656 self.AddPage(Page12(self))
657 self.AddPage(Page13(self))
658 self.AddPage(Page14(self))
659 self.AddPage(Page15(self))
660 self.AddPage(Page16(self))
661 self.AddPage(Page17(self))
662 self.AddPage(Page18(self))
663 self.AddPage(Page19(self))
664 self.AddPage(Page20(self))
665 self.AddPage(Page21(self))
666 self.AddPage(Page22(self))
667 self.AddPage(Page23(self))
668 self.AddPage(Page24(self))
669 self.AddPage(Page25(self))
670 # self.AddPage(Page26(self)) # crbug.com/366371