/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
/* import-globals-from file_ime_state_test_helper.js */
class IMEStateOnReadonlyChangeTester {
static #sTextControlTypes = [
{
description: "",
createElement: aDoc => aDoc.createElement("input"),
expectedIMEState: SpecialPowers.Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
},
{
description: ``,
createElement: aDoc => {
const input = aDoc.createElement("input");
input.setAttribute("type", "text");
return input;
},
expectedIMEState: SpecialPowers.Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
},
{
description: ``,
createElement: aDoc => {
const input = aDoc.createElement("input");
input.setAttribute("type", "password");
return input;
},
expectedIMEState: SpecialPowers.Ci.nsIDOMWindowUtils.IME_STATUS_PASSWORD,
},
{
description: ``,
createElement: aDoc => {
const input = aDoc.createElement("input");
input.setAttribute("type", "url");
return input;
},
expectedIMEState: SpecialPowers.Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
},
{
description: ``,
createElement: aDoc => {
const input = aDoc.createElement("input");
input.setAttribute("type", "email");
return input;
},
expectedIMEState: SpecialPowers.Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
},
{
description: ``,
createElement: aDoc => {
const input = aDoc.createElement("input");
input.setAttribute("type", "search");
return input;
},
expectedIMEState: SpecialPowers.Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
},
{
description: ``,
createElement: aDoc => {
const input = aDoc.createElement("input");
input.setAttribute("type", "tel");
return input;
},
expectedIMEState: SpecialPowers.Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
},
{
description: ``,
createElement: aDoc => {
const input = aDoc.createElement("input");
input.setAttribute("type", "number");
return input;
},
expectedIMEState: SpecialPowers.Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
},
{
description: ``,
createElement: aDoc => aDoc.createElement("textarea"),
expectedIMEState: SpecialPowers.Ci.nsIDOMWindowUtils.IME_STATUS_ENABLED,
},
];
static get numberOfTextControlTypes() {
return IMEStateOnReadonlyChangeTester.#sTextControlTypes.length;
}
// Only runner fields
#mTextControl;
#mTextControlElement;
#mWindow;
// Only checker fields
#mWindowUtils;
#mTIPWrapper;
clear() {
this.#mTextControlElement?.remove();
this.#mTIPWrapper?.clearFocusBlurNotifications();
this.#mTIPWrapper = null;
}
#flushPendingIMENotifications() {
return new Promise(resolve =>
this.#mWindow.requestAnimationFrame(() =>
this.#mWindow.requestAnimationFrame(resolve)
)
);
}
/**
* @param {number} aIndex The index of text control types.
* @param {Window} aWindow The window running tests.
* @param {Element} aContainer The element which should have new or