LibWeb: Allow setInterval() with no interval

This commit is contained in:
Linus Groh 2020-05-21 01:10:44 +01:00 committed by Andreas Kling
parent e3e9749d88
commit c769784406
Notes: sideshowbarker 2024-07-19 06:17:16 +09:00

View file

@ -135,9 +135,14 @@ JS::Value WindowObject::set_interval(JS::Interpreter& interpreter)
return {};
if (!callback_object->is_function())
return interpreter.throw_exception<JS::TypeError>("Not a function");
auto interval = interpreter.argument(1).to_i32(interpreter);
if (interpreter.exception())
return {};
i32 interval = 0;
if (interpreter.argument_count() >= 2) {
interval = interpreter.argument(1).to_i32(interpreter);
if (interpreter.exception())
return {};
}
impl->set_interval(*static_cast<JS::Function*>(callback_object), interval);
return JS::js_undefined();
}