blob: 53847744cf379d10ff1fa3cc77fd44a6314e2a53 [file] [log] [blame]
<html>
<head>
<style>
#test {
height: 0px;
}
.child {
height: 5px;
width: 5px;
margin: 5px;
}
.layer {
-webkit-transform: translateZ(0);
}
</style>
</head>
<body>
<pre id='log'>
</pre>
<div id='test'>
</div>
<script src="../resources/magnitude-perf.js"></script>
<script>
if (window.internals) {
window.internals.settings.setForceCompositingMode(true);
}
function log(msg)
{
document.getElementById('log').innerText += msg + '\n';
}
var testNode;
function setupFunction(magnitude, className)
{
testNode = document.getElementById('test');
testNode.innerHTML = '';
for(var i = 0; i < magnitude; i++) {
var child = document.createElement('div');
child.className = className;
testNode.appendChild(child);
}
// Force any pending full layout (since hit rect computation will be skipped
// when there is a layout pending). It's important that layout isn't dirtied
// after this before the tests run, or we'll get low linear times for everything.
document.body.getBoundingClientRect();
}
// Test 1 tests that rect calculation is linear in the number of rects in a layer.
function setupFunction1(magnitude)
{
setupFunction(magnitude, 'child');
}
// Test 2 tests that rect calculation is linear in the number of layers.
function setupFunction2(magnitude)
{
setupFunction(magnitude, 'child layer');
}
function touchHandler(event)
{
}
function test(magnitude)
{
// Adding or removing a touch handler will force recomputation of the
// touch hit rects. Note layout also forces recomputation and is the more
// relevant scenario, but is too noisy to use for a perf test.
testNode.addEventListener('touchstart', touchHandler);
// Note that if the times aren't coming out as expected, you should check here that the expected
// touch hit rects were generated by using window.internals.touchEventTargetLayerRects(document).
// For example, run in content_shell with --expose-internals-for-testing.
testNode.removeEventListener('touchstart', touchHandler);
}
Magnitude.description('Tests that compositor touch hit rect calculation is ' +
'linear in the number of rects and in the number of layers.');
// Wait for first layout.
document.body.getBoundingClientRect();
// Verify that compositor touch hit testing is properly enabled.
if (window.internals) {
var testNode = document.getElementById('test');
r = testNode.getBoundingClientRect();
testNode.addEventListener('touchstart', touchHandler);
var rects = window.internals.touchEventTargetLayerRects(document);
if (!rects) {
log("FAIL - no hit test rects exist, is compositing enabled?");
return;
}
if (!rects.length) {
log("FAIL - no hit test rects found, is ScrollingCoordinator::touchHitTestingEnabled false?");
}
testNode.removeEventListener('touchstart', touchHandler);
} else {
log("WARNING - missing windows.internals, can't verify hit testing is enabled.");
}
Magnitude.trim = 1;
Magnitude.tolerance = 0.80;
Magnitude.initialExponent = 7;
Magnitude.numPoints = 5;
Magnitude.run(setupFunction1, test, Magnitude.LINEAR);
Magnitude.initialExponent = 4;
Magnitude.numPoints = 5;
Magnitude.run(setupFunction2, test, Magnitude.LINEAR);
</script>
</body>