<!DOCTYPE html>
<html>
<script src="../../../resources/js-test.js"></script>
<label id="labelWithInput" for="inputText">Some, Text associated with input</label>
<input type="checkbox" id="checkbox" checked>
<script>
description('Test the value of checkbox after selecting the associated label\'s text');
var labelElement = document.getElementById('labelWithInput');
var checkbox = document.getElementById('checkbox');
testByDraggingOnLabel(labelElement);
// As checkbox is already checked, dragging over the label text,
// should only select the text and not change the value of
// checkbox.
shouldBeTrue('checkbox.checked');
// To check if selection happened or not.
shouldBeEqualToString('window.getSelection().toString()', 'Some, Text associated with input');
labelElement.style.display = 'none';
function testByDraggingOnLabel(element)
{
eventSender.mouseMoveTo(element.offsetLeft, element.offsetTop + element.offsetHeight / 2);
eventSender.mouseDown();
eventSender.mouseMoveTo(element.offsetLeft + element.offsetWidth, element.offsetTop + element.offsetHeight / 2);
eventSender.mouseUp();
}
</script>
</html>