• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1<html>
2<head>
3<script>
4var clickcount = 0;
5function dispatchClickEvent(target) {
6    // Create a click event and dispatch it
7    var event = document.createEvent('UIEvents');
8    event.initUIEvent('click', true, true, window, 1)
9    target.dispatchEvent(event);
10}
11
12function runTest() {
13    if (window.layoutTestController)
14        layoutTestController.dumpAsText();
15
16    var label1 = document.getElementById('label1');
17    dispatchClickEvent(label1);
18    if (clickcount < 1)
19        return;
20
21    var label2 = document.getElementById('label2');
22    dispatchClickEvent(label2);
23    if (clickcount < 2)
24        return;
25    document.getElementById('result').innerHTML = 'SUCCESS'
26}
27
28function inc()
29{
30    clickcount++;
31}
32</script>
33</head>
34<body onload="runTest()">
35This tests that the correct form control element is clicked when clicking on a label.
36If the test is successful, the text "SUCCESS" should show below.<br>
37<Label id="label1">label1<button onclick="inc();">inc</button></label><br>
38<Label id="label2">label2<fieldset><legend><button onclick="inc();">inc</button></legend></fieldset></label><br>
39<div id="result">FAILURE</div>
40
41</body>
42</html>
43
44