diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /browser/components/customizableui/test | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-upstream/125.0.1.tar.xz firefox-upstream/125.0.1.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'browser/components/customizableui/test')
-rw-r--r-- | browser/components/customizableui/test/browser_1856572_ensure_Fluent_works_in_customizeMode.js | 43 |
1 files changed, 30 insertions, 13 deletions
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" ); }); |