summaryrefslogtreecommitdiffstats
path: root/toolkit/components/translations/tests/browser/browser_translations_translation_document.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /toolkit/components/translations/tests/browser/browser_translations_translation_document.js
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'toolkit/components/translations/tests/browser/browser_translations_translation_document.js')
-rw-r--r--toolkit/components/translations/tests/browser/browser_translations_translation_document.js100
1 files changed, 100 insertions, 0 deletions
diff --git a/toolkit/components/translations/tests/browser/browser_translations_translation_document.js b/toolkit/components/translations/tests/browser/browser_translations_translation_document.js
index 9a00da9ccf..d3d56fd387 100644
--- a/toolkit/components/translations/tests/browser/browser_translations_translation_document.js
+++ b/toolkit/components/translations/tests/browser/browser_translations_translation_document.js
@@ -51,6 +51,7 @@ async function createDoc(html, options) {
/**
* Test utility to check that the document matches the expected markup
*
+ * @param {string} message
* @param {string} html
*/
async function htmlMatches(message, html) {
@@ -720,6 +721,105 @@ add_task(async function test_presumed_inlines3() {
cleanup();
});
+/**
+ * Test the display "none" properties properly subdivide in block elements.
+ */
+add_task(async function test_display_none() {
+ const { translate, htmlMatches, cleanup } = await createDoc(
+ /* html */ `
+ <p>
+ This is some text.
+ <span>It has inline elements</span>
+ <style></style>
+ </p>
+ `,
+ { mockedTranslatorPort: createBatchedMockedTranslatorPort() }
+ );
+
+ translate();
+
+ // Note: The bergamot translator does not translate style elements, while our fake
+ // translator does translate the inside of style elements. That is why in the assertion
+ // here the style element is blank rather than containing style.
+ await htmlMatches(
+ "Display none",
+ /* html */ `
+ <p>
+ aaaa aa aaaa aaaa.
+ <span data-moz-translations-id="0">
+ aa aaa aaaaaa aaaaaaaa
+ </span>
+ <style data-moz-translations-id="1">
+ </style>
+ </p>
+ `
+ );
+
+ cleanup();
+});
+
+/**
+ * Test the display "none" properties properly subdivide in block elements.
+ *
+ * TODO - See Bug 1885235
+ *
+ * This assertion is wrong, as our test suite doesn't properly compute the style for
+ * elements. The div with "display; none;" is still block, not "none".
+ */
+add_task(async function test_display_none_div() {
+ const { translate, htmlMatches, cleanup } = await createDoc(
+ /* html */ `
+ <div>
+ <span>
+ Start of inline text
+ </span>
+ <div style="display: none;">
+ hidden portion of
+ </div>
+ <span>
+ rest of inline text.
+ </span>
+ </div>
+ `,
+ { mockedTranslatorPort: createBatchedMockedTranslatorPort() }
+ );
+
+ translate();
+
+ // eslint-disable-next-line no-unused-vars
+ const _realExpectedResults = /* html */ `
+ <div>
+ <span>
+ aaaaa aa aaaaaa aaaa
+ </span>
+ <div style="display: none;">
+ aaaaaa aaaaaaa aa
+ </div>
+ <span>
+ aaaa aa aaaaaa aaaa.
+ </span>
+ </div>
+ `;
+
+ const currentResults = /* html */ `
+ <div>
+ <span>
+ aaaaa aa aaaaaa aaaa
+ </span>
+ <div style="display: none;">
+ bbbbbb bbbbbbb bb
+ </div>
+ <span>
+ cccc cc cccccc cccc.
+ </span>
+ </div>
+ `;
+
+ await htmlMatches("Display none", currentResults);
+
+ cleanup();
+});
+
add_task(async function test_chunking_large_text() {
const { translate, htmlMatches, cleanup } = await createDoc(
/* html */ `