소스 검색

LibWeb: Guard MediaQueryList event listener removal against null

A recently imported WPT test has a subtest that effectively does the
following:

    const mql = window.matchMedia("");
    mql.removeListener(null);
Timothy Flynn 8 달 전
부모
커밋
3e5476c9e0
1개의 변경된 파일2개의 추가작업 그리고 1개의 파일을 삭제
  1. 2 1
      Libraries/LibWeb/CSS/MediaQueryList.cpp

+ 2 - 1
Libraries/LibWeb/CSS/MediaQueryList.cpp

@@ -99,7 +99,8 @@ void MediaQueryList::remove_listener(JS::GCPtr<DOM::IDLEventListener> listener)
     // 1. Remove an event listener from the associated list of event listeners, whose type is change, callback is listener, and capture is false.
     // NOTE: While the spec doesn't technically use remove_event_listener and instead manipulates the list directly, every major engine uses remove_event_listener.
     //       This means if an event listener removes another event listener that comes after it, the removed event listener will not be invoked.
-    remove_event_listener_without_options(HTML::EventNames::change, *listener);
+    if (listener)
+        remove_event_listener_without_options(HTML::EventNames::change, *listener);
 }
 
 void MediaQueryList::set_onchange(WebIDL::CallbackType* event_handler)