backout aba885aafee0210b1f063a423b1c0b3ce28d15f7 for intermittent bug 1272834

MozReview-Commit-ID: BTJ13wWojaI
This commit is contained in:
Joel Maher 2016-12-14 10:59:43 -05:00
Родитель 4175c1315d
Коммит 9f60f5a226
4 изменённых файлов: 21 добавлений и 126 удалений

Просмотреть файл

@ -64,19 +64,13 @@ const PAGECONTENT_TRANSLATED =
"</iframe>" + "</iframe>" +
"</div></body></html>"; "</div></body></html>";
function openSelectPopup(selectPopup, mode = "key", selector = "select", win = window) function openSelectPopup(selectPopup, withMouse, selector = "select", win = window)
{ {
let popupShownPromise = BrowserTestUtils.waitForEvent(selectPopup, "popupshown"); let popupShownPromise = BrowserTestUtils.waitForEvent(selectPopup, "popupshown");
if (mode == "click" || mode == "mousedown") { if (withMouse) {
let mousePromise; return Promise.all([popupShownPromise,
if (mode == "click") { BrowserTestUtils.synthesizeMouseAtCenter(selector, { }, win.gBrowser.selectedBrowser)]);
mousePromise = BrowserTestUtils.synthesizeMouseAtCenter(selector, { }, win.gBrowser.selectedBrowser);
} else {
mousePromise = BrowserTestUtils.synthesizeMouse(selector, 5, 5, { type: "mousedown" }, win.gBrowser.selectedBrowser);
}
return Promise.all([popupShownPromise, mousePromise]);
} }
EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true, code: "ArrowDown" }, win); EventUtils.synthesizeKey("KEY_ArrowDown", { altKey: true, code: "ArrowDown" }, win);
@ -179,7 +173,7 @@ function* doSelectTests(contentType, dtd)
is((yield getChangeEvents()), 1, "After closed - number of change events"); is((yield getChangeEvents()), 1, "After closed - number of change events");
// Opening and closing the popup without changing the value should not fire a change event. // Opening and closing the popup without changing the value should not fire a change event.
yield openSelectPopup(selectPopup, "click"); yield openSelectPopup(selectPopup, true);
yield hideSelectPopup(selectPopup, "escape"); yield hideSelectPopup(selectPopup, "escape");
is((yield getInputEvents()), 1, "Open and close with no change - number of input events"); is((yield getInputEvents()), 1, "Open and close with no change - number of input events");
is((yield getChangeEvents()), 1, "Open and close with no change - number of change events"); is((yield getChangeEvents()), 1, "Open and close with no change - number of change events");
@ -188,7 +182,7 @@ function* doSelectTests(contentType, dtd)
is((yield getInputEvents()), 1, "Tab away from select with no change - number of input events"); is((yield getInputEvents()), 1, "Tab away from select with no change - number of input events");
is((yield getChangeEvents()), 1, "Tab away from select with no change - number of change events"); is((yield getChangeEvents()), 1, "Tab away from select with no change - number of change events");
yield openSelectPopup(selectPopup, "click"); yield openSelectPopup(selectPopup, true);
EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" }); EventUtils.synthesizeKey("KEY_ArrowDown", { code: "ArrowDown" });
yield hideSelectPopup(selectPopup, "escape"); yield hideSelectPopup(selectPopup, "escape");
is((yield getInputEvents()), isWindows ? 2 : 1, "Open and close with change - number of input events"); is((yield getInputEvents()), isWindows ? 2 : 1, "Open and close with change - number of input events");
@ -222,7 +216,7 @@ add_task(function*() {
let selectPopup = menulist.menupopup; let selectPopup = menulist.menupopup;
// First, try it when a different <select> element than the one that is open is removed // First, try it when a different <select> element than the one that is open is removed
yield openSelectPopup(selectPopup, "click", "#one"); yield openSelectPopup(selectPopup, true, "#one");
yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function() { yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
content.document.body.removeChild(content.document.getElementById("two")); content.document.body.removeChild(content.document.getElementById("two"));
@ -236,7 +230,7 @@ add_task(function*() {
yield hideSelectPopup(selectPopup); yield hideSelectPopup(selectPopup);
// Next, try it when the same <select> element than the one that is open is removed // Next, try it when the same <select> element than the one that is open is removed
yield openSelectPopup(selectPopup, "click", "#three"); yield openSelectPopup(selectPopup, true, "#three");
let popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden"); let popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden");
yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function() { yield ContentTask.spawn(gBrowser.selectedBrowser, {}, function() {
@ -247,7 +241,7 @@ add_task(function*() {
ok(true, "Popup hidden when select is removed"); ok(true, "Popup hidden when select is removed");
// Finally, try it when the tab is closed while the select popup is open. // Finally, try it when the tab is closed while the select popup is open.
yield openSelectPopup(selectPopup, "click", "#one"); yield openSelectPopup(selectPopup, true, "#one");
popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden"); popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden");
yield BrowserTestUtils.removeTab(tab); yield BrowserTestUtils.removeTab(tab);
@ -265,7 +259,7 @@ add_task(function*() {
let selectPopup = menulist.menupopup; let selectPopup = menulist.menupopup;
// First, get the position of the select popup when no translations have been applied. // First, get the position of the select popup when no translations have been applied.
yield openSelectPopup(selectPopup); yield openSelectPopup(selectPopup, false);
let rect = selectPopup.getBoundingClientRect(); let rect = selectPopup.getBoundingClientRect();
let expectedX = rect.left; let expectedX = rect.left;
@ -306,7 +300,7 @@ add_task(function*() {
}); });
}); });
yield openSelectPopup(selectPopup); yield openSelectPopup(selectPopup, false);
expectedX += step[2]; expectedX += step[2];
expectedY += step[3]; expectedY += step[3];
@ -377,7 +371,7 @@ add_task(function* test_event_order() {
for (let mode of ["enter", "click"]) { for (let mode of ["enter", "click"]) {
let expected = mode == "enter" ? expectedEnter : expectedClick; let expected = mode == "enter" ? expectedEnter : expectedClick;
yield openSelectPopup(selectPopup, "click", mode == "enter" ? "#one" : "#two"); yield openSelectPopup(selectPopup, true, mode == "enter" ? "#one" : "#two");
let eventsPromise = ContentTask.spawn(browser, [mode, expected], function*([contentMode, contentExpected]) { let eventsPromise = ContentTask.spawn(browser, [mode, expected], function*([contentMode, contentExpected]) {
return new Promise((resolve) => { return new Promise((resolve) => {
@ -430,38 +424,6 @@ function* performLargePopupTests(win)
let selectPopup = win.document.getElementById("ContentSelectDropdown").menupopup; let selectPopup = win.document.getElementById("ContentSelectDropdown").menupopup;
let browserRect = browser.getBoundingClientRect(); let browserRect = browser.getBoundingClientRect();
// Check if a drag-select works and scrolls the list.
yield openSelectPopup(selectPopup, "mousedown", "select", win);
let scrollPos = selectPopup.scrollBox.scrollTop;
let popupRect = selectPopup.getBoundingClientRect();
// First, check that scrolling does not occur when the mouse is moved over the
// anchor button but not the popup yet.
EventUtils.synthesizeMouseAtPoint(popupRect.left + 5, popupRect.top - 10, { type: "mousemove" }, win);
is(selectPopup.scrollBox.scrollTop, scrollPos, "scroll position after mousemove over button");
EventUtils.synthesizeMouseAtPoint(popupRect.left + 20, popupRect.top + 10, { type: "mousemove" }, win);
// Dragging above the popup scrolls it up.
EventUtils.synthesizeMouseAtPoint(popupRect.left + 20, popupRect.top - 20, { type: "mousemove" }, win);
ok(selectPopup.scrollBox.scrollTop < scrollPos - 5, "scroll position at drag up");
// Dragging below the popup scrolls it down.
scrollPos = selectPopup.scrollBox.scrollTop;
EventUtils.synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 20, { type: "mousemove" }, win);
ok(selectPopup.scrollBox.scrollTop > scrollPos + 5, "scroll position at drag down");
// Releasing the mouse button and moving the mouse does not change the scroll position.
scrollPos = selectPopup.scrollBox.scrollTop;
EventUtils.synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 25, { type: "mouseup" }, win);
is(selectPopup.scrollBox.scrollTop, scrollPos, "scroll position at mouseup");
EventUtils.synthesizeMouseAtPoint(popupRect.left + 20, popupRect.bottom + 20, { type: "mousemove" }, win);
is(selectPopup.scrollBox.scrollTop, scrollPos, "scroll position at mouseup again");
yield hideSelectPopup(selectPopup, "escape", win);
let positions = [ let positions = [
"margin-top: 300px;", "margin-top: 300px;",
"position: fixed; bottom: 100px;", "position: fixed; bottom: 100px;",
@ -469,8 +431,8 @@ function* performLargePopupTests(win)
]; ];
let position; let position;
while (positions.length) { while (true) {
yield openSelectPopup(selectPopup, "key", "select", win); yield openSelectPopup(selectPopup, false, "select", win);
let rect = selectPopup.getBoundingClientRect(); let rect = selectPopup.getBoundingClientRect();
ok(rect.top >= browserRect.top, "Popup top position in within browser area"); ok(rect.top >= browserRect.top, "Popup top position in within browser area");
@ -489,11 +451,14 @@ function* performLargePopupTests(win)
yield hideSelectPopup(selectPopup, "enter", win); yield hideSelectPopup(selectPopup, "enter", win);
position = positions.shift(); position = positions.shift();
if (!position) {
break;
}
let contentPainted = BrowserTestUtils.contentPainted(browser); let contentPainted = BrowserTestUtils.contentPainted(browser);
yield ContentTask.spawn(browser, position, function*(contentPosition) { yield ContentTask.spawn(browser, position, function*(contentPosition) {
let select = content.document.getElementById("one"); let select = content.document.getElementById("one");
select.setAttribute("style", contentPosition || ""); select.setAttribute("style", contentPosition);
}); });
yield contentPainted; yield contentPainted;
} }
@ -554,7 +519,7 @@ add_task(function* test_mousemove_correcttarget() {
// The popup should be closed when fullscreen mode is entered or exited. // The popup should be closed when fullscreen mode is entered or exited.
for (let steps = 0; steps < 2; steps++) { for (let steps = 0; steps < 2; steps++) {
yield openSelectPopup(selectPopup, "click"); yield openSelectPopup(selectPopup, true);
let popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden"); let popupHiddenPromise = BrowserTestUtils.waitForEvent(selectPopup, "popuphidden");
let sizeModeChanged = BrowserTestUtils.waitForEvent(window, "sizemodechange"); let sizeModeChanged = BrowserTestUtils.waitForEvent(window, "sizemodechange");
BrowserFullScreen(); BrowserFullScreen();

Просмотреть файл

@ -246,12 +246,6 @@
</xul:arrowscrollbox> </xul:arrowscrollbox>
</content> </content>
<implementation>
<field name="scrollBox" readonly="true">
document.getAnonymousElementByAttribute(this, "class", "popup-internal-box");
</field>
</implementation>
<handlers> <handlers>
<handler event="popupshowing" phase="target"> <handler event="popupshowing" phase="target">
<![CDATA[ <![CDATA[
@ -632,9 +626,9 @@
<binding id="popup-scrollbars" extends="chrome://global/content/bindings/popup.xml#popup"> <binding id="popup-scrollbars" extends="chrome://global/content/bindings/popup.xml#popup">
<content> <content>
<xul:scrollbox class="popup-internal-box" flex="1" orient="vertical" style="overflow: auto;"> <xul:hbox class="popup-internal-box" flex="1" orient="vertical" style="overflow: auto;">
<children/> <children/>
</xul:scrollbox> </xul:hbox>
</content> </content>
</binding> </binding>

Просмотреть файл

@ -21,15 +21,6 @@
<children/> <children/>
</xul:box> </xul:box>
</content> </content>
<implementation>
<method name="scrollByIndex">
<parameter name="index"/>
<body>
this.boxObject.scrollByIndex(index);
</body>
</method>
</implementation>
</binding> </binding>
<binding id="arrowscrollbox" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox-base"> <binding id="arrowscrollbox" extends="chrome://global/content/bindings/scrollbox.xml#scrollbox-base">

Просмотреть файл

@ -14,18 +14,12 @@ const {AppConstants} = Cu.import("resource://gre/modules/AppConstants.jsm");
// Maximum number of rows to display in the select dropdown. // Maximum number of rows to display in the select dropdown.
const MAX_ROWS = 20; const MAX_ROWS = 20;
// Interval between autoscrolls
const AUTOSCROLL_INTERVAL = 25;
var currentBrowser = null; var currentBrowser = null;
var currentMenulist = null; var currentMenulist = null;
var currentZoom = 1; var currentZoom = 1;
var closedWithEnter = false; var closedWithEnter = false;
this.SelectParentHelper = { this.SelectParentHelper = {
draggedOverPopup: false,
scrollTimer: 0,
populate: function(menulist, items, selectedIndex, zoom) { populate: function(menulist, items, selectedIndex, zoom) {
// Clear the current contents of the popup // Clear the current contents of the popup
menulist.menupopup.textContent = ""; menulist.menupopup.textContent = "";
@ -67,11 +61,6 @@ this.SelectParentHelper = {
constraintRect.width, constraintRect.height); constraintRect.width, constraintRect.height);
menupopup.setConstraintRect(constraintRect); menupopup.setConstraintRect(constraintRect);
menupopup.openPopupAtScreenRect(AppConstants.platform == "macosx" ? "selection" : "after_start", rect.left, rect.top, rect.width, rect.height, false, false); menupopup.openPopupAtScreenRect(AppConstants.platform == "macosx" ? "selection" : "after_start", rect.left, rect.top, rect.width, rect.height, false, false);
// Set up for dragging
menupopup.setCaptureAlways();
this.draggedOverPopup = false;
menupopup.addEventListener("mousemove", this);
}, },
hide: function(menulist, browser) { hide: function(menulist, browser) {
@ -80,19 +69,9 @@ this.SelectParentHelper = {
} }
}, },
clearScrollTimer: function() {
if (this.scrollTimer) {
let win = currentBrowser.ownerDocument.defaultView;
win.clearInterval(this.scrollTimer);
this.scrollTimer = 0;
}
},
handleEvent: function(event) { handleEvent: function(event) {
switch (event.type) { switch (event.type) {
case "mouseup": case "mouseup":
this.clearScrollTimer();
currentMenulist.menupopup.removeEventListener("mousemove", this);
currentBrowser.messageManager.sendAsyncMessage("Forms:MouseUp", {}); currentBrowser.messageManager.sendAsyncMessage("Forms:MouseUp", {});
break; break;
@ -104,38 +83,6 @@ this.SelectParentHelper = {
currentBrowser.messageManager.sendAsyncMessage("Forms:MouseOut", {}); currentBrowser.messageManager.sendAsyncMessage("Forms:MouseOut", {});
break; break;
case "mousemove":
let menupopup = currentMenulist.menupopup;
let popupRect = menupopup.getOuterScreenRect();
this.clearScrollTimer();
// If dragging outside the top or bottom edge of the popup, but within
// the popup area horizontally, scroll the list in that direction. The
// draggedOverPopup flag is used to ensure that scrolling does not start
// until the mouse has moved over the popup first, preventing scrolling
// while over the dropdown button.
if (event.screenX >= popupRect.left && event.screenX <= popupRect.right) {
if (!this.draggedOverPopup) {
if (event.screenY > popupRect.top && event.screenY < popupRect.bottom) {
this.draggedOverPopup = true;
}
}
if (this.draggedOverPopup &&
(event.screenY <= popupRect.top || event.screenY >= popupRect.bottom)) {
let scrollAmount = event.screenY <= popupRect.top ? -1 : 1;
menupopup.scrollBox.scrollByIndex(scrollAmount);
let win = currentBrowser.ownerDocument.defaultView;
this.scrollTimer = win.setInterval(function() {
menupopup.scrollBox.scrollByIndex(scrollAmount);
}, AUTOSCROLL_INTERVAL);
}
}
break;
case "keydown": case "keydown":
if (event.keyCode == event.DOM_VK_RETURN) { if (event.keyCode == event.DOM_VK_RETURN) {
closedWithEnter = true; closedWithEnter = true;
@ -161,8 +108,6 @@ this.SelectParentHelper = {
currentBrowser.messageManager.sendAsyncMessage("Forms:DismissedDropDown", {}); currentBrowser.messageManager.sendAsyncMessage("Forms:DismissedDropDown", {});
let popup = event.target; let popup = event.target;
this._unregisterListeners(currentBrowser, popup); this._unregisterListeners(currentBrowser, popup);
this.clearScrollTimer();
popup.releaseCapture();
popup.parentNode.hidden = true; popup.parentNode.hidden = true;
currentBrowser = null; currentBrowser = null;
currentMenulist = null; currentMenulist = null;