Bug 1354211 - Add shorthand for emulating DOM blur event. r?automatedtester draft
authorAndreas Tolfsen <ato@sny.no>
Sun, 31 Dec 2017 14:36:03 +0000
changeset 719570 74258eee3a9e229b4bf29928389241a0b3ad064d
parent 719569 53070397813ec6b1a71d304033edc460fbccf765
child 719571 328157a76ddd6a3ea61ba139f6c45a93bee4f70b
push id95293
push userbmo:ato@sny.no
push dateFri, 12 Jan 2018 10:32:36 +0000
reviewersautomatedtester
bugs1354211
milestone59.0a1
Bug 1354211 - Add shorthand for emulating DOM blur event. r?automatedtester As part of the focussing steps we subsequently need to blur the element after a focus. MozReview-Commit-ID: xyCcmqeOpO
testing/marionette/event.js
--- a/testing/marionette/event.js
+++ b/testing/marionette/event.js
@@ -1384,16 +1384,25 @@ event.focus = function(el, opts = {}) {
   let doc = el.ownerDocument || el.document;
   let win = doc.defaultView;
 
   let ev = new win.FocusEvent(el);
   ev.initEvent("focus", opts.canBubble, true);
   el.dispatchEvent(ev);
 };
 
+event.blur = function(el, {canBubble = true} = {}) {
+  let doc = el.ownerDocument || el.document;
+  let win = doc.defaultView;
+
+  let ev = new win.FocusEvent(el);
+  ev.initEvent("blur", canBubble, true);
+  el.dispatchEvent(ev);
+};
+
 event.mouseover = function(el, modifiers = {}, opts = {}) {
   return event.sendEvent("mouseover", el, modifiers, opts);
 };
 
 event.mousemove = function(el, modifiers = {}, opts = {}) {
   return event.sendEvent("mousemove", el, modifiers, opts);
 };