Bug 1354211 - Add shorthand for emulating DOM blur event. r=automatedtester
authorAndreas Tolfsen <ato@sny.no>
Sun, 31 Dec 2017 14:36:03 +0000
changeset 453273 4cdb2c2eb4c4739b8d54843d30b09f11418da38e
parent 453272 4bf05eb6e9b6ab20685a8edf625a3c946c409ee9
child 453274 9350c2e8e01f8ed1e3fb6f88e291264fa0f68bdb
push id1648
push usermtabara@mozilla.com
push dateThu, 01 Mar 2018 12:45:47 +0000
treeherdermozilla-release@cbb9688c2eeb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersautomatedtester
bugs1354211
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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);
 };