Bug 1327118 - Fix the charset encoding menu not being properly enabled when dragging tabs into a new window. r=mconley
MozReview-Commit-ID: 15HVXsKHoYW
--- a/toolkit/content/tests/browser/browser.ini
+++ b/toolkit/content/tests/browser/browser.ini
@@ -45,16 +45,17 @@ tags = audiochannel
tags = audiochannel
[browser_bug1170531.js]
[browser_bug1198465.js]
[browser_bug295977_autoscroll_overflow.js]
[browser_bug451286.js]
skip-if = !e10s
[browser_bug594509.js]
[browser_bug982298.js]
+[browser_charsetMenu_swapBrowsers.js]
[browser_content_url_annotation.js]
skip-if = !e10s || !crashreporter
[browser_contentTitle.js]
[browser_crash_previous_frameloader.js]
run-if = e10s && crashreporter
[browser_default_image_filename.js]
[browser_f7_caret_browsing.js]
[browser_findbar.js]
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/browser/browser_charsetMenu_swapBrowsers.js
@@ -0,0 +1,28 @@
+/* Test that the charset menu is properly enabled when swapping browsers. */
+add_task(async function test() {
+ // NB: This test cheats and calls updateCharacterEncodingMenuState directly
+ // instead of opening the "View" menu.
+ function charsetMenuEnabled() {
+ updateCharacterEncodingMenuState();
+ return !document.getElementById("charsetMenu").hasAttribute("disabled");
+ }
+
+ const PAGE = "data:text/html;charset=utf-8,<!DOCTYPE html><body>hello";
+ let tab1 = await BrowserTestUtils.openNewForegroundTab({ gBrowser, url: PAGE });
+ 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");
+
+ await BrowserTestUtils.removeTab(tab2);
+});
--- a/toolkit/content/widgets/browser.xml
+++ b/toolkit/content/widgets/browser.xml
@@ -1367,16 +1367,17 @@
"_remoteWebProgressManager",
"_remoteWebProgress",
"_remoteFinder",
"_securityUI",
"_documentURI",
"_documentContentType",
"_contentTitle",
"_characterSet",
+ "_mayEnableCharacterEncodingMenu",
"_contentPrincipal",
"_imageDocument",
"_fullZoom",
"_textZoom",
"_isSyntheticDocument",
"_innerWindowID",
"_manifestURI",
]);