From 40a355a42d4a9444dc753c04c6608dade2f06a23 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:27 +0200 Subject: Adding upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../browser_translations_translation_document.js | 100 +++++++++++++++++++++ 1 file changed, 100 insertions(+) (limited to 'toolkit/components/translations/tests/browser/browser_translations_translation_document.js') 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 */ ` +

+ This is some text. + It has inline elements + +

+ `, + { 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 */ ` +

+ aaaa aa aaaa aaaa. + + aa aaa aaaaaa aaaaaaaa + + +

+ ` + ); + + 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 */ ` +
+ + Start of inline text + +
+ hidden portion of +
+ + rest of inline text. + +
+ `, + { mockedTranslatorPort: createBatchedMockedTranslatorPort() } + ); + + translate(); + + // eslint-disable-next-line no-unused-vars + const _realExpectedResults = /* html */ ` +
+ + aaaaa aa aaaaaa aaaa + +
+ aaaaaa aaaaaaa aa +
+ + aaaa aa aaaaaa aaaa. + +
+ `; + + const currentResults = /* html */ ` +
+ + aaaaa aa aaaaaa aaaa + +
+ bbbbbb bbbbbbb bb +
+ + cccc cc cccccc cccc. + +
+ `; + + await htmlMatches("Display none", currentResults); + + cleanup(); +}); + add_task(async function test_chunking_large_text() { const { translate, htmlMatches, cleanup } = await createDoc( /* html */ ` -- cgit v1.2.3