зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1686361 - [marionette] Sync synthesizeMouseAtPoint from EventUtils.js. r=marionette-reviewers,whimboo
Currently the default value of buttons is set to MOUSE_BUTTONS_NOT_SPECIFIED, which defers calculation of the value to the DOMWindowUtils GetButtonsFlagForButton function. This calculates a default value based upon the value of the button key. By specifying a default button value of 0, which has a meaning of ePrimary, the buttons value is calculated as the ePrimaryFlag (1), suggesting that a button was pressed. This patch changes the behaviour to set the value of buttons based on the original value of button before the default was applied. The value of buttons also considers the event type to ensure that a mousedown event has a default value calculated by DOMWindowUtils. With the new behaviour: - if a value was explicitly set for buttons, this is used - if a value was explicitly set for button, then the not-specified constant is used to defer calculation to DOMWindowUtils - if an event type was specified and that event type was not the 'mousedown' event, then the no-button constant is used - if an event type was not specified or it was for the 'mousedown' event, then the not-specified constant is used to defer calculation to DOMWindowUtils Differential Revision: https://phabricator.services.mozilla.com/D105877
This commit is contained in:
Родитель
de7b30696a
Коммит
31039e0258
|
@ -178,11 +178,21 @@ event.synthesizeMouseAtPoint = function(left, top, opts, win) {
|
|||
} else {
|
||||
isWidgetEventSynthesized = false;
|
||||
}
|
||||
let buttons;
|
||||
if ("buttons" in opts) {
|
||||
buttons = opts.buttons;
|
||||
} else {
|
||||
buttons = domutils.MOUSE_BUTTONS_NOT_SPECIFIED;
|
||||
|
||||
function computeButtons(aEvent, utils) {
|
||||
if (typeof aEvent.buttons != "undefined") {
|
||||
return aEvent.buttons;
|
||||
}
|
||||
|
||||
if (typeof aEvent.button != "undefined") {
|
||||
return utils.MOUSE_BUTTONS_NOT_SPECIFIED;
|
||||
}
|
||||
|
||||
if (typeof aEvent.type != "undefined" && aEvent.type != "mousedown") {
|
||||
return utils.MOUSE_BUTTONS_NO_BUTTON;
|
||||
}
|
||||
|
||||
return utils.MOUSE_BUTTONS_NOT_SPECIFIED;
|
||||
}
|
||||
|
||||
if ("type" in opts && opts.type) {
|
||||
|
@ -198,7 +208,7 @@ event.synthesizeMouseAtPoint = function(left, top, opts, win) {
|
|||
inputSource,
|
||||
isDOMEventSynthesized,
|
||||
isWidgetEventSynthesized,
|
||||
buttons
|
||||
computeButtons(opts, domutils)
|
||||
);
|
||||
} else {
|
||||
domutils.sendMouseEvent(
|
||||
|
@ -213,7 +223,7 @@ event.synthesizeMouseAtPoint = function(left, top, opts, win) {
|
|||
inputSource,
|
||||
isDOMEventSynthesized,
|
||||
isWidgetEventSynthesized,
|
||||
buttons
|
||||
computeButtons(Object.assign({ type: "mousedown" }, opts), domutils)
|
||||
);
|
||||
domutils.sendMouseEvent(
|
||||
"mouseup",
|
||||
|
@ -227,7 +237,7 @@ event.synthesizeMouseAtPoint = function(left, top, opts, win) {
|
|||
inputSource,
|
||||
isDOMEventSynthesized,
|
||||
isWidgetEventSynthesized,
|
||||
buttons
|
||||
computeButtons(Object.assign({ type: "mouseup" }, opts), domutils)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -184,8 +184,6 @@ async function webdriverClickElement(el, a11y) {
|
|||
clickPoint.y,
|
||||
{
|
||||
type: "mousemove",
|
||||
// Remove buttons attribute with https://bugzilla.mozilla.org/show_bug.cgi?id=1686361
|
||||
buttons: 0,
|
||||
},
|
||||
win
|
||||
);
|
||||
|
|
Загрузка…
Ссылка в новой задаче