summaryrefslogtreecommitdiffstats
path: root/tools/perf/page_sets/key_silk_cases.py
blob: 4a1482988f0a3f3cd639fc9d6d63967ec9381b44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
# Copyright 2014 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# pylint: disable=W0401,W0614
from telemetry.page.actions.all_page_actions import *
from telemetry.page import page as page_module
from telemetry.page import page_set as page_set_module
from telemetry.web_perf import timeline_interaction_record as tir_module


class KeySilkCasesPage(page_module.Page):

  def __init__(self, url, page_set):
    super(KeySilkCasesPage, self).__init__(url=url, page_set=page_set)
    self.credentials_path = 'data/credentials.json'
    self.user_agent_type = 'mobile'
    self.archive_data_file = 'data/key_silk_cases.json'

  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction(
      {
        'seconds': 2
      }))

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(ScrollAction())


class Page1(KeySilkCasesPage):

  """ Why: Infinite scroll. Brings out all of our perf issues. """

  def __init__(self, page_set):
    super(Page1, self).__init__(
      url='http://groupcloned.com/test/plain/list-recycle-transform.html',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(ScrollAction(
      {
        'scrollable_element_function': '''
          function(callback) {
            callback(document.getElementById('scrollable'));
          }'''
      }))


class Page2(KeySilkCasesPage):

  """ Why: Brings out layer management bottlenecks. """

  def __init__(self, page_set):
    super(Page2, self).__init__(
      url='http://groupcloned.com/test/plain/list-animation-simple.html',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 2}))


class Page3(KeySilkCasesPage):

  """
  Why: Best-known method for fake sticky. Janks sometimes. Interacts badly with
  compositor scrolls.
  """

  def __init__(self, page_set):
    super(Page3, self).__init__(
      # pylint: disable=C0301
      url='http://groupcloned.com/test/plain/sticky-using-webkit-backface-visibility.html',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(ScrollAction(
      {
        'scrollable_element_function': '''
          function(callback) {
            callback(document.getElementById('container'));
          }'''
      }))


class Page4(KeySilkCasesPage):

  """
  Why: Card expansion: only the card should repaint, but in reality lots of
  storms happen.
  """

  def __init__(self, page_set):
    super(Page4, self).__init__(
      url='http://jsfiddle.net/3yDKh/4/embedded/result',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 3}))


class Page5(KeySilkCasesPage):

  """
  Why: Card expansion with animated contents, using will-change on the card
  """

  def __init__(self, page_set):
    super(Page5, self).__init__(
      url='http://jsfiddle.net/jx5De/13/embedded/result',
      page_set=page_set)

    self.gpu_raster = True

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 4}))


class Page6(KeySilkCasesPage):

  """
  Why: Card fly-in: It should be fast to animate in a bunch of cards using
  margin-top and letting layout do the rest.
  """

  def __init__(self, page_set):
    super(Page6, self).__init__(
      url='http://jsfiddle.net/3yDKh/6/embedded/result',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 3}))


class Page7(KeySilkCasesPage):

  """
  Why: Image search expands a spacer div when you click an image to accomplish
  a zoomin effect. Each image has a layer. Even so, this triggers a lot of
  unnecessary repainting.
  """

  def __init__(self, page_set):
    super(Page7, self).__init__(
      url='http://jsfiddle.net/R8DX9/1/embedded/result/',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 3}))


class Page8(KeySilkCasesPage):

  """
  Why: Swipe to dismiss of an element that has a fixed-position child that is
  its pseudo-sticky header. Brings out issues with layer creation and
  repainting.
  """

  def __init__(self, page_set):
    super(Page8, self).__init__(
      url='http://jsfiddle.net/rF9Gh/3/embedded/result/',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 3}))


class Page9(KeySilkCasesPage):

  """
  Why: Horizontal and vertical expansion of a card that is cheap to layout but
  costly to rasterize.
  """

  def __init__(self, page_set):
    super(Page9, self).__init__(
      url='http://jsfiddle.net/TLXLu/2/embedded/result/',
      page_set=page_set)

    self.gpu_raster = True

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 4}))


class Page10(KeySilkCasesPage):

  """
  Why: Vertical Expansion of a card that is cheap to layout but costly to
  rasterize.
  """

  def __init__(self, page_set):
    super(Page10, self).__init__(
      url='http://jsfiddle.net/cKB9D/6/embedded/result/',
      page_set=page_set)

    self.gpu_raster = True

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 4}))


class Page11(KeySilkCasesPage):

  """
  Why: Parallax effect is common on photo-viewer-like applications, overloading
  software rasterization
  """

  def __init__(self, page_set):
    super(Page11, self).__init__(
      url='http://jsfiddle.net/vBQHH/10/embedded/result/',
      page_set=page_set)

    self.gpu_raster = True

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 4}))


class Page12(KeySilkCasesPage):

  """ Why: Addressing paint storms during coordinated animations. """

  def __init__(self, page_set):
    super(Page12, self).__init__(
      url='http://jsfiddle.net/ugkd4/9/embedded/result/',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 5}))


class Page13(KeySilkCasesPage):

  """ Why: Mask transitions are common mobile use cases. """

  def __init__(self, page_set):
    super(Page13, self).__init__(
      url='http://jsfiddle.net/xLuvC/embedded/result/',
      page_set=page_set)

    self.gpu_raster = True

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 4}))


class Page14(KeySilkCasesPage):

  """ Why: Card expansions with images and text are pretty and common. """

  def __init__(self, page_set):
    super(Page14, self).__init__(
      url='http://jsfiddle.net/bNp2h/1/embedded/result/',
      page_set=page_set)

    self.gpu_raster = True

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 4}))


class Page15(KeySilkCasesPage):

  """ Why: Coordinated animations for expanding elements. """

  def __init__(self, page_set):
    super(Page15, self).__init__(
      url='file://key_silk_cases/font_wipe.html',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(WaitAction({'seconds': 5}))


class Page16(KeySilkCasesPage):

  def __init__(self, page_set):
    super(Page16, self).__init__(
      url='file://key_silk_cases/inbox_app.html?swipe_to_dismiss',
      page_set=page_set)

  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction({'seconds': 2}))

  def SwipeToDismiss(self, action_runner):
    action_runner.RunAction(SwipeAction(
      {
        'left_start_percentage': 0.8,
        'distance': 200,
        'direction': 'left',
        'top_start_percentage': 0.2,
        'element_function': '''
          function(callback) {
            callback(document.getElementsByClassName('message')[2]);
          }''',
        'speed': 5000
      }))
    action_runner.BeginInteraction('Wait', [tir_module.IS_SMOOTH])
    action_runner.RunAction(WaitAction({
      'javascript': 'document.getElementsByClassName("message").length < 18'
    }))
    action_runner.EndInteraction('Wait', [tir_module.IS_SMOOTH])

  def RunSmoothness(self, action_runner):
    self.SwipeToDismiss(action_runner)


class Page17(KeySilkCasesPage):

  def __init__(self, page_set):
    super(Page17, self).__init__(
      url='file://key_silk_cases/inbox_app.html?stress_hidey_bars',
      page_set=page_set)

  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction({'seconds': 2}))

  def RunSmoothness(self, action_runner):
    self.StressHideyBars(action_runner)

  def StressHideyBars(self, action_runner):
    action_runner.RunAction(ScrollAction(
      {
        'direction': 'down',
        'speed': 200,
        'scrollable_element_function': '''
          function(callback) {
            callback(document.getElementById('messages'));
          }'''
      }))
    action_runner.RunAction(ScrollAction(
      {
        'direction': 'up',
        'speed': 200,
        'scrollable_element_function': '''
          function(callback) {
            callback(document.getElementById('messages'));
          }'''
      }))
    action_runner.RunAction(ScrollAction(
      {
        'direction': 'down',
        'speed': 200,
        'scrollable_element_function': '''
          function(callback) {
            callback(document.getElementById('messages'));
          }'''
      }))


class Page18(KeySilkCasesPage):

  def __init__(self, page_set):
    super(Page18, self).__init__(
      url='file://key_silk_cases/inbox_app.html?toggle_drawer',
      page_set=page_set)

  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction(
      {
        'seconds': 2
      }))

  def RunSmoothness(self, action_runner):
    for _ in xrange(6):
      self.ToggleDrawer(action_runner)

  def ToggleDrawer(self, action_runner):
    action_runner.RunAction(TapAction(
      {
        'selector': '#menu-button',
        'wait_after' : {'seconds': 1}
      }))


class Page19(KeySilkCasesPage):

  def __init__(self, page_set):
    super(Page19, self).__init__(
      url='file://key_silk_cases/inbox_app.html?slide_drawer',
      page_set=page_set)

  def ToggleDrawer(self, action_runner):
    action_runner.RunAction(TapAction(
      {
        'selector': '#menu-button'
      }))
    action_runner.BeginInteraction('Wait', [tir_module.IS_SMOOTH])
    action_runner.RunAction(WaitAction({
      'javascript': 'document.getElementById("nav-drawer").active'
    }))
    action_runner.EndInteraction('Wait', [tir_module.IS_SMOOTH])


  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction({'seconds': 2}))
    self.ToggleDrawer(action_runner)

  def RunSmoothness(self, action_runner):
    self.SlideDrawer(action_runner)

  def SlideDrawer(self, action_runner):
    action_runner.RunAction(SwipeAction(
      {
        'left_start_percentage': 0.8,
        'distance': 200,
        'direction': 'left',
        'top_start_percentage': 0.2,
        'element_function': '''
          function(callback) {
            callback(document.getElementById('nav-drawer').children[0]);
          }''',
        'wait_after' : {
          'javascript': '!document.getElementById("nav-drawer").active'
        }
      }))


class Page20(KeySilkCasesPage):

  """ Why: Shadow DOM infinite scrolling. """

  def __init__(self, page_set):
    super(Page20, self).__init__(
      url='file://key_silk_cases/infinite_scrolling.html',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(ScrollAction(
      {
        'speed': 5000,
        'scrollable_element_function': '''
          function(callback) {
            callback(document.getElementById('container'));
          }'''
      }))


class Page21(KeySilkCasesPage):

  def __init__(self, page_set):
    super(Page21, self).__init__(
      url='http://www.google.com/#q=google',
      page_set=page_set)

  def ScrollKnowledgeCardToTop(self, action_runner):
    # scroll until the knowledge card is at the top
    action_runner.RunAction(ScrollAction(
      {
        'scroll_distance_function': '''
          function() {
            var el = document.getElementById('kno-result');
            var bound = el.getBoundingClientRect();
            return bound.top - document.body.scrollTop;
          }
        '''
      }))

  def ExpandKnowledgeCard(self, action_runner):
    # expand card
    action_runner.RunAction(TapAction(
      {
        'element_function': '''
          function(callback) {
            callback(document.getElementsByClassName("vk_arc")[0]);
          }''',
        'wait_after': {'seconds': 2}
      }))


  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction({'seconds': 3}))
    self.ScrollKnowledgeCardToTop(action_runner)

  def RunSmoothness(self, action_runner):
    self.ExpandKnowledgeCard(action_runner)


class Page22(KeySilkCasesPage):

  def __init__(self, page_set):
    super(Page22, self).__init__(
      url='http://plus.google.com/app/basic/stream',
      page_set=page_set)

    self.disabled = 'Times out on Windows; crbug.com/338838'
    self.credentials = 'google'

  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction(
      {
        'javascript': 'document.getElementsByClassName("fHa").length > 0'
      }))
    action_runner.RunAction(WaitAction(
      {
        'seconds': 2
      }))

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(ScrollAction(
      {
        'scrollable_element_function': '''
          function(callback) {
            callback(document.getElementById('mainContent'));
          }'''
      }))


class Page23(KeySilkCasesPage):

  """
  Why: Physical simulation demo that does a lot of element.style mutation
  triggering JS and recalc slowness
  """

  def __init__(self, page_set):
    super(Page23, self).__init__(
      url='http://jsbin.com/UVIgUTa/6/quiet',
      page_set=page_set)

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(ScrollAction(
      {
        'direction': 'down',
        'scroll_requires_touch': True,
        'scroll_distance_function':
          'function() { return window.innerHeight / 2; }'
      }))
    action_runner.BeginInteraction('Wait', [tir_module.IS_SMOOTH])
    action_runner.RunAction(WaitAction({'seconds' : 1}))
    action_runner.EndInteraction('Wait', [tir_module.IS_SMOOTH])


class Page24(KeySilkCasesPage):

  """
  Why: Google News: this iOS version is slower than accelerated scrolling
  """

  def __init__(self, page_set):
    super(Page24, self).__init__(
      url='http://mobile-news.sandbox.google.com/news/pt0?scroll',
      page_set=page_set)

  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction(
      {
        'javascript': 'document.getElementById(":h") != null'
      }))
    action_runner.RunAction(WaitAction(
      {
        'seconds': 1
      }))

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(ScrollAction(
      {
        'scroll_distance_function': 'function() { return 2500; }',
        'scrollable_element_function':
          'function(callback) { callback(document.getElementById(":5")); }',
        'scroll_requires_touch': True
      }))


class Page25(KeySilkCasesPage):

  def __init__(self, page_set):
    super(Page25, self).__init__(
      url='http://mobile-news.sandbox.google.com/news/pt0?swipe',
      page_set=page_set)

  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction(
      {
        'javascript': 'document.getElementById(":h") != null'
      }))
    action_runner.RunAction(WaitAction(
      {
        'seconds': 1
      }))

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(SwipeAction(
      {
        'distance': 100,
        'direction': "left",
        'element_function': '''
          function(callback) {
            callback(document.getElementById(':f'));
          }'''
      }))
    action_runner.BeginInteraction('Wait', [tir_module.IS_SMOOTH])
    action_runner.RunAction(WaitAction({'seconds' : 1}))
    action_runner.EndInteraction('Wait', [tir_module.IS_SMOOTH])


class Page26(KeySilkCasesPage):

  """ Why: famo.us twitter demo """

  def __init__(self, page_set):
    super(Page26, self).__init__(
      url='http://s.codepen.io/befamous/fullpage/pFsqb?scroll',
      page_set=page_set)

  def RunNavigateSteps(self, action_runner):
    action_runner.NavigateToPage(self)
    action_runner.RunAction(WaitAction(
      {
        'javascript': 'document.getElementsByClassName("tweet").length > 0'
      }))
    action_runner.RunAction(WaitAction(
      {
        'seconds': 1
      }))

  def RunSmoothness(self, action_runner):
    action_runner.RunAction(ScrollAction(
      {
        'scroll_distance_function': 'function() { return 5000; }'
      }))


class KeySilkCasesPageSet(page_set_module.PageSet):

  """ Pages hand-picked for project Silk. """

  def __init__(self):
    super(KeySilkCasesPageSet, self).__init__(
      credentials_path='data/credentials.json',
      user_agent_type='mobile',
      archive_data_file='data/key_silk_cases.json')

    self.AddPage(Page1(self))
    self.AddPage(Page2(self))
    self.AddPage(Page3(self))
    self.AddPage(Page4(self))
    self.AddPage(Page5(self))
    self.AddPage(Page6(self))
    self.AddPage(Page7(self))
    self.AddPage(Page8(self))
    self.AddPage(Page9(self))
    self.AddPage(Page10(self))
    self.AddPage(Page11(self))
    self.AddPage(Page12(self))
    self.AddPage(Page13(self))
    self.AddPage(Page14(self))
    self.AddPage(Page15(self))
    self.AddPage(Page16(self))
    self.AddPage(Page17(self))
    self.AddPage(Page18(self))
    self.AddPage(Page19(self))
    self.AddPage(Page20(self))
    self.AddPage(Page21(self))
    self.AddPage(Page22(self))
    self.AddPage(Page23(self))
    self.AddPage(Page24(self))
    self.AddPage(Page25(self))
    self.AddPage(Page26(self))