<!DOCTYPE html>
<style>
#scrollable {
height: 800px;
width: 800px;
overflow: auto;
}
#content {
height: 4000px;
width: 800px;
}
</style>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<div id="scrollable">
<div id="content"> </div>
</div>
<script>
// values are from enum Feature in UseCounter.h
var ScrollByKeyboardArrowKeys = 1843;
var ScrollByKeyboardPageUpDownKeys = 1844;
var ScrollByKeyboardHomeEndKeys = 1845;
var ScrollByKeyboardSpacebarKey = 1846;
test(function() {
if (!window.eventSender)
return;
var rect = document.getElementById("scrollable").getBoundingClientRect();
var startX = (rect.left + rect.right) / 2;
var startY = (rect.top + rect.bottom) / 2;
// Make sure that scrollable will scroll.
eventSender.mouseMoveTo(startX, startY);
eventSender.mouseDown();
eventSender.mouseUp();
scrollByArrowKey();
scrollBySpaceKey();
scrollByPage();
scrollByEndKey();
}, "Tests that scrolling by keyboard keys is recorded in UMA usecounter.");
function scrollByArrowKey() {
eventSender.keyDown('ArrowDown');
assert_true(internals.isUseCounted(document, ScrollByKeyboardArrowKeys));
}
function scrollBySpaceKey() {
eventSender.keyDown(" ", []);
assert_true(internals.isUseCounted(document, ScrollByKeyboardSpacebarKey));
}
function scrollByPage() {
if (navigator.platform.indexOf('Mac') == 0) {
eventSender.keyDown('ArrowDown', ["altKey"]);
} else {
eventSender.keyDown('PageDown');
}
assert_true(internals.isUseCounted(document,
ScrollByKeyboardPageUpDownKeys));
}
function scrollByEndKey() {
eventSender.keyDown('End');
assert_true(internals.isUseCounted(document, ScrollByKeyboardHomeEndKeys));
}
</script>