mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1814289 - Enable the jsdoc lint rule for translations and run auto-fix; r=translations-reviewers,nordzilla
There will be lint errors reported, as the following patch will manually fix the remaining errors. Differential Revision: https://phabricator.services.mozilla.com/D204516
This commit is contained in:
parent
ae5f491626
commit
5dd28ecc35
@ -597,7 +597,6 @@ module.exports = {
|
|||||||
"toolkit/components/thumbnails/**",
|
"toolkit/components/thumbnails/**",
|
||||||
"toolkit/components/timermanager/UpdateTimerManager.*",
|
"toolkit/components/timermanager/UpdateTimerManager.*",
|
||||||
"toolkit/components/translation/LanguageDetector.*",
|
"toolkit/components/translation/LanguageDetector.*",
|
||||||
"toolkit/components/translations/**",
|
|
||||||
"toolkit/components/url-classifier/**",
|
"toolkit/components/url-classifier/**",
|
||||||
"toolkit/components/utils/**",
|
"toolkit/components/utils/**",
|
||||||
"toolkit/components/viewsource/**",
|
"toolkit/components/viewsource/**",
|
||||||
|
@ -41,6 +41,7 @@ export class TranslationsTelemetry {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Telemetry functions for the Translations panel.
|
* Telemetry functions for the Translations panel.
|
||||||
|
*
|
||||||
* @returns {Panel}
|
* @returns {Panel}
|
||||||
*/
|
*/
|
||||||
static panel() {
|
static panel() {
|
||||||
@ -49,6 +50,7 @@ export class TranslationsTelemetry {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Forces the creation of a new Translations telemetry flowId and returns it.
|
* Forces the creation of a new Translations telemetry flowId and returns it.
|
||||||
|
*
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
static createFlowId() {
|
static createFlowId() {
|
||||||
@ -60,6 +62,7 @@ export class TranslationsTelemetry {
|
|||||||
/**
|
/**
|
||||||
* Returns a Translations telemetry flowId by retrieving the cached value
|
* Returns a Translations telemetry flowId by retrieving the cached value
|
||||||
* if available, or creating a new one otherwise.
|
* if available, or creating a new one otherwise.
|
||||||
|
*
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
static getOrCreateFlowId() {
|
static getOrCreateFlowId() {
|
||||||
|
@ -183,6 +183,7 @@ export class AboutTranslationsChild extends JSWindowActorChild {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Does this device support the translation engine?
|
* Does this device support the translation engine?
|
||||||
|
*
|
||||||
* @returns {Promise<boolean>}
|
* @returns {Promise<boolean>}
|
||||||
*/
|
*/
|
||||||
AT_isTranslationEngineSupported() {
|
AT_isTranslationEngineSupported() {
|
||||||
|
@ -24,6 +24,7 @@ export class TranslationsChild extends JSWindowActorChild {
|
|||||||
/**
|
/**
|
||||||
* This cache is shared across TranslationsChild instances. This means
|
* This cache is shared across TranslationsChild instances. This means
|
||||||
* that it will be shared across multiple page loads in the same origin.
|
* that it will be shared across multiple page loads in the same origin.
|
||||||
|
*
|
||||||
* @type {LRUCache | null}
|
* @type {LRUCache | null}
|
||||||
*/
|
*/
|
||||||
static #translationsCache = null;
|
static #translationsCache = null;
|
||||||
|
@ -19,6 +19,7 @@ export class TranslationsEngineChild extends JSWindowActorChild {
|
|||||||
/**
|
/**
|
||||||
* The resolve function for the Promise returned by the
|
* The resolve function for the Promise returned by the
|
||||||
* "TranslationsEngine:ForceShutdown" message.
|
* "TranslationsEngine:ForceShutdown" message.
|
||||||
|
*
|
||||||
* @type {null | () => {}}
|
* @type {null | () => {}}
|
||||||
*/
|
*/
|
||||||
#resolveForceShutdown = null;
|
#resolveForceShutdown = null;
|
||||||
@ -130,7 +131,7 @@ export class TranslationsEngineChild extends JSWindowActorChild {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} options
|
* @param {object} options
|
||||||
* @param {number?} options.startTime
|
* @param {number?} options.startTime
|
||||||
* @param {string} options.message
|
* @param {string} options.message
|
||||||
*/
|
*/
|
||||||
|
@ -142,11 +142,11 @@ const VERIFY_SIGNATURES_FROM_FS = false;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} TranslationPair
|
* @typedef {object} TranslationPair
|
||||||
* @prop {string} fromLanguage
|
* @property {string} fromLanguage
|
||||||
* @prop {string} toLanguage
|
* @property {string} toLanguage
|
||||||
* @prop {string} [fromDisplayLanguage]
|
* @property {string} [fromDisplayLanguage]
|
||||||
* @prop {string} [toDisplayLanguage]
|
* @property {string} [toDisplayLanguage]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -332,6 +332,7 @@ export class TranslationsParent extends JSWindowActorParent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Telemetry functions for Translations
|
* Telemetry functions for Translations
|
||||||
|
*
|
||||||
* @returns {TranslationsTelemetry}
|
* @returns {TranslationsTelemetry}
|
||||||
*/
|
*/
|
||||||
static telemetry() {
|
static telemetry() {
|
||||||
@ -351,6 +352,7 @@ export class TranslationsParent extends JSWindowActorParent {
|
|||||||
/**
|
/**
|
||||||
* Offer translations (for instance by automatically opening the popup panel) whenever
|
* Offer translations (for instance by automatically opening the popup panel) whenever
|
||||||
* languages are detected, but only do it once per host per session.
|
* languages are detected, but only do it once per host per session.
|
||||||
|
*
|
||||||
* @param {LangTags} detectedLanguages
|
* @param {LangTags} detectedLanguages
|
||||||
*/
|
*/
|
||||||
maybeOfferTranslations(detectedLanguages) {
|
maybeOfferTranslations(detectedLanguages) {
|
||||||
@ -553,6 +555,7 @@ export class TranslationsParent extends JSWindowActorParent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Provide a way for tests to override the system locales.
|
* Provide a way for tests to override the system locales.
|
||||||
|
*
|
||||||
* @type {null | string[]}
|
* @type {null | string[]}
|
||||||
*/
|
*/
|
||||||
static mockedSystemLocales = null;
|
static mockedSystemLocales = null;
|
||||||
@ -848,6 +851,7 @@ export class TranslationsParent extends JSWindowActorParent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The cached language pairs.
|
* The cached language pairs.
|
||||||
|
*
|
||||||
* @type {Promise<Array<LanguagePair>> | null}
|
* @type {Promise<Array<LanguagePair>> | null}
|
||||||
*/
|
*/
|
||||||
static #languagePairs = null;
|
static #languagePairs = null;
|
||||||
@ -937,7 +941,7 @@ export class TranslationsParent extends JSWindowActorParent {
|
|||||||
/**
|
/**
|
||||||
* Create a unique list of languages, sorted by the display name.
|
* Create a unique list of languages, sorted by the display name.
|
||||||
*
|
*
|
||||||
* @param {Object} supportedLanguages
|
* @param {object} supportedLanguages
|
||||||
* @returns {Array<{ langTag: string, displayName: string}}
|
* @returns {Array<{ langTag: string, displayName: string}}
|
||||||
*/
|
*/
|
||||||
static getLanguageList(supportedLanguages) {
|
static getLanguageList(supportedLanguages) {
|
||||||
@ -966,8 +970,8 @@ export class TranslationsParent extends JSWindowActorParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Object} event
|
* @param {object} event
|
||||||
* @param {Object} event.data
|
* @param {object} event.data
|
||||||
* @param {TranslationModelRecord[]} event.data.created
|
* @param {TranslationModelRecord[]} event.data.created
|
||||||
* @param {TranslationModelRecord[]} event.data.updated
|
* @param {TranslationModelRecord[]} event.data.updated
|
||||||
* @param {TranslationModelRecord[]} event.data.deleted
|
* @param {TranslationModelRecord[]} event.data.deleted
|
||||||
@ -1043,8 +1047,8 @@ export class TranslationsParent extends JSWindowActorParent {
|
|||||||
* then only the 1.1-version record will be returned in the resulting collection.
|
* then only the 1.1-version record will be returned in the resulting collection.
|
||||||
*
|
*
|
||||||
* @param {RemoteSettingsClient} remoteSettingsClient
|
* @param {RemoteSettingsClient} remoteSettingsClient
|
||||||
* @param {Object} [options]
|
* @param {object} [options]
|
||||||
* @param {Object} [options.filters={}]
|
* @param {object} [options.filters={}]
|
||||||
* The filters to apply when retrieving the records from RemoteSettings.
|
* The filters to apply when retrieving the records from RemoteSettings.
|
||||||
* Filters should correspond to properties on the RemoteSettings records themselves.
|
* Filters should correspond to properties on the RemoteSettings records themselves.
|
||||||
* For example, A filter to retrieve only records with a `fromLang` value of "en" and a `toLang` value of "es":
|
* For example, A filter to retrieve only records with a `fromLang` value of "en" and a `toLang` value of "es":
|
||||||
@ -1503,6 +1507,7 @@ export class TranslationsParent extends JSWindowActorParent {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete all language model files.
|
* Delete all language model files.
|
||||||
|
*
|
||||||
* @returns {Promise<string[]>} A list of record IDs.
|
* @returns {Promise<string[]>} A list of record IDs.
|
||||||
*/
|
*/
|
||||||
static async deleteAllLanguageFiles() {
|
static async deleteAllLanguageFiles() {
|
||||||
@ -1860,6 +1865,7 @@ export class TranslationsParent extends JSWindowActorParent {
|
|||||||
/**
|
/**
|
||||||
* Report an error. Having this as a method allows tests to check that an error
|
* Report an error. Having this as a method allows tests to check that an error
|
||||||
* was properly reported.
|
* was properly reported.
|
||||||
|
*
|
||||||
* @param {Error} error - Providing an Error object makes sure the stack is properly
|
* @param {Error} error - Providing an Error object makes sure the stack is properly
|
||||||
* reported.
|
* reported.
|
||||||
* @param {any[]} args - Any args to pass on to console.error.
|
* @param {any[]} args - Any args to pass on to console.error.
|
||||||
@ -2740,11 +2746,11 @@ class TranslationsLanguageState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} QueueItem
|
* @typedef {object} QueueItem
|
||||||
* @prop {Function} download
|
* @property {Function} download
|
||||||
* @prop {Function} [onSuccess]
|
* @property {Function} [onSuccess]
|
||||||
* @prop {Function} [onFailure]
|
* @property {Function} [onFailure]
|
||||||
* @prop {number} [retriesLeft]
|
* @property {number} [retriesLeft]
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -254,7 +254,7 @@ export class TranslationsDocument {
|
|||||||
/**
|
/**
|
||||||
* The BCP 47 language tag that is used on the page.
|
* The BCP 47 language tag that is used on the page.
|
||||||
*
|
*
|
||||||
* @type {string} */
|
@type {string} */
|
||||||
documentLanguage;
|
documentLanguage;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -475,8 +475,9 @@ export class TranslationsDocument {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue a node for translation of attributes.
|
* Queue a node for translation of attributes.
|
||||||
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node
|
||||||
* @param {Array<String>}
|
* @param {Array<string>}
|
||||||
*/
|
*/
|
||||||
queueAttributeNodeForTranslation(node, attributeList) {
|
queueAttributeNodeForTranslation(node, attributeList) {
|
||||||
/** @type {NodeVisibility} */
|
/** @type {NodeVisibility} */
|
||||||
@ -522,6 +523,7 @@ export class TranslationsDocument {
|
|||||||
/**
|
/**
|
||||||
* Helper function for adding a new root to the mutation
|
* Helper function for adding a new root to the mutation
|
||||||
* observer.
|
* observer.
|
||||||
|
*
|
||||||
* @param {Node} root
|
* @param {Node} root
|
||||||
*/
|
*/
|
||||||
observeNewRoot(root) {
|
observeNewRoot(root) {
|
||||||
@ -689,6 +691,7 @@ export class TranslationsDocument {
|
|||||||
* Get all the nodes which have selected attributes
|
* Get all the nodes which have selected attributes
|
||||||
* from the node/document and queue them.
|
* from the node/document and queue them.
|
||||||
* Call the translate function on these nodes
|
* Call the translate function on these nodes
|
||||||
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node
|
||||||
* @returns {Array<Promise<void>> | null}
|
* @returns {Array<Promise<void>> | null}
|
||||||
*/
|
*/
|
||||||
@ -773,7 +776,7 @@ export class TranslationsDocument {
|
|||||||
* Runs `determineTranslationStatus`, but only on unprocessed nodes.
|
* Runs `determineTranslationStatus`, but only on unprocessed nodes.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node
|
||||||
* @return {number} - One of the NodeStatus values.
|
* @returns {number} - One of the NodeStatus values.
|
||||||
*/
|
*/
|
||||||
determineTranslationStatusForUnprocessedNodes = node => {
|
determineTranslationStatusForUnprocessedNodes = node => {
|
||||||
if (this.#processedNodes.has(node)) {
|
if (this.#processedNodes.has(node)) {
|
||||||
@ -840,6 +843,7 @@ export class TranslationsDocument {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Queue a node for translation.
|
* Queue a node for translation.
|
||||||
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node
|
||||||
*/
|
*/
|
||||||
queueNodeForTranslation(node) {
|
queueNodeForTranslation(node) {
|
||||||
@ -856,6 +860,7 @@ export class TranslationsDocument {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit the translations giving priority to nodes in the viewport.
|
* Submit the translations giving priority to nodes in the viewport.
|
||||||
|
*
|
||||||
* @returns {Array<Promise<void>> | null}
|
* @returns {Array<Promise<void>> | null}
|
||||||
*/
|
*/
|
||||||
dispatchQueuedTranslations() {
|
dispatchQueuedTranslations() {
|
||||||
@ -905,6 +910,7 @@ export class TranslationsDocument {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Submit the Attribute translations giving priority to nodes in the viewport.
|
* Submit the Attribute translations giving priority to nodes in the viewport.
|
||||||
|
*
|
||||||
* @returns {Array<Promise<void>> | null}
|
* @returns {Array<Promise<void>> | null}
|
||||||
*/
|
*/
|
||||||
dispatchQueuedAttributeTranslations() {
|
dispatchQueuedAttributeTranslations() {
|
||||||
@ -1124,9 +1130,10 @@ export class TranslationsDocument {
|
|||||||
/**
|
/**
|
||||||
* A single function to update pendingTranslationsCount while
|
* A single function to update pendingTranslationsCount while
|
||||||
* calling the translate function
|
* calling the translate function
|
||||||
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node
|
||||||
* @param {string} text
|
* @param {string} text
|
||||||
* @prop {boolean} isHTML
|
* @property {boolean} isHTML
|
||||||
* @returns {Promise<string | null>}
|
* @returns {Promise<string | null>}
|
||||||
*/
|
*/
|
||||||
async maybeTranslate(node, text, isHTML) {
|
async maybeTranslate(node, text, isHTML) {
|
||||||
@ -1223,6 +1230,7 @@ export class TranslationsDocument {
|
|||||||
/**
|
/**
|
||||||
* Stop the mutations so that the updates of the translations
|
* Stop the mutations so that the updates of the translations
|
||||||
* in the nodes won't trigger observations.
|
* in the nodes won't trigger observations.
|
||||||
|
*
|
||||||
* @param {Function} run The function to update translations
|
* @param {Function} run The function to update translations
|
||||||
*/
|
*/
|
||||||
pauseMutationObserverAndRun(run) {
|
pauseMutationObserverAndRun(run) {
|
||||||
@ -1286,6 +1294,7 @@ export class TranslationsDocument {
|
|||||||
/**
|
/**
|
||||||
* Get the list of attributes that need to be translated
|
* Get the list of attributes that need to be translated
|
||||||
* in a given node.
|
* in a given node.
|
||||||
|
*
|
||||||
* @returns Array<string>
|
* @returns Array<string>
|
||||||
*/
|
*/
|
||||||
function getTranslatableAttributes(node) {
|
function getTranslatableAttributes(node) {
|
||||||
@ -1342,7 +1351,7 @@ function langTagsMatch(knownLanguage, otherLanguage) {
|
|||||||
* style of node.
|
* style of node.
|
||||||
*
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node
|
||||||
* @returns {HTMLElement} */
|
@returns {HTMLElement} */
|
||||||
function getElementForStyle(node) {
|
function getElementForStyle(node) {
|
||||||
if (node.nodeType != Node.TEXT_NODE) {
|
if (node.nodeType != Node.TEXT_NODE) {
|
||||||
return node;
|
return node;
|
||||||
@ -1424,6 +1433,7 @@ function updateElement(translationsDocument, element) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* The Set of translation IDs for nodes that have been cloned.
|
* The Set of translation IDs for nodes that have been cloned.
|
||||||
|
*
|
||||||
* @type {Set<number>}
|
* @type {Set<number>}
|
||||||
*/
|
*/
|
||||||
const clonedNodes = new Set();
|
const clonedNodes = new Set();
|
||||||
@ -1649,6 +1659,7 @@ function removeTextNodes(node) {
|
|||||||
* - `<p>test</p>`: yes
|
* - `<p>test</p>`: yes
|
||||||
* - `<p> </p>`: no
|
* - `<p> </p>`: no
|
||||||
* - `<p><b>test</b></p>`: no
|
* - `<p><b>test</b></p>`: no
|
||||||
|
*
|
||||||
* @param {Node} node
|
* @param {Node} node
|
||||||
* @returns {boolean}
|
* @returns {boolean}
|
||||||
*/
|
*/
|
||||||
@ -1795,12 +1806,12 @@ function* getAncestorsIterator(node) {
|
|||||||
/**
|
/**
|
||||||
* This contains all of the information needed to perform a translation request.
|
* This contains all of the information needed to perform a translation request.
|
||||||
*
|
*
|
||||||
* @typedef {Object} TranslationRequest
|
* @typedef {object} TranslationRequest
|
||||||
* @prop {Node} node
|
* @property {Node} node
|
||||||
* @prop {string} sourceText
|
* @property {string} sourceText
|
||||||
* @prop {boolean} isHTML
|
* @property {boolean} isHTML
|
||||||
* @prop {Function} resolve
|
* @property {Function} resolve
|
||||||
* @prop {Function} reject
|
* @property {Function} reject
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1827,6 +1838,7 @@ class QueuedTranslator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tie together a message id to a resolved response.
|
* Tie together a message id to a resolved response.
|
||||||
|
*
|
||||||
* @type {Map<number, TranslationRequest}
|
* @type {Map<number, TranslationRequest}
|
||||||
*/
|
*/
|
||||||
#requests = new Map();
|
#requests = new Map();
|
||||||
@ -1834,6 +1846,7 @@ class QueuedTranslator {
|
|||||||
/**
|
/**
|
||||||
* If the translations are paused, they are queued here. This Map is ordered by
|
* If the translations are paused, they are queued here. This Map is ordered by
|
||||||
* from oldest to newest requests with stale requests being removed.
|
* from oldest to newest requests with stale requests being removed.
|
||||||
|
*
|
||||||
* @type {Map<Node, TranslationRequest>}
|
* @type {Map<Node, TranslationRequest>}
|
||||||
*/
|
*/
|
||||||
#queue = new Map();
|
#queue = new Map();
|
||||||
@ -1902,6 +1915,7 @@ class QueuedTranslator {
|
|||||||
/**
|
/**
|
||||||
* Request a new port. The port will come in via `acquirePort`, and then resolved
|
* Request a new port. The port will come in via `acquirePort`, and then resolved
|
||||||
* through the `this.#portRequest.resolve`.
|
* through the `this.#portRequest.resolve`.
|
||||||
|
*
|
||||||
* @returns {Promise<void>}
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
#requestNewPort() {
|
#requestNewPort() {
|
||||||
@ -1997,7 +2011,7 @@ class QueuedTranslator {
|
|||||||
* @param {Node} node
|
* @param {Node} node
|
||||||
* @param {string} sourceText
|
* @param {string} sourceText
|
||||||
* @param {boolean} isHTML
|
* @param {boolean} isHTML
|
||||||
* @return {{ translateText: TranslationFunction, translateHTML: TranslationFunction}}
|
* @returns {{ translateText: TranslationFunction, translateHTML: TranslationFunction}}
|
||||||
*/
|
*/
|
||||||
#postTranslationRequest(node, sourceText, isHTML) {
|
#postTranslationRequest(node, sourceText, isHTML) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
@ -2049,6 +2063,7 @@ class QueuedTranslator {
|
|||||||
/**
|
/**
|
||||||
* Acquires a port, checks on the engine status, and then starts or resumes
|
* Acquires a port, checks on the engine status, and then starts or resumes
|
||||||
* translations.
|
* translations.
|
||||||
|
*
|
||||||
* @param {MessagePort} port
|
* @param {MessagePort} port
|
||||||
*/
|
*/
|
||||||
acquirePort(port) {
|
acquirePort(port) {
|
||||||
|
@ -150,6 +150,7 @@ export class TranslationsEngine {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes the engine, and if it's the last, call the process to destroy itself.
|
* Removes the engine, and if it's the last, call the process to destroy itself.
|
||||||
|
*
|
||||||
* @param {string} languagePairKey
|
* @param {string} languagePairKey
|
||||||
* @param {boolean} force - On forced shutdowns, it's not necessary to notify the
|
* @param {boolean} force - On forced shutdowns, it's not necessary to notify the
|
||||||
* parent process.
|
* parent process.
|
||||||
@ -207,6 +208,7 @@ export class TranslationsEngine {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Terminates the engine and its worker after a timeout.
|
* Terminates the engine and its worker after a timeout.
|
||||||
|
*
|
||||||
* @param {boolean} force
|
* @param {boolean} force
|
||||||
*/
|
*/
|
||||||
terminate = (force = false) => {
|
terminate = (force = false) => {
|
||||||
@ -419,6 +421,7 @@ function getLanguagePairKey(fromLanguage, toLanguage) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps the innerWindowId to the port.
|
* Maps the innerWindowId to the port.
|
||||||
|
*
|
||||||
* @type {Map<number, { fromLanguage: string, toLanguage: string, port: MessagePort }}
|
* @type {Map<number, { fromLanguage: string, toLanguage: string, port: MessagePort }}
|
||||||
*/
|
*/
|
||||||
const ports = new Map();
|
const ports = new Map();
|
||||||
@ -427,6 +430,7 @@ const ports = new Map();
|
|||||||
* Listen to the port to the content process for incoming messages, and pass
|
* Listen to the port to the content process for incoming messages, and pass
|
||||||
* them to the TranslationsEngine manager. The other end of the port is held
|
* them to the TranslationsEngine manager. The other end of the port is held
|
||||||
* in the content process by the TranslationsDocument.
|
* in the content process by the TranslationsDocument.
|
||||||
|
*
|
||||||
* @param {string} fromLanguage
|
* @param {string} fromLanguage
|
||||||
* @param {string} toLanguage
|
* @param {string} toLanguage
|
||||||
* @param {number} innerWindowId
|
* @param {number} innerWindowId
|
||||||
|
@ -57,6 +57,7 @@ class TranslationsState {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Only send one translation in at a time to the worker.
|
* Only send one translation in at a time to the worker.
|
||||||
|
*
|
||||||
* @type {Promise<string[]>}
|
* @type {Promise<string[]>}
|
||||||
*/
|
*/
|
||||||
translationRequest = Promise.resolve([]);
|
translationRequest = Promise.resolve([]);
|
||||||
@ -75,6 +76,7 @@ class TranslationsState {
|
|||||||
constructor(isSupported) {
|
constructor(isSupported) {
|
||||||
/**
|
/**
|
||||||
* Is the engine supported by the device?
|
* Is the engine supported by the device?
|
||||||
|
*
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
this.isTranslationEngineSupported = isSupported;
|
this.isTranslationEngineSupported = isSupported;
|
||||||
@ -607,7 +609,7 @@ window.addEventListener("AboutTranslationsChromeToContent", ({ detail }) => {
|
|||||||
* Debounce a function so that it is only called after some wait time with no activity.
|
* Debounce a function so that it is only called after some wait time with no activity.
|
||||||
* This is good for grouping text entry via keyboard.
|
* This is good for grouping text entry via keyboard.
|
||||||
*
|
*
|
||||||
* @param {Object} settings
|
* @param {object} settings
|
||||||
* @param {Function} settings.onDebounce
|
* @param {Function} settings.onDebounce
|
||||||
* @param {Function} settings.doEveryTime
|
* @param {Function} settings.doEveryTime
|
||||||
* @returns {Function}
|
* @returns {Function}
|
||||||
@ -671,6 +673,7 @@ class Translator {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Tie together a message id to a resolved response.
|
* Tie together a message id to a resolved response.
|
||||||
|
*
|
||||||
* @type {Map<number, TranslationRequest}
|
* @type {Map<number, TranslationRequest}
|
||||||
*/
|
*/
|
||||||
#requests = new Map();
|
#requests = new Map();
|
||||||
|
@ -149,6 +149,7 @@ async function openAboutTranslations({
|
|||||||
/**
|
/**
|
||||||
* Naively prettify's html based on the opening and closing tags. This is not robust
|
* Naively prettify's html based on the opening and closing tags. This is not robust
|
||||||
* for general usage, but should be adequate for these tests.
|
* for general usage, but should be adequate for these tests.
|
||||||
|
*
|
||||||
* @param {string} html
|
* @param {string} html
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
@ -358,6 +359,7 @@ async function closeAllOpenPanelsAndMenus() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Closes the popup element with the given Id if it is open.
|
* Closes the popup element with the given Id if it is open.
|
||||||
|
*
|
||||||
* @param {string} popupElementId
|
* @param {string} popupElementId
|
||||||
*/
|
*/
|
||||||
async function closePopupIfOpen(popupElementId) {
|
async function closePopupIfOpen(popupElementId) {
|
||||||
@ -655,7 +657,8 @@ async function captureTranslationsError(callback) {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Load a test page and run
|
* Load a test page and run
|
||||||
* @param {Object} options - The options for `loadTestPage` plus a `runInPage` function.
|
*
|
||||||
|
* @param {object} options - The options for `loadTestPage` plus a `runInPage` function.
|
||||||
*/
|
*/
|
||||||
async function autoTranslatePage(options) {
|
async function autoTranslatePage(options) {
|
||||||
const { prefs, languagePairs, ...otherOptions } = options;
|
const { prefs, languagePairs, ...otherOptions } = options;
|
||||||
@ -827,7 +830,7 @@ let _remoteSettingsMockId = 0;
|
|||||||
* Creates a local RemoteSettingsClient for use within tests.
|
* Creates a local RemoteSettingsClient for use within tests.
|
||||||
*
|
*
|
||||||
* @param {boolean} autoDownloadFromRemoteSettings
|
* @param {boolean} autoDownloadFromRemoteSettings
|
||||||
* @param {Object[]} langPairs
|
* @param {object[]} langPairs
|
||||||
* @returns {RemoteSettingsClient}
|
* @returns {RemoteSettingsClient}
|
||||||
*/
|
*/
|
||||||
async function createTranslationModelsRemoteClient(
|
async function createTranslationModelsRemoteClient(
|
||||||
@ -981,7 +984,7 @@ function hitEnterKey(button, message) {
|
|||||||
*
|
*
|
||||||
* @see assertVisibility
|
* @see assertVisibility
|
||||||
*
|
*
|
||||||
* @param {Object} options
|
* @param {object} options
|
||||||
* @param {string} options.message
|
* @param {string} options.message
|
||||||
* @param {Record<string, Element[]>} options.visible
|
* @param {Record<string, Element[]>} options.visible
|
||||||
* @param {Record<string, Element[]>} options.hidden
|
* @param {Record<string, Element[]>} options.hidden
|
||||||
@ -1012,7 +1015,7 @@ async function ensureVisibility({ message = null, visible = {}, hidden = {} }) {
|
|||||||
/**
|
/**
|
||||||
* Asserts that the provided elements are either visible or hidden.
|
* Asserts that the provided elements are either visible or hidden.
|
||||||
*
|
*
|
||||||
* @param {Object} options
|
* @param {object} options
|
||||||
* @param {string} options.message
|
* @param {string} options.message
|
||||||
* @param {Record<string, Element[]>} options.visible
|
* @param {Record<string, Element[]>} options.visible
|
||||||
* @param {Record<string, Element[]>} options.hidden
|
* @param {Record<string, Element[]>} options.hidden
|
||||||
@ -1137,8 +1140,8 @@ class TestTranslationsTelemetry {
|
|||||||
* Asserts qualities about a counter telemetry metric.
|
* Asserts qualities about a counter telemetry metric.
|
||||||
*
|
*
|
||||||
* @param {string} name - The name of the metric.
|
* @param {string} name - The name of the metric.
|
||||||
* @param {Object} counter - The Glean counter object.
|
* @param {object} counter - The Glean counter object.
|
||||||
* @param {Object} expectedCount - The expected value of the counter.
|
* @param {object} expectedCount - The expected value of the counter.
|
||||||
*/
|
*/
|
||||||
static async assertCounter(name, counter, expectedCount) {
|
static async assertCounter(name, counter, expectedCount) {
|
||||||
// Ensures that glean metrics are collected from all child processes
|
// Ensures that glean metrics are collected from all child processes
|
||||||
@ -1156,15 +1159,15 @@ class TestTranslationsTelemetry {
|
|||||||
* Asserts qualities about an event telemetry metric.
|
* Asserts qualities about an event telemetry metric.
|
||||||
*
|
*
|
||||||
* @param {string} name - The name of the metric.
|
* @param {string} name - The name of the metric.
|
||||||
* @param {Object} event - The Glean event object.
|
* @param {object} event - The Glean event object.
|
||||||
* @param {Object} expectations - The test expectations.
|
* @param {object} expectations - The test expectations.
|
||||||
* @param {number} expectations.expectedEventCount - The expected count of events.
|
* @param {number} expectations.expectedEventCount - The expected count of events.
|
||||||
* @param {boolean} expectations.expectNewFlowId
|
* @param {boolean} expectations.expectNewFlowId
|
||||||
* - Expects the flowId to be different than the previous flowId if true,
|
* - Expects the flowId to be different than the previous flowId if true,
|
||||||
* and expects it to be the same if false.
|
* and expects it to be the same if false.
|
||||||
* @param {Array<function>} [expectations.allValuePredicates=[]]
|
* @param {Array<Function>} [expectations.allValuePredicates=[]]
|
||||||
* - An array of function predicates to assert for all event values.
|
* - An array of function predicates to assert for all event values.
|
||||||
* @param {Array<function>} [expectations.finalValuePredicates=[]]
|
* @param {Array<Function>} [expectations.finalValuePredicates=[]]
|
||||||
* - An array of function predicates to assert for only the final event value.
|
* - An array of function predicates to assert for only the final event value.
|
||||||
*/
|
*/
|
||||||
static async assertEvent(
|
static async assertEvent(
|
||||||
@ -1264,8 +1267,8 @@ class TestTranslationsTelemetry {
|
|||||||
* Asserts qualities about a rate telemetry metric.
|
* Asserts qualities about a rate telemetry metric.
|
||||||
*
|
*
|
||||||
* @param {string} name - The name of the metric.
|
* @param {string} name - The name of the metric.
|
||||||
* @param {Object} rate - The Glean rate object.
|
* @param {object} rate - The Glean rate object.
|
||||||
* @param {Object} expectations - The test expectations.
|
* @param {object} expectations - The test expectations.
|
||||||
* @param {number} expectations.expectedNumerator - The expected value of the numerator.
|
* @param {number} expectations.expectedNumerator - The expected value of the numerator.
|
||||||
* @param {number} expectations.expectedDenominator - The expected value of the denominator.
|
* @param {number} expectations.expectedDenominator - The expected value of the denominator.
|
||||||
*/
|
*/
|
||||||
@ -1346,9 +1349,10 @@ function getNeverTranslateSitesFromPerms() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Opens a dialog window for about:preferences
|
* Opens a dialog window for about:preferences
|
||||||
|
*
|
||||||
* @param {string} dialogUrl - The URL of the dialog window
|
* @param {string} dialogUrl - The URL of the dialog window
|
||||||
* @param {Function} callback - The function to open the dialog via UI
|
* @param {Function} callback - The function to open the dialog via UI
|
||||||
* @returns {Object} The dialog window object
|
* @returns {object} The dialog window object
|
||||||
*/
|
*/
|
||||||
async function waitForOpenDialogWindow(dialogUrl, callback) {
|
async function waitForOpenDialogWindow(dialogUrl, callback) {
|
||||||
const dialogLoaded = promiseLoadSubDialog(dialogUrl);
|
const dialogLoaded = promiseLoadSubDialog(dialogUrl);
|
||||||
@ -1360,7 +1364,7 @@ async function waitForOpenDialogWindow(dialogUrl, callback) {
|
|||||||
/**
|
/**
|
||||||
* Closes an open dialog window and waits for it to close.
|
* Closes an open dialog window and waits for it to close.
|
||||||
*
|
*
|
||||||
* @param {Object} dialogWindow
|
* @param {object} dialogWindow
|
||||||
*/
|
*/
|
||||||
async function waitForCloseDialogWindow(dialogWindow) {
|
async function waitForCloseDialogWindow(dialogWindow) {
|
||||||
const closePromise = BrowserTestUtils.waitForEvent(
|
const closePromise = BrowserTestUtils.waitForEvent(
|
||||||
|
Loading…
Reference in New Issue
Block a user