From 6bf0a5cb5034a7e684dcc3500e841785237ce2dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 19:32:43 +0200 Subject: Adding upstream version 1:115.7.0. Signed-off-by: Daniel Baumann --- .../browser/browser_charsetMenu_swapBrowsers.js | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 toolkit/content/tests/browser/browser_charsetMenu_swapBrowsers.js (limited to 'toolkit/content/tests/browser/browser_charsetMenu_swapBrowsers.js') diff --git a/toolkit/content/tests/browser/browser_charsetMenu_swapBrowsers.js b/toolkit/content/tests/browser/browser_charsetMenu_swapBrowsers.js new file mode 100644 index 0000000000..9ea8fccf29 --- /dev/null +++ b/toolkit/content/tests/browser/browser_charsetMenu_swapBrowsers.js @@ -0,0 +1,39 @@ +/* Test that the charset menu is properly enabled when swapping browsers. */ +add_task(async function test() { + function charsetMenuEnabled() { + return !document + .getElementById("repair-text-encoding") + .hasAttribute("disabled"); + } + + const PAGE = + "data:text/html;charset=windows-1252,hello %e4"; + let tab1 = await BrowserTestUtils.openNewForegroundTab({ + gBrowser, + url: PAGE, + }); + await BrowserTestUtils.waitForMutationCondition( + document.getElementById("repair-text-encoding"), + { attributes: true }, + charsetMenuEnabled + ); + ok(charsetMenuEnabled(), "should have a charset menu here"); + + let tab2 = await BrowserTestUtils.openNewForegroundTab({ gBrowser }); + ok(!charsetMenuEnabled(), "about:blank shouldn't have a charset menu"); + + await BrowserTestUtils.switchTab(gBrowser, tab1); + + let swapped = BrowserTestUtils.waitForEvent( + tab2.linkedBrowser, + "SwapDocShells" + ); + + // NB: Closes tab1. + gBrowser.swapBrowsersAndCloseOther(tab2, tab1); + await swapped; + + ok(charsetMenuEnabled(), "should have a charset after the swap"); + + BrowserTestUtils.removeTab(tab2); +}); -- cgit v1.2.3