Bug 1565888 - Replace Japanese with Shift_JIS in onSetCharacterSet() for view source. r=mkmelin a=jorgk DONTBUILD
authorJorg K <jorgk@jorgk.com>
Sun, 14 Jul 2019 19:40:46 +0200
changeset 35229 88262b52018dba31463fe4756aeae2ffe98355f1
parent 35228 8f5dba7221f0c6cd9e36302ad4a33aab0d86cb12
child 35236 037a19a922a15ab5d90c7b04b503bd6e12a94e17
push id2464
push usermozilla@jorgk.com
push dateTue, 16 Jul 2019 09:27:32 +0000
treeherdercomm-beta@88262b52018d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmkmelin, jorgk
bugs1565888
Bug 1565888 - Replace Japanese with Shift_JIS in onSetCharacterSet() for view source. r=mkmelin a=jorgk DONTBUILD
common/src/viewSource.js
--- a/common/src/viewSource.js
+++ b/common/src/viewSource.js
@@ -430,17 +430,23 @@ ViewSourceChrome.prototype = {
    * Called by clicks on a menu populated by CharsetMenu.jsm to
    * change the selected character set.
    *
    * @param event
    *        The click event on a character set menuitem.
    */
   onSetCharacterSet(event) {
     if (event.target.hasAttribute("charset")) {
-      this.browser.docShell.charset = event.target.getAttribute("charset");
+      let charset = event.target.getAttribute("charset");
+      // Replace generic Japanses with Shift_JIS which will also auto-detect
+      // ISO-2022-JP and EUC-JP.
+      if (charset == "Japanese") {
+        charset = "Shift_JIS";
+      }
+      this.browser.docShell.charset = charset;
       this.browser
           .reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
     }
   },
 
   /**
    * Called from the frame script when the context menu is about to
    * open. This tells ViewSourceChrome things about the item that