Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: LayoutTests/fast/forms/radio-checkbox-events-order.html

Issue 1188763002: Click event should be fired before change events for checkbox and radio button. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/forms/radio-checkbox-events-order-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/forms/radio-checkbox-events-order.html
diff --git a/LayoutTests/fast/forms/radio-checkbox-events-order.html b/LayoutTests/fast/forms/radio-checkbox-events-order.html
new file mode 100644
index 0000000000000000000000000000000000000000..673ecb8291643de36483de084f684652ceb8b964
--- /dev/null
+++ b/LayoutTests/fast/forms/radio-checkbox-events-order.html
@@ -0,0 +1,102 @@
+<!DOCTYPE HTML>
+
+<script src="../../resources/js-test.js"></script>
+
+<body>
+<input type="checkbox" id="checkbox-btn1" onclick="doClickAction(event)" onchange="doChangeAction(event)"/>
+<input type="checkbox" id="checkbox-btn2" onclick="doClickAction(event); event.preventDefault()" onchange="doChangeAction(event)"/>
+<input type="radio" id="radio-btn1" onclick="doClickAction(event)" onchange="doChangeAction(event)"/>
+<input type="radio" id="radio-btn2" onclick="doClickAction(event); event.preventDefault()" onchange="doChangeAction(event)"/>
+<script>
+description('Tests the order of onclick and onchange');
+var message = '';
+
+function doClickAction(e)
+{
+ shouldBeEqualToString('message', '');
+ message = 'clicked';
+}
+
+function doChangeAction(e)
+{
+ shouldBeEqualToString('message', 'clicked');
+ message = 'changed';
+}
+
+var checkbox1 = document.getElementById('checkbox-btn1');
+var checkbox2 = document.getElementById('checkbox-btn2');
+var radio1 = document.getElementById('radio-btn1');
+var radio2 = document.getElementById('radio-btn2');
+
+message = '';
+checkbox1.click();
+shouldBeEqualToString('message', 'changed');
+shouldBeTrue('checkbox1.checked');
+
+message = '';
+checkbox1.click();
+shouldBeEqualToString('message', 'changed');
+shouldBeFalse('checkbox1.checked');
+
+message = '';
+checkbox2.click();
+shouldBeEqualToString('message', 'clicked');
+shouldBeFalse('checkbox2.checked');
+
+message = '';
+checkbox1.checked = false;
+checkbox1.focus();
+eventSender.keyDown(' ');
+shouldBeEqualToString('message', 'changed');
+shouldBeTrue('checkbox1.checked');
+
+message = '';
+checkbox1.focus();
+eventSender.keyDown(' ');
+shouldBeEqualToString('message', 'changed');
+shouldBeFalse('checkbox1.checked');
+
+message = '';
+checkbox2.checked = false;
+checkbox2.focus();
+eventSender.keyDown(' ');
+shouldBeEqualToString('message', 'clicked');
+shouldBeFalse('checkbox2.checked');
+
+message = '';
+radio1.click();
+shouldBeEqualToString('message', 'changed');
+shouldBeTrue('radio1.checked');
+
+message = '';
+radio1.click();
+shouldBeEqualToString('message', 'clicked');
+shouldBeTrue('radio1.checked');
+
+message = '';
+radio2.click();
+shouldBeEqualToString('message', 'clicked');
+shouldBeFalse('radio2.checked');
+
+message = '';
+radio1.checked = false;
+radio1.focus();
+eventSender.keyDown(' ');
+shouldBeEqualToString('message', 'changed');
+shouldBeTrue('radio1.checked');
+
+message = '';
+radio1.focus();
+eventSender.keyDown(' ');
+shouldBeEqualToString('message', '');
+shouldBeTrue('radio1.checked');
+
+message = '';
+radio2.checked = false;
+radio2.focus();
+eventSender.keyDown(' ');
+shouldBeEqualToString('message', 'clicked');
+shouldBeFalse('radio2.checked');
+
+</script>
+</body>
« no previous file with comments | « no previous file | LayoutTests/fast/forms/radio-checkbox-events-order-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698