Backed out changeset 4a9483083a4d (bug 1686663) for causing bc failures in browser_selectpopup.js

CLOSED TREE
This commit is contained in:
Mihai Alexandru Michis 2021-01-18 23:05:11 +02:00
parent 25256faaa4
commit ba3afb97f1
3 changed files with 10 additions and 143 deletions

View File

@ -211,22 +211,6 @@ function computeButton(aEvent) {
return aEvent.type == "contextmenu" ? 2 : 0;
}
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;
}
function sendMouseEvent(aEvent, aTarget, aWindow) {
if (
![
@ -600,6 +584,8 @@ function synthesizeMouseAtPoint(left, top, aEvent, aWindow = window) {
"isWidgetEventSynthesized" in aEvent
? aEvent.isWidgetEventSynthesized
: false;
var buttons =
"buttons" in aEvent ? aEvent.buttons : utils.MOUSE_BUTTONS_NOT_SPECIFIED;
if ("type" in aEvent && aEvent.type) {
defaultPrevented = utils.sendMouseEvent(
aEvent.type,
@ -613,7 +599,7 @@ function synthesizeMouseAtPoint(left, top, aEvent, aWindow = window) {
inputSource,
isDOMEventSynthesized,
isWidgetEventSynthesized,
computeButtons(aEvent, utils),
buttons,
id
);
} else {
@ -629,7 +615,7 @@ function synthesizeMouseAtPoint(left, top, aEvent, aWindow = window) {
inputSource,
isDOMEventSynthesized,
isWidgetEventSynthesized,
computeButtons(Object.assign({ type: "mousedown" }, aEvent), utils),
buttons,
id
);
utils.sendMouseEvent(
@ -644,7 +630,7 @@ function synthesizeMouseAtPoint(left, top, aEvent, aWindow = window) {
inputSource,
isDOMEventSynthesized,
isWidgetEventSynthesized,
computeButtons(Object.assign({ type: "mouseup" }, aEvent), utils),
buttons,
id
);
}

View File

@ -81,124 +81,6 @@ add_task(async function() {
gBrowser.removeTab(tab);
});
add_task(async function testSynthesizeMouseAtPointsButtons() {
let onMouseEvt =
'document.getElementById("mouselog").textContent += "/" + [event.type,event.clientX,event.clientY,event.button,event.buttons].join(",");';
let getLastMouseEventDetails = browser => {
return SpecialPowers.spawn(browser, [], async () => {
let log = content.document.getElementById("mouselog").textContent;
content.document.getElementById("mouselog").textContent = "";
return log;
});
};
const url =
"<body" +
"' onmousedown='" +
onMouseEvt +
"' onmousemove='" +
onMouseEvt +
"' onmouseup='" +
onMouseEvt +
"' style='margin: 0'>" +
"<div style='margin: 0; width: 80px; height: 60px;'>Mouse area</div>" +
"<span id='mouselog'></span>" +
"</body>";
let tab = await BrowserTestUtils.openNewForegroundTab(
gBrowser,
"data:text/html," + url
);
let browser = tab.linkedBrowser;
let details;
await BrowserTestUtils.synthesizeMouseAtPoint(
21,
22,
{
type: "mousemove",
},
browser.browsingContext
);
details = await getLastMouseEventDetails(browser);
is(details, "/mousemove,21,22,0,0", "synthesizeMouseAtPoint mousemove");
await BrowserTestUtils.synthesizeMouseAtPoint(
22,
23,
{},
browser.browsingContext
);
details = await getLastMouseEventDetails(browser);
is(
details,
"/mousedown,22,23,0,1/mouseup,22,23,0,0",
"synthesizeMouseAtPoint default action includes buttons on mousedown only"
);
await BrowserTestUtils.synthesizeMouseAtPoint(
20,
22,
{
type: "mousedown",
},
browser.browsingContext
);
details = await getLastMouseEventDetails(browser);
is(
details,
"/mousedown,20,22,0,1",
"synthesizeMouseAtPoint mousedown includes buttons"
);
await BrowserTestUtils.synthesizeMouseAtPoint(
21,
20,
{
type: "mouseup",
},
browser.browsingContext
);
details = await getLastMouseEventDetails(browser);
is(details, "/mouseup,21,20,0,0", "synthesizeMouseAtPoint mouseup");
await BrowserTestUtils.synthesizeMouseAtPoint(
20,
22,
{
type: "mousedown",
button: 2,
},
browser.browsingContext
);
details = await getLastMouseEventDetails(browser);
is(
details,
"/mousedown,20,22,2,2",
"synthesizeMouseAtPoint mousedown respects specified button 2"
);
await BrowserTestUtils.synthesizeMouseAtPoint(
21,
20,
{
type: "mouseup",
button: 2,
},
browser.browsingContext
);
details = await getLastMouseEventDetails(browser);
is(
details,
"/mouseup,21,20,2,0",
"synthesizeMouseAtPoint mouseup with button 2"
);
gBrowser.removeTab(tab);
});
add_task(async function mouse_in_iframe() {
let onClickEvt = "document.body.lastChild.textContent = event.target.id;";
const url = `<iframe style='margin: 30px;' src='data:text/html,<body onclick="${onClickEvt}">

View File

@ -273,12 +273,11 @@ async function dragScroll()
is(getScrollPos(), scrollPos, "scroll position after mousemove over button should not change");
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.top + 10, { type: "mousemove" });
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.top + 10, { type: "mousedown", buttons: 1 });
// Dragging above the popup scrolls it up.
let scrolledPromise = waitForEvent(popup, "scroll", false,
() => getScrollPos() < scrollPos - 5);
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.top - 20, { type: "mousemove", buttons: 1 });
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.top - 20, { type: "mousemove" });
await scrolledPromise;
ok(true, "scroll position at drag up");
@ -286,7 +285,7 @@ async function dragScroll()
scrollPos = getScrollPos();
scrolledPromise = waitForEvent(popup, "scroll", false,
() => getScrollPos() > scrollPos + 5);
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 20, { type: "mousemove", buttons: 1 });
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 20, { type: "mousemove" });
await scrolledPromise;
ok(true, "scroll position at drag down");
@ -302,12 +301,12 @@ async function dragScroll()
// visible, as the asynchronous scrolling may have moved it out of view.
popup.childNodes[4].scrollIntoView({ block: "nearest", behavior: "instant" });
let menuRect = popup.childNodes[4].getBoundingClientRect();
synthesizeMouseAtPoint(menuRect.left + 5, menuRect.top + 5, { type: "mousedown", buttons: 1 });
synthesizeMouseAtPoint(menuRect.left + 5, menuRect.top + 5, { type: "mousedown" });
// Dragging below the popup scrolls it down.
scrolledPromise = waitForEvent(popup, "scroll", false,
() => getScrollPos() > scrollPos + 5);
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 20, { type: "mousemove", buttons: 1 });
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 20, { type: "mousemove" });
await scrolledPromise;
ok(true, "scroll position at drag down from item");
@ -315,7 +314,7 @@ async function dragScroll()
scrollPos = getScrollPos();
scrolledPromise = waitForEvent(popup, "scroll", false,
() => getScrollPos() < scrollPos - 5);
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.top - 20, { type: "mousemove", buttons: 1 });
synthesizeMouseAtPoint(popupRect.left + 20, popupRect.top - 20, { type: "mousemove" });
await scrolledPromise;
ok(true, "scroll position at drag up from item");