summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Bindings/WindowObject.cpp
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2020-05-21 00:55:01 +0100
committerAndreas Kling <kling@serenityos.org>2020-05-21 15:16:48 +0200
commite3e9749d884813d886d8b9c4fe5417ce88238b1e (patch)
treeff47fedaff60f04fa324b10d2ddbb166e3fa2e07 /Libraries/LibWeb/Bindings/WindowObject.cpp
parent2d503b20da1c6ba157060303c2e6ebbba31e0c68 (diff)
downloadserenity-e3e9749d884813d886d8b9c4fe5417ce88238b1e.zip
LibWeb: Let various functions throw if not enough arguments
...instead of handing out null / undefined / empty values.
Diffstat (limited to 'Libraries/LibWeb/Bindings/WindowObject.cpp')
-rw-r--r--Libraries/LibWeb/Bindings/WindowObject.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/Libraries/LibWeb/Bindings/WindowObject.cpp b/Libraries/LibWeb/Bindings/WindowObject.cpp
index b0a00dac16..7f020fc6e3 100644
--- a/Libraries/LibWeb/Bindings/WindowObject.cpp
+++ b/Libraries/LibWeb/Bindings/WindowObject.cpp
@@ -128,8 +128,8 @@ JS::Value WindowObject::set_interval(JS::Interpreter& interpreter)
auto* impl = impl_from(interpreter);
if (!impl)
return {};
- if (interpreter.argument_count() < 2)
- return {};
+ if (!interpreter.argument_count())
+ return interpreter.throw_exception<JS::TypeError>("setInterval() needs at least one argument");
auto* callback_object = interpreter.argument(0).to_object(interpreter);
if (!callback_object)
return {};
@@ -148,7 +148,7 @@ JS::Value WindowObject::set_timeout(JS::Interpreter& interpreter)
if (!impl)
return {};
if (!interpreter.argument_count())
- return {};
+ return interpreter.throw_exception<JS::TypeError>("setTimeout() needs at least one argument");
auto* callback_object = interpreter.argument(0).to_object(interpreter);
if (!callback_object)
return {};
@@ -172,7 +172,7 @@ JS::Value WindowObject::request_animation_frame(JS::Interpreter& interpreter)
if (!impl)
return {};
if (!interpreter.argument_count())
- return {};
+ return interpreter.throw_exception<JS::TypeError>("requestAnimationFrame() needs one argument");
auto* callback_object = interpreter.argument(0).to_object(interpreter);
if (!callback_object)
return {};
@@ -187,7 +187,7 @@ JS::Value WindowObject::cancel_animation_frame(JS::Interpreter& interpreter)
if (!impl)
return {};
if (!interpreter.argument_count())
- return {};
+ return interpreter.throw_exception<JS::TypeError>("cancelAnimationFrame() needs one argument");
auto id = interpreter.argument(0).to_i32(interpreter);
if (interpreter.exception())
return {};