From ce99636cd061b356b6789f3cfc9083828b9cab6c Mon Sep 17 00:00:00 2001 From: Matthew Olsson Date: Sat, 10 Feb 2024 21:11:40 -0700 Subject: [PATCH] LibWeb: Fix check for missing argument in Animation constructor Receiving a null argument has a different result than not passing an argument at all. --- Userland/Libraries/LibWeb/Animations/Animation.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Userland/Libraries/LibWeb/Animations/Animation.cpp b/Userland/Libraries/LibWeb/Animations/Animation.cpp index 64d6252594..ebad82036e 100644 --- a/Userland/Libraries/LibWeb/Animations/Animation.cpp +++ b/Userland/Libraries/LibWeb/Animations/Animation.cpp @@ -23,13 +23,15 @@ JS_DEFINE_ALLOCATOR(Animation); // https://www.w3.org/TR/web-animations-1/#dom-animation-animation JS::NonnullGCPtr Animation::create(JS::Realm& realm, JS::GCPtr effect, JS::GCPtr timeline) { + auto& vm = realm.vm(); + // 1. Let animation be a new Animation object. auto animation = realm.heap().allocate(realm, realm); // 2. Run the procedure to set the timeline of an animation on animation passing timeline as the new timeline or, if // a timeline argument is missing, passing the default document timeline of the Document associated with the // Window that is the current global object. - if (!timeline) { + if (vm.argument_count() < 2) { auto& window = verify_cast(HTML::current_global_object()); timeline = window.associated_document().timeline(); }