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

Unified Diff: third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event.html

Issue 1813583002: Convert radio-group-keyboard-change-event.html to a testharness.js test. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 | third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event.html
diff --git a/third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event.html b/third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event.html
index d88c9146ec6ffddaadf3a87c985496cae37d8465..153ac6dacbbe7275142eae47f24da4bc32be8d1e 100644
--- a/third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event.html
+++ b/third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event.html
@@ -1,6 +1,9 @@
<!DOCTYPE html>
<html>
<body>
+<script src="../../../resources/testharness.js"></script>
+<script src="../../../resources/testharnessreport.js"></script>
+<div id="log"></div>
<p>Test for <a href="https://bugs.webkit.org/show_bug.cgi?id=32013">https://bugs.webkit.org/show_bug.cgi?id=32013</a>.
@@ -8,17 +11,17 @@
radio button should fire change events.
<p>
-<input type=radio name=aaa value=a checked onchange="handleChange(event)" onclick="handleClick(event)">a
-<input type=radio name=aaa value=b onchange="handleChange(event)" onclick="handleClick(event)">b
-<input type=radio name=aaa value=c onchange="handleChange(event)" onclick="handleClick(event)">c
+<input type=radio name=aaa value=a checked onchange="handleChange(event)">a
+<input type=radio name=aaa value=b onchange="handleChange(event)">b
+<input type=radio name=aaa value=c onchange="handleChange(event)">c
<p>For manual testing, focus a radio button in the second group and use the arrow keys. Change events
should still be dispatched but the checked radio should not change.
<p>
-<input type=radio name=bbb value=d checked onchange="handleChange(event)" onclick="handleClick(event)">d
-<input type=radio name=bbb value=e onchange="handleChange(event)" onclick="handleClick(event)">e
-<input type=radio name=bbb value=f onchange="handleChange(event)" onclick="handleClick(event)">f
+<input type=radio name=bbb value=d checked onchange="handleChange(event)" onclick="preventClick(event)">d
+<input type=radio name=bbb value=e onchange="handleChange(event)" onclick="preventClick(event)">e
+<input type=radio name=bbb value=f onchange="handleChange(event)" onclick="preventClick(event)">f
<p>Test for <a href="https://code.google.com/p/chromium/issues/detail?id=556677">https://code.google.com/p/chromium/issues/detail?id=556677</a>.
@@ -31,36 +34,18 @@ radio button should fire change events in the direction of left to right.
<input type=radio name=ccc value=y onchange="handleChange(event)"><span dir="rtl">y</span>
<input type=radio name=ccc value=z onchange="handleChange(event)"><span dir="rtl">z</span>
</div>
-<pre id=out></pre>
<script>
-
-var preventClickValues = 'def';
+var lastChangeEventValue = null;
function handleChange(e)
{
- var value = e.target.value;
- print(value + ' dispatched change event');
-}
-
-function handleClick(e)
-{
- var value = e.target.value;
- if (preventClickValues.indexOf(value) !== -1)
- e.preventDefault();
+ lastChangeEventValue = e.target.value;
}
-function print(s)
+function preventClick(e)
{
- document.getElementById('out').textContent += s + '\n';
-}
-
-function pass(s) {
- print('PASS: ' + s);
-}
-
-function fail(s) {
- print('FAIL: ' + s);
+ e.preventDefault();
}
function getRadio(value)
@@ -68,60 +53,52 @@ function getRadio(value)
return document.querySelector('input[value="' + value + '"]');
}
-function assertChecked(value)
-{
- if (getRadio(value).checked)
- pass(value + ' is checked');
- else
- fail(value + ' should be checked');
-}
-
-function assertNotChecked(value)
-{
- if (!getRadio(value).checked)
- pass(value + ' is not checked');
- else
- fail(value + ' should not be checked');
-}
-
-if (window.testRunner)
- testRunner.dumpAsText();
-
if (window.eventSender) {
- getRadio('a').focus();
- eventSender.keyDown('downArrow');
- eventSender.keyDown('downArrow');
-
- getRadio('d').focus();
- eventSender.keyDown('downArrow');
- eventSender.keyDown('downArrow');
-
- assertNotChecked('a');
- assertNotChecked('b');
- assertChecked('c');
-
- assertChecked('d');
- assertNotChecked('e');
- assertNotChecked('f');
-
- getRadio('x').focus();
- eventSender.keyDown('rightArrow');
- eventSender.keyDown('rightArrow');
-
- assertNotChecked('x');
- assertChecked('y');
- assertNotChecked('z');
-
- getRadio('x').focus();
- eventSender.keyDown('downArrow');
-
- assertNotChecked('x');
- assertChecked('y');
- assertNotChecked('z');
-
-
+ test(function() {
+ getRadio('a').focus();
+ eventSender.keyDown('downArrow');
+ assert_equals(lastChangeEventValue, 'b');
+ eventSender.keyDown('downArrow');
+ assert_equals(lastChangeEventValue, 'c');
+ assert_false(getRadio('a').checked);
+ assert_false(getRadio('b').checked);
+ assert_true(getRadio('c').checked);
+ }, 'Pressing an arrow key moves checked state in a radio button group.');
+
+ test(function() {
+ getRadio('d').focus();
+ eventSender.keyDown('downArrow');
+ eventSender.keyDown('downArrow');
+ assert_true(getRadio('d').checked);
+ assert_false(getRadio('e').checked);
+ assert_false(getRadio('f').checked);
+ }, 'Pressing an arrow key doesn\'t move checked state in a radio button group if click events are prevented.');
+
+ test(function() {
+ getRadio('x').focus();
+ eventSender.keyDown('rightArrow');
+ assert_equals(lastChangeEventValue, 'z');
+ assert_false(getRadio('x').checked);
+ assert_false(getRadio('y').checked);
+ assert_true(getRadio('z').checked);
+
+ eventSender.keyDown('rightArrow');
+ assert_equals(lastChangeEventValue, 'y');
+ assert_false(getRadio('x').checked);
+ assert_true(getRadio('y').checked);
+ assert_false(getRadio('z').checked);
+ }, 'Right arrow key should move checked state backward in RTL.');
+
+ test(function() {
+ getRadio('x').focus();
+ getRadio('x').checked = true;
+ eventSender.keyDown('downArrow');
+ assert_equals(lastChangeEventValue, 'y');
+ assert_false(getRadio('x').checked);
+ assert_true(getRadio('y').checked);
+ assert_false(getRadio('z').checked);
+ }, 'Down arrow key should move checked state forward regardless of RTL.');
}
-
</script>
</body>
</html>
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/forms/radio/radio-group-keyboard-change-event-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698