Bug 1327118 - Fix the charset encoding menu not being properly enabled when dragging tabs into a new window. r=mconley draft
authorBlake Kaplan <mrbkap@gmail.com>
Tue, 06 Jun 2017 17:04:54 -0700
changeset 590595 d04e507a4be41e061f3c334e92455b7f063888ac
parent 589747 6cd0639e02ded96057e7fa325623a1245efd4535
child 632271 ffc130e49da03cfb0228091be86acda71171e156
push id62791
push userbmo:mrbkap@mozilla.com
push dateWed, 07 Jun 2017 22:20:08 +0000
reviewersmconley
bugs1327118
milestone55.0a1
Bug 1327118 - Fix the charset encoding menu not being properly enabled when dragging tabs into a new window. r=mconley MozReview-Commit-ID: 15HVXsKHoYW
toolkit/content/tests/browser/browser.ini
toolkit/content/tests/browser/browser_charsetMenu_swapBrowsers.js
toolkit/content/widgets/browser.xml
--- 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",
             ]);