mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 635281 - Implement the value sanitizing algorithm for <input type="number">. r=sicking
--HG-- extra : rebase_source : b4ca5ff2b2ce873012ba3a8e589130123eb40559
This commit is contained in:
parent
5885dd639e
commit
e1126739b0
@ -2459,6 +2459,15 @@ nsHTMLInputElement::SanitizeValue(nsAString& aValue)
|
||||
aValue = nsContentUtils::TrimWhitespace<nsContentUtils::IsHTMLWhitespace>(aValue);
|
||||
}
|
||||
break;
|
||||
case NS_FORM_INPUT_NUMBER:
|
||||
{
|
||||
PRInt32 ec;
|
||||
PromiseFlatString(aValue).ToDouble(&ec);
|
||||
if (NS_FAILED(ec)) {
|
||||
aValue.Truncate();
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=549475
|
||||
var inputTypes =
|
||||
[
|
||||
"text", "password", "search", "tel", "hidden", "checkbox", "radio",
|
||||
"submit", "image", "reset", "button", "email", "url"
|
||||
"submit", "image", "reset", "button", "email", "url", "number",
|
||||
];
|
||||
|
||||
var todoTypes =
|
||||
@ -60,8 +60,7 @@ function sanitizeValue(aType, aValue)
|
||||
// TODO: write the sanitize algorithm.
|
||||
return "";
|
||||
case "number":
|
||||
todo(false, "will be done with bug 635281");
|
||||
return "";
|
||||
return (parseFloat(aValue) + "" === aValue) ? aValue : "";
|
||||
case "range":
|
||||
// TODO: write the sanitize algorithm.
|
||||
return "";
|
||||
@ -77,11 +76,17 @@ function checkSanitizing(element)
|
||||
{
|
||||
var testData =
|
||||
[
|
||||
// For text, password, search, tel, email:
|
||||
"\n\rfoo\n\r",
|
||||
"foo\n\rbar",
|
||||
" foo ",
|
||||
" foo\n\r bar ",
|
||||
// For url:
|
||||
"\r\n foobar \n\r",
|
||||
// For number:
|
||||
"42",
|
||||
"13.37",
|
||||
"1.234567898765432",
|
||||
];
|
||||
|
||||
for each (value in testData) {
|
||||
|
@ -133,7 +133,7 @@ fh.addEntry("field6", "value");
|
||||
fh.addEntry("field7", "value");
|
||||
fh.addEntry("field8", "value");
|
||||
fh.addEntry("field9", "value");
|
||||
fh.addEntry("field10", "value");
|
||||
fh.addEntry("field10", "42");
|
||||
fh.addEntry("searchbar-history", "blacklist test");
|
||||
|
||||
// All these non-implemeted types might need autocomplete tests in the future.
|
||||
@ -705,7 +705,6 @@ function runTest(testNum) {
|
||||
case 401:
|
||||
case 402:
|
||||
case 403:
|
||||
case 404:
|
||||
checkMenuEntries(["value"]);
|
||||
doKey("down");
|
||||
doKey("return");
|
||||
@ -719,17 +718,27 @@ function runTest(testNum) {
|
||||
input = $_(11, "field9");
|
||||
} else if (testNum == 403) {
|
||||
input = $_(12, "field10");
|
||||
} else if (testNum == 404) {
|
||||
// Go to test 500.
|
||||
fh.addEntry("field1", "value1");
|
||||
input = $_(1, "field1");
|
||||
testNum = 499;
|
||||
}
|
||||
|
||||
restoreForm();
|
||||
doKey("down");
|
||||
break;
|
||||
|
||||
case 404:
|
||||
checkMenuEntries(["42"]);
|
||||
doKey("down");
|
||||
doKey("return");
|
||||
checkForm("42");
|
||||
|
||||
// Go to test 500.
|
||||
fh.addEntry("field1", "value1");
|
||||
input = $_(1, "field1");
|
||||
testNum = 499;
|
||||
|
||||
restoreForm();
|
||||
doKey("down");
|
||||
break;
|
||||
|
||||
// Check that the input event is fired.
|
||||
case 500:
|
||||
input.addEventListener("input", function(event) {
|
||||
|
Loading…
Reference in New Issue
Block a user