mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
LibWeb/WebIDL: Throw correct error when converting integers
When an integer doesn't fit within the range of an integral type defined by WebIDL, the spec says to throw a `TypeError`, not a `RangeError`.
This commit is contained in:
committed by
Ali Mohammad Pur
parent
4e7d3026d2
commit
3be7e88903
@@ -1,3 +1,3 @@
|
|||||||
Made memory [object WebAssembly.Memory] with buffer [object ArrayBuffer] (byteLength 655360)
|
Made memory [object WebAssembly.Memory] with buffer [object ArrayBuffer] (byteLength 655360)
|
||||||
After growing buffer (byteLength 983040)
|
After growing buffer (byteLength 983040)
|
||||||
Got error: 'RangeError: Number '4294967296' is outside of allowed range of 0 to 4294967295'
|
Got error: 'TypeError: Number '4294967296' is outside of allowed range of 0 to 4294967295'
|
||||||
|
|||||||
@@ -384,7 +384,7 @@ JS::ThrowCompletionOr<T> convert_to_int(JS::VM& vm, JS::Value value, EnforceRang
|
|||||||
|
|
||||||
// 3. If x < lowerBound or x > upperBound, then throw a TypeError.
|
// 3. If x < lowerBound or x > upperBound, then throw a TypeError.
|
||||||
if (x < lower_bound || x > upper_bound)
|
if (x < lower_bound || x > upper_bound)
|
||||||
return vm.throw_completion<JS::RangeError>(MUST(String::formatted("Number '{}' is outside of allowed range of {} to {}", x, lower_bound, upper_bound)));
|
return vm.throw_completion<JS::TypeError>(MUST(String::formatted("Number '{}' is outside of allowed range of {} to {}", x, lower_bound, upper_bound)));
|
||||||
|
|
||||||
// 4. Return x.
|
// 4. Return x.
|
||||||
return x;
|
return x;
|
||||||
|
|||||||
Reference in New Issue
Block a user