13 transform: translateZ(0);
20 <script src="../resources/magnitude-perf.js"></script>
30 function setupFunction(magnitude, className)
32 testNode = document.getElementById('test');
33 testNode.innerHTML = '';
34 for(var i = 0; i < magnitude; i++) {
35 var child = document.createElement('div');
36 child.className = className;
37 testNode.appendChild(child);
40 // Force any pending full layout (since hit rect computation will be skipped
41 // when there is a layout pending). It's important that layout isn't dirtied
42 // after this before the tests run, or we'll get low linear times for everything.
43 document.body.getBoundingClientRect();
47 // Test 1 tests that rect calculation is linear in the number of rects in a layer.
49 function setupFunction1(magnitude)
51 setupFunction(magnitude, 'child');
54 // Test 2 tests that rect calculation is linear in the number of layers.
56 function setupFunction2(magnitude)
58 setupFunction(magnitude, 'child layer');
61 function touchHandler(event)
65 function test(magnitude)
67 // Adding or removing a touch handler will force recomputation of the
68 // touch hit rects. Note layout also forces recomputation and is the more
69 // relevant scenario, but is too noisy to use for a perf test.
70 testNode.addEventListener('touchstart', touchHandler);
72 // Note that if the times aren't coming out as expected, you should check here that the expected
73 // touch hit rects were generated by using window.internals.touchEventTargetLayerRects(document).
74 // For example, run in content_shell with --expose-internals-for-testing.
75 testNode.removeEventListener('touchstart', touchHandler);
78 Magnitude.description('Tests that compositor touch hit rect calculation is ' +
79 'linear in the number of rects and in the number of layers.');
81 // Wait for first layout.
82 document.body.getBoundingClientRect();
86 // Verify that compositor touch hit testing is properly enabled.
87 if (!window.internals) {
88 log("WARNING - missing windows.internals, can't verify hit testing is enabled.");
91 var testNode = document.getElementById('test');
92 r = testNode.getBoundingClientRect();
94 testNode.addEventListener('touchstart', touchHandler);
95 var rects = window.internals.touchEventTargetLayerRects(document);
97 log("FAIL - no hit test rects exist, is compositing enabled?");
101 log("FAIL - no hit test rects found, is ScrollingCoordinator::touchHitTestingEnabled false?");
104 testNode.removeEventListener('touchstart', touchHandler);
108 Magnitude.tolerance = 0.80;
110 Magnitude.initialExponent = 7;
111 Magnitude.numPoints = 5;
112 Magnitude.run(setupFunction1, test, Magnitude.LINEAR);
114 Magnitude.initialExponent = 4;
115 Magnitude.numPoints = 5;
116 Magnitude.run(setupFunction2, test, Magnitude.LINEAR);