Bug 1472931 - Drop the autofocus feature of HTMLTooltip. r=birtles

This feature is no longer used. So this patch will remove this feature.

Differential Revision: https://phabricator.services.mozilla.com/D4052

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Mantaroh Yoshinaga 2018-08-27 01:35:55 +00:00
Родитель 69eb976056
Коммит 94698538d1
2 изменённых файлов: 6 добавлений и 64 удалений

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

@ -5,7 +5,7 @@
"use strict";
/**
* Test the HTMLTooltip autofocus configuration option.
* This is the sanity test for the HTMLTooltip focus
*/
const HTML_NS = "http://www.w3.org/1999/xhtml";
@ -30,17 +30,11 @@ add_task(async function() {
});
async function runTests(doc) {
await testNoAutoFocus(doc);
await testAutoFocus(doc);
await testAutoFocusPreservesFocusChange(doc);
}
async function testNoAutoFocus(doc) {
await focusNode(doc, "#box4-input");
ok(doc.activeElement.closest("#box4-input"), "Focus is in the #box4-input");
info("Test a tooltip without autofocus will not take focus");
const tooltip = await createTooltip(doc, false);
info("Test a tooltip will not take focus");
const tooltip = await createTooltip(doc);
await showTooltip(tooltip, doc.getElementById("box1"));
ok(doc.activeElement.closest("#box4-input"), "Focus is still in the #box4-input");
@ -51,50 +45,6 @@ async function testNoAutoFocus(doc) {
tooltip.destroy();
}
async function testAutoFocus(doc) {
await focusNode(doc, "#box4-input");
ok(doc.activeElement.closest("#box4-input"), "Focus is in the #box4-input");
info("Test autofocus tooltip takes focus when displayed, " +
"and restores the focus when hidden");
const tooltip = await createTooltip(doc, true);
await showTooltip(tooltip, doc.getElementById("box1"));
ok(doc.activeElement.closest(".tooltip-content"), "Focus is in the tooltip");
await hideTooltip(tooltip);
ok(doc.activeElement.closest("#box4-input"), "Focus is in the #box4-input");
info("Blur the textbox before moving to the next test to reset the state.");
await blurNode(doc, "#box4-input");
tooltip.destroy();
}
async function testAutoFocusPreservesFocusChange(doc) {
await focusNode(doc, "#box4-input");
ok(doc.activeElement.closest("#box4-input"), "Focus is still in the #box3-input");
info("Test autofocus tooltip takes focus when displayed, " +
"but does not try to restore the active element if it is not focused when hidden");
const tooltip = await createTooltip(doc, true);
await showTooltip(tooltip, doc.getElementById("box1"));
ok(doc.activeElement.closest(".tooltip-content"), "Focus is in the tooltip");
info("Move the focus to #box3-input while the tooltip is displayed");
await focusNode(doc, "#box3-input");
ok(doc.activeElement.closest("#box3-input"), "Focus moved to the #box3-input");
await hideTooltip(tooltip);
ok(doc.activeElement.closest("#box3-input"), "Focus is still in the #box3-input");
info("Blur the textbox before moving to the next test to reset the state.");
await blurNode(doc, "#box3-input");
tooltip.destroy();
}
/**
* Fpcus the node corresponding to the provided selector in the provided document. Returns
* a promise that will resolve when receiving the focus event on the node.
@ -118,16 +68,15 @@ function blurNode(doc, selector) {
}
/**
* Create an HTMLTooltip instance with the provided autofocus setting.
* Create an HTMLTooltip instance.
*
* @param {Document} doc
* Document in which the tooltip should be created
* @param {Boolean} autofocus
* @return {Promise} promise that will resolve the HTMLTooltip instance created when the
* tooltip content will be ready.
*/
function createTooltip(doc, autofocus) {
const tooltip = new HTMLTooltip(doc, {autofocus, useXulWrapper});
function createTooltip(doc) {
const tooltip = new HTMLTooltip(doc, {useXulWrapper});
const div = doc.createElementNS(HTML_NS, "div");
div.classList.add("tooltip-content");
div.style.height = "50px";

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

@ -294,8 +294,6 @@ const getRelativeRect = function(node, relativeTo) {
* - {String} type
* Display type of the tooltip. Possible values: "normal", "arrow", and
* "doorhanger".
* - {Boolean} autofocus
* Defaults to false. Should the tooltip be focused when opening it.
* - {Boolean} consumeOutsideClicks
* Defaults to true. The tooltip is closed when clicking outside.
* Should this event be stopped and consumed or not.
@ -307,7 +305,6 @@ function HTMLTooltip(toolboxDoc, {
id = "",
className = "",
type = "normal",
autofocus = false,
consumeOutsideClicks = true,
useXulWrapper = false,
} = {}) {
@ -317,7 +314,6 @@ function HTMLTooltip(toolboxDoc, {
this.id = id;
this.className = className;
this.type = type;
this.autofocus = autofocus;
this.consumeOutsideClicks = consumeOutsideClicks;
this.useXulWrapper = this._isXUL() && useXulWrapper;
this.preferredWidth = "auto";
@ -451,9 +447,6 @@ HTMLTooltip.prototype = {
this.doc.defaultView.clearTimeout(this.attachEventsTimer);
this.attachEventsTimer = this.doc.defaultView.setTimeout(() => {
if (this.autofocus) {
this.focus();
}
// Update the top window reference each time in case the host changes.
this.topWindow = this._getTopWindow();
this.topWindow.addEventListener("click", this._onClick, true);