mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 813936 - Update nsHTMLInputElement::GetStepBase() to return the default value if there is no min. r=smaug
This commit is contained in:
parent
91efd22fff
commit
85440b01dc
@ -1204,6 +1204,19 @@ nsHTMLInputElement::GetStepBase() const
|
||||
{
|
||||
double stepBase = GetMinAsDouble();
|
||||
|
||||
// If @min is not a double, we should use defaultValue.
|
||||
if (MOZ_DOUBLE_IS_NaN(stepBase)) {
|
||||
nsAutoString stringValue;
|
||||
GetAttr(kNameSpaceID_None, nsGkAtoms::value, stringValue);
|
||||
|
||||
nsresult ec;
|
||||
stepBase = stringValue.ToDouble(&ec);
|
||||
|
||||
if (NS_FAILED(ec)) {
|
||||
stepBase = MOZ_DOUBLE_NaN();
|
||||
}
|
||||
}
|
||||
|
||||
return MOZ_DOUBLE_IS_NaN(stepBase) ? kDefaultStepBase : stepBase;
|
||||
}
|
||||
|
||||
|
@ -45,8 +45,11 @@ var types = [
|
||||
[ 'button', false ],
|
||||
];
|
||||
|
||||
var input = document.createElement("input");
|
||||
document.getElementById('content').appendChild(input);
|
||||
function getFreshElement(type) {
|
||||
var elmt = document.createElement('input');
|
||||
elmt.type = type;
|
||||
return elmt;
|
||||
}
|
||||
|
||||
function checkValidity(aElement, aValidity, aApply, aData)
|
||||
{
|
||||
@ -74,7 +77,7 @@ function checkValidity(aElement, aValidity, aApply, aData)
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
SpecialPowers.pushPrefEnv({'set': [["dom.experimental_forms", true]]}, function() {
|
||||
for each (var data in types) {
|
||||
input.type = data[0];
|
||||
var input = getFreshElement(data[0]);
|
||||
var apply = data[1];
|
||||
|
||||
if (data[2]) {
|
||||
@ -227,10 +230,35 @@ for each (var data in types) {
|
||||
input.max = '10';
|
||||
input.value = '-9';
|
||||
checkValidity(input, false, apply, {low: -10, high: -8});
|
||||
|
||||
// If there is a value defined but no min, the step base is the value.
|
||||
input = getFreshElement(data[0]);
|
||||
input.setAttribute('value', '1');
|
||||
input.step = 2;
|
||||
checkValidity(input, true, apply);
|
||||
|
||||
input.value = 3;
|
||||
checkValidity(input, true, apply);
|
||||
|
||||
input.value = 2;
|
||||
checkValidity(input, false, apply, {low: 1, high: 3});
|
||||
|
||||
// Should also work with defaultValue.
|
||||
input = getFreshElement(data[0]);
|
||||
input.defaultValue = 1;
|
||||
input.step = 2;
|
||||
checkValidity(input, true, apply);
|
||||
|
||||
input.value = 3;
|
||||
checkValidity(input, true, apply);
|
||||
|
||||
input.value = 2;
|
||||
checkValidity(input, false, apply, {low: 1, high: 3});
|
||||
}
|
||||
|
||||
if (input.type == 'number') {
|
||||
// Check that when the higher value is higher than max, we don't show it.
|
||||
input = getFreshElement(data[0]);
|
||||
input.step = '2';
|
||||
input.min = '1';
|
||||
input.max = '10.9';
|
||||
@ -240,12 +268,6 @@ for each (var data in types) {
|
||||
"The nearest valid value is 9.",
|
||||
"The validation message should not include the higher value.");
|
||||
}
|
||||
|
||||
// Cleaning up,
|
||||
input.removeAttribute('step');
|
||||
input.removeAttribute('max');
|
||||
input.removeAttribute('min');
|
||||
input.value = '';
|
||||
}
|
||||
|
||||
SimpleTest.finish();
|
||||
|
@ -124,8 +124,6 @@ function checkStepDownForNumber()
|
||||
[ '1', null, null, null, 1.1, '0', false ],
|
||||
// With step values.
|
||||
[ '1', '0.5', null, null, null, '0.5', false ],
|
||||
[ null, '0.5', null, null, null, '0', false ],
|
||||
[ null, '0.5', null, null, null, '-0.5', false ],
|
||||
[ '1', '0.25', null, null, 4, '0', false ],
|
||||
// step = 0 isn't allowed (-> step = 1).
|
||||
[ '1', '0', null, null, null, '0', false ],
|
||||
@ -147,21 +145,21 @@ function checkStepDownForNumber()
|
||||
[ '1', null, null, '-10', null, '-10', false ],
|
||||
[ '1', null, null, '1', null, '0', false ],
|
||||
[ '5', null, null, '3', '3', '2', false ],
|
||||
[ '5', '2', null, '3', '2', '2', false ],
|
||||
[ '5', '2', '-6', '3', '2', '2', false ],
|
||||
[ '-3', '5', '-10', '-3', null, '-5', false ],
|
||||
// Step mismatch.
|
||||
[ '1', '2', '-2', null, null, '0', false ],
|
||||
[ '3', '2', '-2', null, null, '2', false ],
|
||||
[ '3', '2', '-2', null, '2', '0', false ],
|
||||
[ '3', '2', '-2', null, '-2', '6', false ],
|
||||
[ '1', '2', null, null, null, '0', false ],
|
||||
[ '1', '2', '-6', null, null, '0', false ],
|
||||
[ '1', '2', '-2', null, null, '0', false ],
|
||||
[ '1', '3', null, null, null, '0', false ],
|
||||
[ '2', '3', null, null, null, '0', false ],
|
||||
[ '1', '3', '-6', null, null, '0', false ],
|
||||
[ '2', '3', '-6', null, null, '0', false ],
|
||||
[ '2', '3', '1', null, null, '1', false ],
|
||||
[ '5', '3', '1', null, null, '4', false ],
|
||||
[ '3', '2', null, null, null, '2', false ],
|
||||
[ '5', '2', null, null, null, '4', false ],
|
||||
[ '3', '2', '-6', null, null, '2', false ],
|
||||
[ '5', '2', '-6', null, null, '4', false ],
|
||||
[ '6', '2', '1', null, null, '5', false ],
|
||||
[ '8', '3', '1', null, null, '7', false ],
|
||||
[ '9', '2', '-10', null, null, '8', false ],
|
||||
@ -178,13 +176,16 @@ function checkStepDownForNumber()
|
||||
[ '0', 'ANY', null, null, 1, null, true ],
|
||||
[ '0', 'AnY', null, null, 1, null, true ],
|
||||
[ '0', 'aNy', null, null, 1, null, true ],
|
||||
// With @value = step base.
|
||||
[ '1', '2', null, null, null, '-1', false ],
|
||||
];
|
||||
|
||||
var element = document.createElement("input");
|
||||
element.type = 'number';
|
||||
for each (var data in testData) {
|
||||
var element = document.createElement("input");
|
||||
element.type = 'number';
|
||||
|
||||
if (data[0] != null) {
|
||||
element.value = data[0];
|
||||
element.setAttribute('value', data[0]);
|
||||
}
|
||||
|
||||
if (data[1] != null) {
|
||||
@ -216,10 +217,6 @@ function checkStepDownForNumber()
|
||||
} finally {
|
||||
is(exceptionCaught, data[6], "exception status should be " + data[6]);
|
||||
}
|
||||
|
||||
element.removeAttribute('step');
|
||||
element.removeAttribute('min');
|
||||
element.removeAttribute('max');
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,8 +237,6 @@ function checkStepUpForNumber()
|
||||
[ '1', null, null, null, 1.1, '2', false ],
|
||||
// With step values.
|
||||
[ '1', '0.5', null, null, null, '1.5', false ],
|
||||
[ null, '0.5', null, null, null, '2', false ],
|
||||
[ null, '0.5', null, null, null, '2.5', false ],
|
||||
[ '1', '0.25', null, null, 4, '2', false ],
|
||||
// step = 0 isn't allowed (-> step = 1).
|
||||
[ '1', '0', null, null, null, '2', false ],
|
||||
@ -269,7 +264,7 @@ function checkStepUpForNumber()
|
||||
[ '1', '2', '0', null, null, '2', false ],
|
||||
[ '1', '2', '0', null, '2', '4', false ],
|
||||
[ '8', '2', null, '9', null, '8', false ],
|
||||
[ '-3', '2', null, null, null, '-2', false ],
|
||||
[ '-3', '2', '-6', null, null, '-2', false ],
|
||||
[ '9', '3', '-10', null, null, '11', false ],
|
||||
[ '7', '3', '-10', null, null, '8', false ],
|
||||
[ '7', '3', '5', null, null, '8', false ],
|
||||
@ -282,8 +277,8 @@ function checkStepUpForNumber()
|
||||
[ '-9', '3', '-8', '-1', '5', '-2', false ],
|
||||
[ '-9', '3', '8', '15', '15', '14', false ],
|
||||
[ '-1', '3', '-1', '4', '3', '2', false ],
|
||||
[ '-3', '2', null, '-2', null, '-2', false ],
|
||||
[ '-3', '2', null, '-1', null, '-2', false ],
|
||||
[ '-3', '2', '-6', '-2', null, '-2', false ],
|
||||
[ '-3', '2', '-6', '-1', null, '-2', false ],
|
||||
// value = "" (NaN).
|
||||
[ '', null, null, null, null, '', false ],
|
||||
// With step = 'any'.
|
||||
@ -291,13 +286,16 @@ function checkStepUpForNumber()
|
||||
[ '0', 'ANY', null, null, 1, null, true ],
|
||||
[ '0', 'AnY', null, null, 1, null, true ],
|
||||
[ '0', 'aNy', null, null, 1, null, true ],
|
||||
// With @value = step base.
|
||||
[ '1', '2', null, null, null, '3', false ],
|
||||
];
|
||||
|
||||
var element = document.createElement("input");
|
||||
element.type = 'number';
|
||||
for each (var data in testData) {
|
||||
var element = document.createElement("input");
|
||||
element.type = 'number';
|
||||
|
||||
if (data[0] != null) {
|
||||
element.value = data[0];
|
||||
element.setAttribute('value', data[0]);
|
||||
}
|
||||
|
||||
if (data[1] != null) {
|
||||
@ -329,10 +327,6 @@ function checkStepUpForNumber()
|
||||
} finally {
|
||||
is(exceptionCaught, data[6], "exception status should be " + data[6]);
|
||||
}
|
||||
|
||||
element.removeAttribute('step');
|
||||
element.removeAttribute('min');
|
||||
element.removeAttribute('max');
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user