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
10 class ToughSchedulingCasesPage(page_module.Page):
12 def __init__(self, url, page_set):
13 super(ToughSchedulingCasesPage, self).__init__(url=url, page_set=page_set)
15 def RunSmoothness(self, action_runner):
16 action_runner.RunAction(ScrollAction())
19 class Page1(ToughSchedulingCasesPage):
21 """ Why: Simulate oversubscribed main thread """
23 def __init__(self, page_set):
24 super(Page1, self).__init__(
25 url='file://tough_scheduling_cases/simple_text_page.html?main_busy',
28 self.synthetic_delays = {'cc.BeginMainFrame': {'target_duration': 0.008}}
31 class Page2(ToughSchedulingCasesPage):
33 """ Why: Simulate oversubscribed main thread """
35 def __init__(self, page_set):
36 super(Page2, self).__init__(
37 # pylint: disable=C0301
38 url='file://tough_scheduling_cases/simple_text_page.html?main_very_busy',
41 self.synthetic_delays = {'cc.BeginMainFrame': {'target_duration': 0.024}}
44 class Page3(ToughSchedulingCasesPage):
46 """ Why: Simulate a page with a a few graphics layers """
48 def __init__(self, page_set):
49 super(Page3, self).__init__(
50 # pylint: disable=C0301
51 url='file://tough_scheduling_cases/simple_text_page.html?medium_layers',
54 self.synthetic_delays = {
55 'cc.DrawAndSwap': {'target_duration': 0.004},
56 'gpu.PresentingFrame': {'target_duration': 0.004},
57 'cc.BeginMainFrame': {'target_duration': 0.004}
61 class Page4(ToughSchedulingCasesPage):
63 """ Why: Simulate a page with many graphics layers """
65 def __init__(self, page_set):
66 super(Page4, self).__init__(
67 # pylint: disable=C0301
68 url='file://tough_scheduling_cases/simple_text_page.html?many_layers',
71 self.synthetic_delays = {
72 'cc.DrawAndSwap': {'target_duration': 0.012},
73 'gpu.PresentingFrame': {'target_duration': 0.012},
74 'cc.BeginMainFrame': {'target_duration': 0.012}
78 class Page5(ToughSchedulingCasesPage):
80 """ Why: Simulate a page with expensive recording and rasterization """
82 def __init__(self, page_set):
83 super(Page5, self).__init__(
84 # pylint: disable=C0301
85 url='file://tough_scheduling_cases/simple_text_page.html?medium_raster',
88 self.synthetic_delays = {
89 'cc.RasterRequiredForActivation': {'target_duration': 0.004},
90 'cc.BeginMainFrame': {'target_duration': 0.004},
91 'gpu.AsyncTexImage': {'target_duration': 0.004}
95 class Page6(ToughSchedulingCasesPage):
97 """ Why: Simulate a page with expensive recording and rasterization """
99 def __init__(self, page_set):
100 super(Page6, self).__init__(
101 # pylint: disable=C0301
102 url='file://tough_scheduling_cases/simple_text_page.html?heavy_raster',
105 self.synthetic_delays = {
106 'cc.RasterRequiredForActivation': {'target_duration': 0.024},
107 'cc.BeginMainFrame': {'target_duration': 0.024},
108 'gpu.AsyncTexImage': {'target_duration': 0.024}
112 class Page7(ToughSchedulingCasesPage):
114 """ Why: Medium cost touch handler """
116 def __init__(self, page_set):
117 super(Page7, self).__init__(
118 # pylint: disable=C0301
119 url='file://tough_scheduling_cases/touch_handler_scrolling.html?medium_handler',
122 self.synthetic_delays = {'blink.HandleInputEvent':
123 {'target_duration': 0.008}}
126 class Page8(ToughSchedulingCasesPage):
128 """ Why: Slow touch handler """
130 def __init__(self, page_set):
131 super(Page8, self).__init__(
132 # pylint: disable=C0301
133 url='file://tough_scheduling_cases/touch_handler_scrolling.html?slow_handler',
136 self.synthetic_delays = {'blink.HandleInputEvent':
137 {'target_duration': 0.024}}
140 class Page9(ToughSchedulingCasesPage):
142 """ Why: Touch handler that often takes a long time """
144 def __init__(self, page_set):
145 super(Page9, self).__init__(
146 # pylint: disable=C0301
147 url='file://tough_scheduling_cases/touch_handler_scrolling.html?janky_handler',
150 self.synthetic_delays = {'blink.HandleInputEvent':
151 {'target_duration': 0.024, 'mode': 'alternating'}
155 class Page10(ToughSchedulingCasesPage):
157 """ Why: Touch handler that occasionally takes a long time """
159 def __init__(self, page_set):
160 super(Page10, self).__init__(
161 # pylint: disable=C0301
162 url='file://tough_scheduling_cases/touch_handler_scrolling.html?occasionally_janky_handler',
165 self.synthetic_delays = {'blink.HandleInputEvent':
166 {'target_duration': 0.024, 'mode': 'oneshot'}}
169 class Page11(ToughSchedulingCasesPage):
171 """ Why: Super expensive touch handler causes browser to scroll after a
175 def __init__(self, page_set):
176 super(Page11, self).__init__(
177 # pylint: disable=C0301
178 url='file://tough_scheduling_cases/touch_handler_scrolling.html?super_slow_handler',
181 self.synthetic_delays = {'blink.HandleInputEvent':
182 {'target_duration': 0.2}}
185 class Page12(ToughSchedulingCasesPage):
187 """ Why: Super expensive touch handler that only occupies a part of the page.
190 def __init__(self, page_set):
191 super(Page12, self).__init__(
192 url='file://tough_scheduling_cases/div_touch_handler.html',
195 self.synthetic_delays = {'blink.HandleInputEvent': {'target_duration': 0.2}}
198 class Page13(ToughSchedulingCasesPage):
200 """ Why: Test a moderately heavy requestAnimationFrame handler """
202 def __init__(self, page_set):
203 super(Page13, self).__init__(
204 url='file://tough_scheduling_cases/raf.html?medium_handler',
207 self.synthetic_delays = {
208 'cc.RasterRequiredForActivation': {'target_duration': 0.004},
209 'cc.BeginMainFrame': {'target_duration': 0.004},
210 'gpu.AsyncTexImage': {'target_duration': 0.004}
214 class Page14(ToughSchedulingCasesPage):
216 """ Why: Test a moderately heavy requestAnimationFrame handler """
218 def __init__(self, page_set):
219 super(Page14, self).__init__(
220 url='file://tough_scheduling_cases/raf.html?heavy_handler',
223 self.synthetic_delays = {
224 'cc.RasterRequiredForActivation': {'target_duration': 0.024},
225 'cc.BeginMainFrame': {'target_duration': 0.024},
226 'gpu.AsyncTexImage': {'target_duration': 0.024}
230 class Page15(ToughSchedulingCasesPage):
232 """ Why: Simulate a heavily GPU bound page """
234 def __init__(self, page_set):
235 super(Page15, self).__init__(
236 url='file://tough_scheduling_cases/raf.html?gpu_bound',
239 self.synthetic_delays = {'gpu.PresentingFrame': {'target_duration': 0.1}}
242 class Page16(ToughSchedulingCasesPage):
244 """ Why: Test a requestAnimationFrame handler with a heavy first frame """
246 def __init__(self, page_set):
247 super(Page16, self).__init__(
248 url='file://tough_scheduling_cases/raf.html?heavy_first_frame',
251 self.synthetic_delays = {'cc.BeginMainFrame': {'target_duration': 0.15}}
254 class Page17(ToughSchedulingCasesPage):
256 """ Why: Medium stress test for the scheduler """
258 def __init__(self, page_set):
259 super(Page17, self).__init__(
260 url='file://tough_scheduling_cases/raf_touch_animation.html?medium',
263 self.synthetic_delays = {
264 'cc.DrawAndSwap': {'target_duration': 0.004},
265 'cc.BeginMainFrame': {'target_duration': 0.004}
269 class Page18(ToughSchedulingCasesPage):
271 """ Why: Heavy stress test for the scheduler """
273 def __init__(self, page_set):
274 super(Page18, self).__init__(
275 url='file://tough_scheduling_cases/raf_touch_animation.html?heavy',
278 self.synthetic_delays = {
279 'cc.DrawAndSwap': {'target_duration': 0.012},
280 'cc.BeginMainFrame': {'target_duration': 0.012}
284 class Page19(ToughSchedulingCasesPage):
286 """ Why: Both main and impl thread animating concurrently """
288 def __init__(self, page_set):
289 super(Page19, self).__init__(
290 url='file://tough_scheduling_cases/split_animation.html',
293 def RunSmoothness(self, action_runner):
294 action_runner.RunAction(WaitAction(
299 class Page20(ToughSchedulingCasesPage):
301 """ Why: Simple JS touch dragging """
303 def __init__(self, page_set):
304 super(Page20, self).__init__(
305 url='file://tough_scheduling_cases/simple_touch_drag.html',
308 def RunSmoothness(self, action_runner):
309 action_runner.RunAction(ScrollAction(
311 'scrollable_element_function': '''
313 callback(document.getElementById('card'));
315 'scroll_requires_touch': True,
318 'scroll_distance_function': 'function() { return 400; }'
321 class EmptyTouchHandlerPage(ToughSchedulingCasesPage):
323 """ Why: Scrolling on a page with a touch handler that consumes no events but
326 def __init__(self, name, desktop, slow_handler, bounce, page_set):
327 super(EmptyTouchHandlerPage, self).__init__(
328 url='file://tough_scheduling_cases/empty_touch_handler' +
329 ('_desktop' if desktop else '') + '.html?' + name,
333 self.synthetic_delays = {
334 'blink.HandleInputEvent': {'target_duration': 0.2}
339 def RunSmoothness(self, action_runner):
341 action = ScrollBounceAction()
343 action = ScrollAction(
345 'scroll_requires_touch': True,
346 """ Speed and distance are tuned to run exactly as long as a scroll
349 'scroll_distance_function': 'function() { return 2100; }'
352 action_runner.RunAction(action)
354 class ToughSchedulingCasesPageSet(page_set_module.PageSet):
356 """ Tough scheduler latency test cases """
359 super(ToughSchedulingCasesPageSet, self).__init__()
361 # Why: Simple scrolling baseline
362 self.AddPage(ToughSchedulingCasesPage(
363 'file://tough_scheduling_cases/simple_text_page.html',
365 self.AddPage(Page1(self))
366 self.AddPage(Page2(self))
367 self.AddPage(Page3(self))
368 self.AddPage(Page4(self))
369 self.AddPage(Page5(self))
370 self.AddPage(Page6(self))
371 # Why: Touch handler scrolling baseline
372 self.AddPage(ToughSchedulingCasesPage(
373 'file://tough_scheduling_cases/touch_handler_scrolling.html',
375 self.AddPage(Page7(self))
376 self.AddPage(Page8(self))
377 self.AddPage(Page9(self))
378 self.AddPage(Page10(self))
379 self.AddPage(Page11(self))
380 self.AddPage(Page12(self))
381 # Why: requestAnimationFrame scrolling baseline
382 self.AddPage(ToughSchedulingCasesPage(
383 'file://tough_scheduling_cases/raf.html',
385 # Why: Test canvas blocking behavior
386 self.AddPage(ToughSchedulingCasesPage(
387 'file://tough_scheduling_cases/raf_canvas.html',
389 self.AddPage(Page13(self))
390 # Disabled for flakiness. See 368532
391 # self.AddPage(Page14(self))
392 self.AddPage(Page15(self))
393 self.AddPage(Page16(self))
394 # Why: Test a requestAnimationFrame handler with concurrent CSS animation
395 self.AddPage(ToughSchedulingCasesPage(
396 'file://tough_scheduling_cases/raf_animation.html',
398 # Why: Stress test for the scheduler
399 self.AddPage(ToughSchedulingCasesPage(
400 'file://tough_scheduling_cases/raf_touch_animation.html',
402 self.AddPage(Page17(self))
403 self.AddPage(Page18(self))
404 self.AddPage(Page19(self))
405 self.AddPage(Page20(self))
406 # Why: Baseline for scrolling in the presence of a no-op touch handler
407 self.AddPage(EmptyTouchHandlerPage(
413 # Why: Slow handler blocks scroll start
414 self.AddPage(EmptyTouchHandlerPage(
420 # Why: Slow handler blocks scroll start until touch ACK timeout
421 self.AddPage(EmptyTouchHandlerPage(
422 name='desktop_slow_handler',
427 # Why: Scroll bounce showing repeated transitions between scrolling and
428 # sending synchronous touchmove events. Should be nearly as fast as
430 self.AddPage(EmptyTouchHandlerPage(
436 # Why: Scroll bounce with slow handler, repeated blocking.
437 self.AddPage(EmptyTouchHandlerPage(
438 name='bounce_slow_handler',
443 # Why: Scroll bounce with slow handler on desktop, blocks only once until
445 self.AddPage(EmptyTouchHandlerPage(
446 name='bounce_desktop_slow_handler',