Support waiting for event in custom element
https://bugs.webkit.org/show_bug.cgi?id=241812

Patch by Youssef Soliman <youssefdevelops@gmail.com> on 2022-06-21
Reviewed by Eric Carlson.

Some media related layout tests require event listeners on custom HTML elements.

* LayoutTests/media/video-test.js:
(waitForEventAndFailFor):
(waitForEventAndTest):
(waitForEventAndTestFor):

Canonical link: https://commits.webkit.org/251718@main

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@295713 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/media/video-test.js b/LayoutTests/media/video-test.js
index 354fa6c..3446058 100644
--- a/LayoutTests/media/video-test.js
+++ b/LayoutTests/media/video-test.js
@@ -283,8 +283,18 @@
     waitForEventAndTest(eventName, "false", true);
 }
 
+function waitForEventAndFailFor(element, eventName)
+{
+    waitForEventAndTest(element, eventName, "false", true);
+}
+
 function waitForEventAndTest(eventName, testFuncString, endit)
 {
+    waitForEventAndTestFor(mediaElement, eventName, testFuncString, endit)
+}
+
+function waitForEventAndTestFor(element, eventName, testFuncString, endit)
+{
     function _eventCallback(event)
     {
         logResult(eval(testFuncString), "EVENT(" + eventName + ") TEST(" + testFuncString + ")");
@@ -292,7 +302,7 @@
             endTest();
     }
 
-    mediaElement.addEventListener(eventName, _eventCallback, true);
+    element.addEventListener(eventName, _eventCallback, true);
 }
 
 function waitForEventOnceOn(element, eventName, func, endit)