18 <p>Ensure that simulated click on label elements uses the original mouse coordinates.</p>
19 <input type="checkbox" id="target" onclick="validateEventProperties(event)">
20 <label for="target" onclick="storeEvent(event)">Click Me</label>
23 <div class="filler"></div>
24 <input type="radio" id="target2" onclick="validateEventProperties(event)">
25 <label for="target2" onclick="storeEvent(event)">Click Me</label>
31 if (window.layoutTestController)
32 layoutTestController.dumpAsText();
34 function clickOn(element)
36 if (!window.eventSender)
38 var rect = element.getBoundingClientRect();
39 var x = rect.left + rect.width / 2;
40 var y = rect.top + rect.height / 2;
41 eventSender.mouseMoveTo(x, y);
42 eventSender.mouseDown();
43 eventSender.mouseUp();
48 document.getElementById('out').textContent += s + '\n';
51 var realClickEvent, simulatedEvent;
53 function storeEvent(event)
55 realClickEvent = event;
58 function validateEventProperty(name)
60 if (realClickEvent[name] === simulatedEvent[name])
61 print('PASS: event.' + name + ' is same for both real and simulated event.');
63 print('FAIL: event.' + name + ' is ' + simulatedEvent[name] + ', expected ' + realClickEvent[name]);
66 function validateEventProperties(event)
68 simulatedEvent = event;
70 validateEventProperty('clientX');
71 validateEventProperty('clientY');
72 validateEventProperty('layerX');
73 validateEventProperty('layerY');
74 validateEventProperty('pageX');
75 validateEventProperty('pageY');
76 validateEventProperty('screenX');
77 validateEventProperty('screenY');
78 validateEventProperty('x');
79 validateEventProperty('y');
82 clickOn(document.querySelector('label'));
85 document.querySelector('.scroll').scrollTop = 999;
86 clickOn(document.querySelector('.scroll label'));