Commit b7803c6d authored by yosin@chromium.org's avatar yosin@chromium.org

[Tests] We should have interactive validation of required value for the "input" element

https://bugs.webkit.org/show_bug.cgi?id=95817

Reviewed by Kent Tamura.

This patch adds tests for required attribute handling on form
submission of input types. The test script is parametrized for
input type and expected type. Each test file simply call one test
script in common-interactive-validation-required.js.

The test script checks:
  - Don't submit form when required value isn't presented.
  - Submit form when required value is presented.

* fast/forms/date/date-interactive-validation-required-expected.txt: Added.
* fast/forms/date/date-interactive-validation-required.html: Added.
* fast/forms/datetime/datetime-interactive-validation-required-expected.txt: Added.
* fast/forms/datetime/datetime-interactive-validation-required.html: Added.
* fast/forms/datetimelocal/datetimelocal-interactive-validation-required-expected.txt: Added.
* fast/forms/datetimelocal/datetimelocal-interactive-validation-required.html: Added.
* fast/forms/month/month-interactive-validation-required-expected.txt: Added.
* fast/forms/month/month-interactive-validation-required.html: Added.
* fast/forms/number/number-interactive-validation-required-expected.txt: Added.
* fast/forms/number/number-interactive-validation-required.html: Added.
* fast/forms/resources/common-interactive-validation-required.js: Added.
* fast/forms/time/time-interactive-validation-required-expected.txt: Added.
* fast/forms/time/time-interactive-validation-required.html: Added.
* fast/forms/week/week-interactive-validation-required-expected.txt: Added.
* fast/forms/week/week-interactive-validation-required.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@127564 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent ee6f3e4f
2012-09-05 Yoshifumi Inoue <yosin@chromium.org>
[Tests] We should have interactive validation of required value for the "input" element
https://bugs.webkit.org/show_bug.cgi?id=95817
Reviewed by Kent Tamura.
This patch adds tests for required attribute handling on form
submission of input types. The test script is parametrized for
input type and expected type. Each test file simply call one test
script in common-interactive-validation-required.js.
The test script checks:
- Don't submit form when required value isn't presented.
- Submit form when required value is presented.
* fast/forms/date/date-interactive-validation-required-expected.txt: Added.
* fast/forms/date/date-interactive-validation-required.html: Added.
* fast/forms/datetime/datetime-interactive-validation-required-expected.txt: Added.
* fast/forms/datetime/datetime-interactive-validation-required.html: Added.
* fast/forms/datetimelocal/datetimelocal-interactive-validation-required-expected.txt: Added.
* fast/forms/datetimelocal/datetimelocal-interactive-validation-required.html: Added.
* fast/forms/month/month-interactive-validation-required-expected.txt: Added.
* fast/forms/month/month-interactive-validation-required.html: Added.
* fast/forms/number/number-interactive-validation-required-expected.txt: Added.
* fast/forms/number/number-interactive-validation-required.html: Added.
* fast/forms/resources/common-interactive-validation-required.js: Added.
* fast/forms/time/time-interactive-validation-required-expected.txt: Added.
* fast/forms/time/time-interactive-validation-required.html: Added.
* fast/forms/week/week-interactive-validation-required-expected.txt: Added.
* fast/forms/week/week-interactive-validation-required.html: Added.
2012-09-05 Mike Lawther <mikelawther@chromium.org>
Moved mac results to be the generic results, and the existing result to be the chromium
Test interactive validation with required attribute. This test checks if an empty required field prevents form submission and checks if a non-empty required field doesn't prevent form submission.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS queryValues["test"] is "2012-08-25"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common-interactive-validation-required.js"></script>
</head>
<body>
<script>
testInteractiveValidationRequired({
'expectedValue' : '2012-08-25',
'inputType' : 'date',
});
</script>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common-interactive-validation-required.js"></script>
</head>
<body>
<script>
testInteractiveValidationRequired({
'expectedValue' : '1982-11-02T12:34Z',
'inputType' : 'datetime',
});
</script>
</body>
</html>
Test interactive validation with required attribute. This test checks if an empty required field prevents form submission and checks if a non-empty required field doesn't prevent form submission.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS queryValues["test"] is "1982-11-02T12:34"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common-interactive-validation-required.js"></script>
</head>
<body>
<script>
testInteractiveValidationRequired({
'expectedValue' : '1982-11-02T12:34',
'inputType' : 'datetime-local',
});
</script>
</body>
</html>
Test interactive validation with required attribute. This test checks if an empty required field prevents form submission and checks if a non-empty required field doesn't prevent form submission.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS queryValues["test"] is "2012-09"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common-interactive-validation-required.js"></script>
</head>
<body>
<script>
testInteractiveValidationRequired({
'expectedValue' : '2012-09',
'inputType' : 'month',
});
</script>
</body>
</html>
Test interactive validation with required attribute. This test checks if an empty required field prevents form submission and checks if a non-empty required field doesn't prevent form submission.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS queryValues["test"] is "123456789"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common-interactive-validation-required.js"></script>
</head>
<body>
<script>
testInteractiveValidationRequired({
'expectedValue' : '123456789',
'inputType' : 'number',
});
</script>
</body>
</html>
var queryValues = {};
function testInteractiveValidationRequired(config) {
description("Test interactive validation with required attribute. This test checks if an empty required field prevents form submission and checks if a non-empty required field doesn't prevent form submission.");
var expectedValue = config['expectedValue'];
var keyValuePairs = window.location.search.replace('?', '').split('&');
for (var index = 0; index < keyValuePairs.length; ++index) {
var keyValue = keyValuePairs[index].split('=');
queryValues[keyValue[0]] = unescape(keyValue[1]);
}
if (queryValues['submitted']) {
shouldBeEqualToString('queryValues["test"]', expectedValue);
window.jsTestIsAsync = true;
finishJSTest();
return;
}
var form = document.createElement("form");
form.setAttribute("action", window.location);
form.innerHTML = '<input type=hidden name=submitted value=1><input id=submit type=submit><input id=test name=test type=' + config['inputType'] + ' required>';
document.body.appendChild(form);
debug('Submit without required value');
document.getElementById('submit').click();
if (document.activeElement.id != 'test') {
testFailed('Focus should be on test element.');
finishJSTest();
return;
}
debug('Submit with required value');
document.getElementById('test').value = expectedValue;
document.getElementById('submit').click();
testFailed('The form was not submitted.');
finishJSTest();
}
if (window.testRunner)
testRunner.waitUntilDone();
wasPostTestScriptParsed = true;
Test interactive validation with required attribute. This test checks if an empty required field prevents form submission and checks if a non-empty required field doesn't prevent form submission.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS queryValues["test"] is "12:34"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common-interactive-validation-required.js"></script>
</head>
<body>
<script>
testInteractiveValidationRequired({
'expectedValue' : '12:34',
'inputType' : 'time',
});
</script>
</body>
</html>
Test interactive validation with required attribute. This test checks if an empty required field prevents form submission and checks if a non-empty required field doesn't prevent form submission.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS queryValues["test"] is "2012-W15"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<html>
<head>
<script src="../../js/resources/js-test-pre.js"></script>
<script src="../resources/common-interactive-validation-required.js"></script>
</head>
<body>
<script>
testInteractiveValidationRequired({
'expectedValue' : '2012-W15',
'inputType' : 'week',
});
</script>
</body>
</html>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment