зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1255955 - Add function to dispatch events to event library; r=automatedtester
MozReview-Commit-ID: GBvXy8svoY2 --HG-- extra : rebase_source : a0d4db22becb70f8097198d300bff6f198e9ede4
This commit is contained in:
Родитель
55a23f732e
Коммит
11e8e8c6c2
|
@ -1279,3 +1279,18 @@ event.sendKeysToElement = function(
|
|||
throw new ElementNotVisibleError("Element is not visible");
|
||||
}
|
||||
};
|
||||
|
||||
event.sendEvent = function(eventType, el, modifiers = {}, opts = {}) {
|
||||
opts.canBubble = opts.canBubble || true;
|
||||
|
||||
let doc = el.ownerDocument || el.document;
|
||||
let ev = doc.createEvent("Event");
|
||||
|
||||
ev.shiftKey = modifiers["shift"];
|
||||
ev.metaKey = modifiers["meta"];
|
||||
ev.altKey = modifiers["alt"];
|
||||
ev.ctrlKey = modifiers["ctrl"];
|
||||
|
||||
ev.initEvent(eventType, opts.canBubble, true);
|
||||
el.dispatchEvent(ev);
|
||||
};
|
||||
|
|
Загрузка…
Ссылка в новой задаче