Skip to content
Permalink
Browse files
2009-10-05 Kent Tamura <tkent@chromium.org>
        Reviewed by Darin Adler.

        Implement min/max attributes, ValidityState.rangeUnderflow and
        ValidityState.rangeOverflow for <input type=number> and <input type=range>
        https://bugs.webkit.org/show_bug.cgi?id=29069

        * fast/forms/ValidityState-rangeOverflow-number-expected.txt: Added.
        * fast/forms/ValidityState-rangeOverflow-number.html: Added.
        * fast/forms/ValidityState-rangeOverflow-range-expected.txt: Added.
        * fast/forms/ValidityState-rangeOverflow-range.html: Added.
        * fast/forms/ValidityState-rangeUnderflow-number-expected.txt: Added.
        * fast/forms/ValidityState-rangeUnderflow-number.html: Added.
        * fast/forms/ValidityState-rangeUnderflow-range-expected.txt: Added.
        * fast/forms/ValidityState-rangeUnderflow-range.html: Added.
        * fast/forms/input-minmax-expected.txt: Added.
        * fast/forms/input-minmax.html: Added.
        * fast/forms/script-tests/ValidityState-rangeOverflow-number.js: Added.
        * fast/forms/script-tests/ValidityState-rangeOverflow-range.js: Added.
        * fast/forms/script-tests/ValidityState-rangeUnderflow-number.js: Added.
        * fast/forms/script-tests/ValidityState-rangeUnderflow-range.js: Added.
        * fast/forms/script-tests/input-minmax.js: Added.
2009-10-05  Kent Tamura  <tkent@chromium.org>

        Reviewed by Darin Adler.

        Implement min/max attributes, ValidityState.rangeUnderflow and
        ValidityState.rangeOverflow for <input type=number> and <input type=range>
        https://bugs.webkit.org/show_bug.cgi?id=29069

        Tests: fast/forms/ValidityState-rangeOverflow-number.html
               fast/forms/ValidityState-rangeOverflow-range.html
               fast/forms/ValidityState-rangeUnderflow-number.html
               fast/forms/ValidityState-rangeUnderflow-range.html
               fast/forms/input-minmax.html

        * html/HTMLInputElement.cpp:
        (WebCore::HTMLInputElement::rangeUnderflow):
        (WebCore::HTMLInputElement::rangeOverflow):
        (WebCore::HTMLInputElement::rangeMinimum):
        (WebCore::HTMLInputElement::rangeMaximum):
        * html/HTMLInputElement.h:
        * html/HTMLInputElement.idl:
        * html/ValidityState.cpp:
        (WebCore::ValidityState::rangeUnderflow):
        (WebCore::ValidityState::rangeOverflow):
        * html/ValidityState.h:
        * rendering/RenderSlider.cpp:
        (WebCore::SliderRange::SliderRange):
        (WebCore::SliderRange::valueFromElement):

Canonical link: https://commits.webkit.org/40663@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@49104 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
eseidel committed Oct 5, 2009
1 parent 7877da8 commit f2ad58b56b48be5452afde463c1591020dbde9b0
Showing 23 changed files with 520 additions and 12 deletions.
@@ -1,3 +1,27 @@
2009-10-05 Kent Tamura <tkent@chromium.org>

Reviewed by Darin Adler.

Implement min/max attributes, ValidityState.rangeUnderflow and
ValidityState.rangeOverflow for <input type=number> and <input type=range>
https://bugs.webkit.org/show_bug.cgi?id=29069

* fast/forms/ValidityState-rangeOverflow-number-expected.txt: Added.
* fast/forms/ValidityState-rangeOverflow-number.html: Added.
* fast/forms/ValidityState-rangeOverflow-range-expected.txt: Added.
* fast/forms/ValidityState-rangeOverflow-range.html: Added.
* fast/forms/ValidityState-rangeUnderflow-number-expected.txt: Added.
* fast/forms/ValidityState-rangeUnderflow-number.html: Added.
* fast/forms/ValidityState-rangeUnderflow-range-expected.txt: Added.
* fast/forms/ValidityState-rangeUnderflow-range.html: Added.
* fast/forms/input-minmax-expected.txt: Added.
* fast/forms/input-minmax.html: Added.
* fast/forms/script-tests/ValidityState-rangeOverflow-number.js: Added.
* fast/forms/script-tests/ValidityState-rangeOverflow-range.js: Added.
* fast/forms/script-tests/ValidityState-rangeUnderflow-number.js: Added.
* fast/forms/script-tests/ValidityState-rangeUnderflow-range.js: Added.
* fast/forms/script-tests/input-minmax.js: Added.

2009-10-05 Kent Tamura <tkent@chromium.org>

Reviewed by Eric Seidel.
@@ -0,0 +1,23 @@
This test aims to check for rangeOverflow flag with type=number input fields

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS The value "101" doesn't overflow the maximum value "100".
PASS The value "99" doesn't overflow the maximum value "100".
PASS The value "-101" doesn't overflow the maximum value "-100".
PASS The value "99" doesn't overflow the maximum value "1E+2".
PASS The value "0.99" doesn't overflow the maximum value "1.00".
PASS The value "abc" doesn't overflow the maximum value "100".
PASS The value "" doesn't overflow the maximum value "-1".
PASS The value "101" doesn't overflow the maximum value "".
PASS The value "101" doesn't overflow the maximum value "xxx".
PASS The value "0.999999999999999999999999999999999999999999" doesn't overflow the maximum value "0.999999999999999999999999999999999999999998".
PASS The value "101" overflows the maximum value "100".
PASS The value "-99" overflows the maximum value "-100".
PASS The value "101" overflows the maximum value "1E+2".
PASS The value "101" overflows the maximum value "100".
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/ValidityState-rangeOverflow-number.js"></script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
@@ -0,0 +1,23 @@
This test aims to check for rangeOverflow flag with type=range input fields

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS The value "101" doesn't overflow the maximum value "100".
PASS The value "99" doesn't overflow the maximum value "100".
PASS The value "-101" doesn't overflow the maximum value "-100".
PASS The value "99" doesn't overflow the maximum value "1E+2".
PASS The value "0.99" doesn't overflow the maximum value "1.00".
PASS The value "abc" doesn't overflow the maximum value "100".
PASS The value "" doesn't overflow the maximum value "-1".
PASS The value "0.999999999999999999999999999999999999999999" doesn't overflow the maximum value "0.999999999999999999999999999999999999999998".
PASS The value "101" doesn't overflow the maximum value "100".
PASS The value "101" overflows the maximum value "100".
PASS The value "-99" overflows the maximum value "-100".
PASS The value "101" overflows the maximum value "1E+2".
PASS The value "101" overflows the maximum value "".
PASS The value "101" overflows the maximum value "xxx".
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/ValidityState-rangeOverflow-range.js"></script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
@@ -0,0 +1,23 @@
This test aims to check for rangeUnderflow flag with type=number input fields

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS The value "99" doesn't underflow the minimum value "100".
PASS The value "101" doesn't underflow the minimum value "100".
PASS The value "-99" doesn't underflow the minimum value "-100".
PASS The value "101" doesn't underflow the minimum value "1E+2".
PASS The value "1.01" doesn't underflow the minimum value "1.00".
PASS The value "abc" doesn't underflow the minimum value "100".
PASS The value "" doesn't underflow the minimum value "1".
PASS The value "-1" doesn't underflow the minimum value "".
PASS The value "-1" doesn't underflow the minimum value "xxx".
PASS The value "0.999999999999999999999999999999999999999998" doesn't underflow the minimum value "0.999999999999999999999999999999999999999999".
PASS The value "99" underflows the minimum value "100".
PASS The value "-101" underflows the minimum value "-100".
PASS The value "99" underflows the minimum value "1E+2".
PASS The value "101" underflows the minimum value "200".
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/ValidityState-rangeUnderflow-number.js"></script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
@@ -0,0 +1,23 @@
This test aims to check for rangeUnderflow flag with type=range input fields

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS The value "99" doesn't underflow the minimum value "100".
PASS The value "101" doesn't underflow the minimum value "100".
PASS The value "-99" doesn't underflow the minimum value "-100".
PASS The value "101" doesn't underflow the minimum value "1E+2".
PASS The value "1.01" doesn't underflow the minimum value "1.00".
PASS The value "abc" doesn't underflow the minimum value "100".
PASS The value "" doesn't underflow the minimum value "1".
PASS The value "0.999999999999999999999999999999999999999998" doesn't underflow the minimum value "0.999999999999999999999999999999999999999999".
PASS The value "101" doesn't underflow the minimum value "100".
PASS The value "99" underflows the minimum value "100".
PASS The value "-101" underflows the minimum value "-100".
PASS The value "99" underflows the minimum value "1E+2".
PASS The value "-1" underflows the minimum value "".
PASS The value "-1" underflows the minimum value "xxx".
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/ValidityState-rangeUnderflow-range.js"></script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
@@ -0,0 +1,21 @@
Tests the behavior of .min and .max of HTMLInputElement.

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS input.min is ""
PASS input.max is ""
PASS input.min is "0"
PASS input.max is "100"
PASS input.min is "abc"
PASS input.max is "qwerty"
PASS input.getAttribute("min") is "foo"
PASS input.getAttribute("max") is "bar"
PASS input.getAttribute("min") is ""
PASS input.getAttribute("max") is ""
PASS input.min is ""
PASS input.max is ""
PASS successfullyParsed is true

TEST COMPLETE

@@ -0,0 +1,13 @@
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<link rel="stylesheet" href="../../fast/js/resources/js-test-style.css">
<script src="../../fast/js/resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script src="script-tests/input-minmax.js"></script>
<script src="../../fast/js/resources/js-test-post.js"></script>
</body>
</html>
@@ -0,0 +1,40 @@
description('This test aims to check for rangeOverflow flag with type=number input fields');

var input = document.createElement('input');

function check(value, max, overflowExpected)
{
input.value = value;
input.max = max;
var actual = input.validity.rangeOverflow;
var didPass = actual == overflowExpected;
var resultText = 'The value "' + input.value + '" ' + (actual ? 'overflows' : 'doesn\'t overflow') + ' the maximum value "' + input.max + '".';
if (didPass)
testPassed(resultText);
else
testFailed(resultText);
}

// No overflow cases
input.type = 'text'; // No overflow for type=text.
check('101', '100', false);
input.type = 'number';
check('99', '100', false); // Very normal case.
check('-101', '-100', false);
check('99', '1E+2', false);
check('0.99', '1.00', false);
check('abc', '100', false); // Invalid value.
check('', '-1', false); // No value.
check('101', '', false); // No max.
check('101', 'xxx', false); // Invalid max.
// The following case should be rangeOverflow==true ideally. But the "double" type doesn't have enough precision.
check('0.999999999999999999999999999999999999999999', '0.999999999999999999999999999999999999999998', false);

// Overflow cases
check('101', '100', true);
check('-99', '-100', true);
check('101', '1E+2', true);
input.min = '200'; // value < min && value > max
check('101', '100', true);

var successfullyParsed = true;
@@ -0,0 +1,43 @@
description('This test aims to check for rangeOverflow flag with type=range input fields');

var input = document.createElement('input');

function check(value, max, overflowExpected)
{
input.value = value;
input.max = max;
var actual = input.validity.rangeOverflow;
var didPass = actual == overflowExpected;
var resultText = 'The value "' + input.value + '" ' + (actual ? 'overflows' : 'doesn\'t overflow') + ' the maximum value "' + input.max + '".';
if (didPass)
testPassed(resultText);
else
testFailed(resultText);
}

// No overflow cases
input.type = 'text'; // No overflow for type=text.
check('101', '100', false);
input.type = 'range';
check('99', '100', false); // Very normal case.
check('-101', '-100', false);
check('99', '1E+2', false);
check('0.99', '1.00', false);
check('abc', '100', false); // Invalid value.
check('', '-1', false); // No value.
// The following case should be rangeOverflow==true ideally. But the "double" type doesn't have enough precision.
check('0.999999999999999999999999999999999999999999', '0.999999999999999999999999999999999999999998', false);
input.min = '200'; // If min > max, max is reset to min.
check('101', '100', false);
input.min = '';

// Overflow cases
check('101', '100', true);
input.min = '-200';
check('-99', '-100', true);
input.min = '';
check('101', '1E+2', true);
check('101', '', true); // No max.
check('101', 'xxx', true); // Invalid max.

var successfullyParsed = true;
@@ -0,0 +1,40 @@
description('This test aims to check for rangeUnderflow flag with type=number input fields');

var input = document.createElement('input');

function check(value, min, underflowExpected)
{
input.value = value;
input.min = min;
var actual = input.validity.rangeUnderflow;
var didPass = actual == underflowExpected;
var resultText = 'The value "' + input.value + '" ' + (actual ? 'underflows' : 'doesn\'t underflow') + ' the minimum value "' + input.min + '".';
if (didPass)
testPassed(resultText);
else
testFailed(resultText);
}

// No underflow cases
input.type = 'text'; // No underflow for type=text.
check('99', '100', false);
input.type = 'number';
check('101', '100', false); // Very normal case.
check('-99', '-100', false);
check('101', '1E+2', false);
check('1.01', '1.00', false);
check('abc', '100', false); // Invalid value.
check('', '1', false); // No value.
check('-1', '', false); // No min.
check('-1', 'xxx', false); // Invalid min.
// The following case should be rangeUnderflow==true ideally. But the "double" type doesn't have enough precision.
check('0.999999999999999999999999999999999999999998', '0.999999999999999999999999999999999999999999', false);

// Underflow cases
check('99', '100', true);
check('-101', '-100', true);
check('99', '1E+2', true);
input.max = '100'; // value < min && value > max
check('101', '200', true);

var successfullyParsed = true;
@@ -0,0 +1,41 @@
description('This test aims to check for rangeUnderflow flag with type=range input fields');

var input = document.createElement('input');

function check(value, min, underflowExpected)
{
input.value = value;
input.min = min;
var actual = input.validity.rangeUnderflow;
var didPass = actual == underflowExpected;
var resultText = 'The value "' + input.value + '" ' + (actual ? 'underflows' : 'doesn\'t underflow') + ' the minimum value "' + input.min + '".';
if (didPass)
testPassed(resultText);
else
testFailed(resultText);
}

// No underflow cases
input.type = 'text'; // No overflow for type=text.
check('99', '100', false);
input.type = 'range';
check('101', '100', false); // Very normal case.
check('-99', '-100', false);
check('101', '1E+2', false);
check('1.01', '1.00', false);
check('abc', '100', false); // Invalid value.
check('', '1', false); // No value.
// The following case should be rangeUnderflow==true ideally. But the "double" type doesn't have enough precision.
check('0.999999999999999999999999999999999999999998', '0.999999999999999999999999999999999999999999', false);
input.max = '0'; // If min > max, max is reset to min and min is not changed.
check('101', '100', false);
input.max = '';

// Underflow cases
check('99', '100', true);
check('-101', '-100', true);
check('99', '1E+2', true);
check('-1', '', true); // No min.
check('-1', 'xxx', true); // Invalid min.

var successfullyParsed = true;

0 comments on commit f2ad58b

Please sign in to comment.