summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/HTMLLabelElement/click-label.html
diff options
context:
space:
mode:
Diffstat (limited to 'LayoutTests/fast/dom/HTMLLabelElement/click-label.html')
-rw-r--r--LayoutTests/fast/dom/HTMLLabelElement/click-label.html43
1 files changed, 43 insertions, 0 deletions
diff --git a/LayoutTests/fast/dom/HTMLLabelElement/click-label.html b/LayoutTests/fast/dom/HTMLLabelElement/click-label.html
new file mode 100644
index 0000000..b8dbfbd
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLLabelElement/click-label.html
@@ -0,0 +1,43 @@
+<html>
+<head>
+<script>
+var clickcount = 0;
+function dispatchClickEvent(target) {
+ // Create a click event and dispatch it
+ var event = document.createEvent('UIEvents');
+ event.initUIEvent('click', true, true, window, 1)
+ target.dispatchEvent(event);
+}
+
+function runTest() {
+ if (window.layoutTestController)
+ layoutTestController.dumpAsText();
+
+ var label1 = document.getElementById('label1');
+ dispatchClickEvent(label1);
+ if (clickcount < 1)
+ return;
+
+ var label2 = document.getElementById('label2');
+ dispatchClickEvent(label2);
+ if (clickcount < 2)
+ return;
+ document.getElementById('result').innerHTML = 'SUCCESS'
+}
+
+function inc()
+{
+ clickcount++;
+}
+</script>
+</head>
+<body onload="runTest()">
+This tests that the correct form control element is clicked when clicking on a label.
+If the test is successful, the text "SUCCESS" should show below.<br>
+<Label id="label1">label1<button onclick="inc();">inc</button></label><br>
+<Label id="label2">label2<fieldset><legend><button onclick="inc();">inc</button></legend></fieldset></label><br>
+<div id="result">FAILURE</div>
+
+</body>
+</html>
+