Bug 1507067 - [marionette] Add support for EventListener callback to WebElementEventTarget. r=ato a=test-only
authorHenrik Skupin <mail@hskupin.info>
Thu, 10 Jan 2019 14:26:26 +0000
changeset 506628 482eb149ad4a01dd0d192c9136d3dcd3197f4446
parent 506627 888054b8eec1afea3ca6fce6dbb6a0377c11c260
child 506629 189f49635cfd710ab47ad45f24247966bed3dee1
push id10489
push userapavel@mozilla.com
push dateFri, 11 Jan 2019 11:14:05 +0000
treeherdermozilla-beta@189f49635cfd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersato, test-only
bugs1507067
milestone65.0
Bug 1507067 - [marionette] Add support for EventListener callback to WebElementEventTarget. r=ato a=test-only Depends on D16095 Differential Revision: https://phabricator.services.mozilla.com/D16096
testing/marionette/dom.js
--- a/testing/marionette/dom.js
+++ b/testing/marionette/dom.js
@@ -102,17 +102,21 @@ class WebElementEventTarget {
     if (!(event.type in this.listeners)) {
       return;
     }
 
     event.target = this;
 
     let stack = this.listeners[event.type].slice(0);
     stack.forEach(listener => {
-      listener.call(this, event);
+      if (typeof listener.handleEvent == "function") {
+        listener.handleEvent(event);
+      } else {
+        listener(event);
+      }
 
       if (listener.once) {
         this.removeEventListener(event.type, listener);
       }
     });
   }
 
   receiveMessage({name, data, objects}) {