mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-02 08:22:55 +00:00
LibWeb: Add test for valueAsNumber
This commit is contained in:
parent
3572a047d1
commit
d503fd51ec
Notes:
sideshowbarker
2024-07-17 06:40:21 +09:00
Author: https://github.com/Lubrsi
Commit: d503fd51ec
Pull-request: https://github.com/SerenityOS/serenity/pull/21932
Reviewed-by: https://github.com/awesomekling
2 changed files with 95 additions and 0 deletions
|
@ -0,0 +1,46 @@
|
|||
valueAsNumber getter:
|
||||
hidden: NaN
|
||||
text: NaN
|
||||
search: NaN
|
||||
tel: NaN
|
||||
url: NaN
|
||||
email: NaN
|
||||
password: NaN
|
||||
date: NaN
|
||||
month: NaN
|
||||
week: NaN
|
||||
time: NaN
|
||||
datetime-local: NaN
|
||||
number: 100
|
||||
range: 100
|
||||
color: NaN
|
||||
checkbox: NaN
|
||||
radio: NaN
|
||||
file: NaN
|
||||
submit: NaN
|
||||
image: NaN
|
||||
reset: NaN
|
||||
button: NaN
|
||||
valueAsNumber setter:
|
||||
hidden threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
text threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
search threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
tel threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
url threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
email threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
password threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
date did not throw: NaN
|
||||
month did not throw: NaN
|
||||
week did not throw: NaN
|
||||
time did not throw: NaN
|
||||
datetime-local threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
number did not throw: 100
|
||||
range did not throw: 100
|
||||
color threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
checkbox threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
radio threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
file threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
submit threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
image threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
reset threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
||||
button threw exception: InvalidStateError: valueAsNumber: Invalid input type used
|
|
@ -0,0 +1,49 @@
|
|||
<input id="input-element" value="100" style="display: none;" />
|
||||
<script src="../include.js"></script>
|
||||
<script>
|
||||
test(() => {
|
||||
const inputElement = document.getElementById("input-element");
|
||||
|
||||
const allInputTypes = [
|
||||
"hidden",
|
||||
"text",
|
||||
"search",
|
||||
"tel",
|
||||
"url",
|
||||
"email",
|
||||
"password",
|
||||
"date",
|
||||
"month",
|
||||
"week",
|
||||
"time",
|
||||
"datetime-local",
|
||||
"number",
|
||||
"range",
|
||||
"color",
|
||||
"checkbox",
|
||||
"radio",
|
||||
"file",
|
||||
"submit",
|
||||
"image",
|
||||
"reset",
|
||||
"button",
|
||||
];
|
||||
|
||||
println("valueAsNumber getter:");
|
||||
for (const type of allInputTypes) {
|
||||
inputElement.type = type;
|
||||
println(`${type}: ${inputElement.valueAsNumber}`);
|
||||
}
|
||||
|
||||
println("valueAsNumber setter:");
|
||||
for (const type of allInputTypes) {
|
||||
try {
|
||||
inputElement.type = type;
|
||||
inputElement.valueAsNumber = 100;
|
||||
println(`${type} did not throw: ${inputElement.valueAsNumber}`);
|
||||
} catch (e) {
|
||||
println(`${type} threw exception: ${e.name}: ${e.message}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue