From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- ...1856572_ensure_Fluent_works_in_customizeMode.js | 43 +++++++++++++++------- 1 file changed, 30 insertions(+), 13 deletions(-) (limited to 'browser/components/customizableui/test/browser_1856572_ensure_Fluent_works_in_customizeMode.js') diff --git a/browser/components/customizableui/test/browser_1856572_ensure_Fluent_works_in_customizeMode.js b/browser/components/customizableui/test/browser_1856572_ensure_Fluent_works_in_customizeMode.js index 0f89bd5d1c..7187effdb1 100644 --- a/browser/components/customizableui/test/browser_1856572_ensure_Fluent_works_in_customizeMode.js +++ b/browser/components/customizableui/test/browser_1856572_ensure_Fluent_works_in_customizeMode.js @@ -10,12 +10,21 @@ const { "resource://testing-common/FirefoxViewTestUtils.sys.mjs" ); +/** + * Bug 1856572 - This test is to ensure that fluent strings in Firefox View + * can be updated after opening Customize Mode + * **/ add_task(async function test_data_l10n_customize_mode() { FirefoxViewTestUtilsInit(this); await withFirefoxView({ win: window }, async function (browser) { /** * Bug 1856572, Bug 1857622: Without requesting two animation frames * the "missing Fluent strings" issue will not reproduce. + * + * Given the precondition that we open Firefox View, then open Customize Mode, then + * navigate back to Firefox View in a quick succession, as long as Fluent + * controlled strings can be updated by changing their Fluent IDs then this + * test is valid. */ await new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r)) @@ -23,39 +32,47 @@ add_task(async function test_data_l10n_customize_mode() { await startCustomizing(); await endCustomizing(); await openFirefoxViewTab(window); - const { document } = browser.contentWindow; - let header = document.querySelector("h1"); - document.l10n.setAttributes(header, "firefoxview-overview-header"); + let secondPageNavButton = document.querySelectorAll( + "moz-page-nav-button" + )[0]; + document.l10n.setAttributes( + secondPageNavButton, + "firefoxview-overview-header" + ); let previousText = await document.l10n.formatValue( - "firefoxview-page-title" + "firefoxview-opentabs-nav" + ); + let translatedText = await window.content.document.l10n.formatValue( + "firefoxview-overview-header" ); /** * This should be replaced with - * BrowserTestUtils.waitForMutationCondition(header, {characterData: true}, ...) + * BrowserTestUtils.waitForMutationCondition(secondPageNavButton, {characterData: true}, ...) * but apparently Fluent manipulation of textContent doesn't result * in a characterData mutation occurring. */ await BrowserTestUtils.waitForCondition(() => { - return header.textContent != previousText; + return ( + secondPageNavButton.textContent !== previousText && + secondPageNavButton.textContent === translatedText + ); }, "waiting for text content to change"); Assert.equal( - header.getAttribute("data-l10n-id"), + secondPageNavButton.getAttribute("data-l10n-id"), "firefoxview-overview-header", "data-l10n-id should be updated" ); Assert.notEqual( previousText, - header.textContent, - "The header's text content should be updated" - ); - let translatedText = await window.content.document.l10n.formatValue( - "firefoxview-overview-header" + secondPageNavButton.textContent, + "The second page-nav button text content should be updated" ); + Assert.equal( translatedText, - header.textContent, + secondPageNavButton.textContent, "The changed text should be the translated value of 'firefoxview-overview-header" ); }); -- cgit v1.2.3