Bug 437844 - [RTL] about:plugins is hardcoded to LTR; r=bz
authorEhsan Akhgari <ehsan.akhgari@gmail.com>
Fri, 30 Jan 2009 11:43:17 +0330
changeset 24438 121fbf0736cc1154f74f50b795630c4fffd94b2b
parent 24437 3470b0b3a98d28a6a14236f461d31ab6ec0e6af5
child 24439 3777df92cc24f15040e4bc69cc486a0f378b22b9
push idunknown
push userunknown
push dateunknown
reviewersbz
bugs437844
milestone1.9.2a1pre
Bug 437844 - [RTL] about:plugins is hardcoded to LTR; r=bz
toolkit/content/directionDetector.html
toolkit/content/jar.mn
toolkit/content/plugins.css
toolkit/content/plugins.html
toolkit/content/tests/chrome/Makefile.in
toolkit/content/tests/chrome/bug437844.css
toolkit/content/tests/chrome/bug437844.manifest
toolkit/content/tests/chrome/test_bug437844.xul
new file mode 100644
--- /dev/null
+++ b/toolkit/content/directionDetector.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<html>
+  <head>
+    <link rel="stylesheet" type="text/css" href="chrome://global/locale/intl.css">
+  </head>
+  <body>
+    <window id="target" style="display: none;"></window>
+  </body>
+</html>
--- a/toolkit/content/jar.mn
+++ b/toolkit/content/jar.mn
@@ -4,16 +4,17 @@ toolkit.jar:
 %  content global-region %content/global-region/ xpcnativewrappers=yes
 # provide the nsTransferable in nsDragAndDrop.js to extensions that have to
 # work with Geckos from before 1.9, when there was a separate file
 %  override chrome://global/content/nsTransferable.js chrome://global/content/nsDragAndDrop.js
 *  content/global/license.html                (license.html)
    content/global/XPCNativeWrapper.js         (XPCNativeWrapper.js)
 *  content/global/xul.css                     (xul.css)
 *  content/global/about.xhtml                 (about.xhtml)
+   content/global/directionDetector.html
    content/global/plugins.html
    content/global/plugins.css
 *+  content/global/buildconfig.html            (buildconfig.html)
 +  content/global/charsetOverlay.js           (charsetOverlay.js)
 +  content/global/charsetOverlay.xul          (charsetOverlay.xul)
 *+ content/global/commonDialog.js             (commonDialog.js)
 *+ content/global/commonDialog.xul            (commonDialog.xul)
    content/global/commonDialog.css            (commonDialog.css)
--- a/toolkit/content/plugins.css
+++ b/toolkit/content/plugins.css
@@ -66,29 +66,29 @@ div#outside {
 div#findmore {
   margin-top: 2em;
 }
 
 .plugname {
   margin-top: 2em;
   margin-bottom: 1em;
   font-size: large;
-  text-align: left;
+  text-align: start;
   font-weight: bold;
 }
 
 dl {
   margin: 0px 0px 3px 0px;
 }
 
 table {
   background-color: -moz-Dialog;
   color: -moz-DialogText;
   font: message-box;
-  text-align: left;
+  text-align: start;
   width: 100%;
   border: 1px solid ThreeDShadow;
   border-spacing: 0px;
 }
 
 th, td {
   border: none;
   padding: 3px;
@@ -97,21 +97,21 @@ th, td {
 th {
   text-align: center;
   background-color: Highlight;
   color: HighlightText;
 }
 
 th + th,
 td + td {
-  border-left: 1px dotted ThreeDShadow; 
+  -moz-border-start: 1px dotted ThreeDShadow; 
 }
 
 td {
-  text-align: left;
+  text-align: start;
   border-top: 1px dotted ThreeDShadow;
 }
 
 th.type, th.suff {
   width: 20%;
 }
 
 th.desc {
--- a/toolkit/content/plugins.html
+++ b/toolkit/content/plugins.html
@@ -21,16 +21,17 @@
    - the Initial Developer. All Rights Reserved.
    -
    - Contributor(s):
    -   Mark Olson <maolson@earthlink.net>
    -   Alexey Chernyak <alexeyc@bigfoot.com>
    -   Frank Tang <ftang@netscape.com>
    -   Mike Connelly <mozilla@shepherdstown.com>
    -   Robert Kaiser <kairo@kairo.at>
+   -   Ehsan Akhgari <ehsan.akhgari@gmail.com>
    -
    - Alternatively, the contents of this file may be used under the terms of
    - either the GNU General Public License Version 2 or later (the "GPL"), or
    - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
    - in which case the provisions of the GPL or the LGPL are applicable instead
    - of those above. If you wish to allow use of your version of this file only
    - under the terms of either the GPL or the LGPL, and not to allow others to
    - use your version of this file under the terms of the MPL, indicate your
@@ -52,16 +53,39 @@
 </script>
 <link rel="stylesheet" type="text/css" href="chrome://global/content/plugins.css">
 <link rel="stylesheet" type="text/css" href="chrome://global/skin/plugins.css">
 </head>
 <body>
 <div id="outside">
 <script type="application/javascript">
 
+  function setDirection() {
+    var frame = document.getElementById("directionDetector");
+    var direction = frame.contentDocument
+                         .defaultView
+                         .window
+                         .getComputedStyle(frame.contentDocument.getElementById("target"), "")
+                         .getPropertyValue("direction");
+    document.body.removeChild(frame);
+    document.dir = direction;
+  }
+
+  function setupDirection() {
+    var frame = document.createElement("iframe");
+    frame.setAttribute("id", "directionDetector");
+    frame.setAttribute("src", "chrome://global/content/directionDetector.html");
+    frame.setAttribute("width", "0");
+    frame.setAttribute("height", "0");
+    frame.setAttribute("style", "visibility: hidden;");
+    frame.setAttribute("onload", "setDirection();");
+    document.body.appendChild(frame);
+  }
+  setupDirection();
+
   /* JavaScript to enumerate and display all installed plug-ins
 
    * First, refresh plugins in case anything has been changed recently in
    * prefs: (The "false" argument tells refresh not to reload or activate
    * any plug-ins that would be active otherwise.  In contrast, one would
    * use "true" in the case of ASD instead of restarting)
    */
   navigator.plugins.refresh(false);
--- a/toolkit/content/tests/chrome/Makefile.in
+++ b/toolkit/content/tests/chrome/Makefile.in
@@ -55,16 +55,19 @@ include $(topsrcdir)/config/rules.mk
 		test_bug331215.xul \
 		bug360437_window.xul \
 		test_bug360437.xul \
 		bug366992_window.xul \
 		test_bug366992.xul \
 		test_bug418874.xul \
 		bug429723_window.xul \
 		test_bug429723.xul \
+		bug437844.css \
+		bug437844.manifest \
+		test_bug437844.xul \
 		bug451286_window.xul \
 		test_bug451286.xul \
 		test_popup_preventdefault_chrome.xul \
 		window_popup_preventdefault_chrome.xul \
 		test_largemenu.xul \
 		window_largemenu.xul \
 		test_popup_anchor.xul \
 		window_popup_anchor.xul \
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/chrome/bug437844.css
@@ -0,0 +1,2 @@
+/* Imitate RTL UI */
+window { direction: rtl; }
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/chrome/bug437844.manifest
@@ -0,0 +1,2 @@
+# Override intl.css with our own CSS file
+override chrome://global/locale/intl.css chrome://mochikit/content/chrome/toolkit/content/tests/chrome/bug437844.css
new file mode 100644
--- /dev/null
+++ b/toolkit/content/tests/chrome/test_bug437844.xul
@@ -0,0 +1,160 @@
+<?xml version="1.0"?>
+<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
+<?xml-stylesheet 
+  href="chrome://mochikit/content/tests/SimpleTest/test.css"
+  type="text/css"?>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=437844
+-->
+<window title="Mozilla Bug 437844"
+  xmlns:html="http://www.w3.org/1999/xhtml"
+  xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
+
+  <title>Test for Bug 437844</title>
+  <script type="application/javascript" 
+          src="chrome://mochikit/content/MochiKit/packed.js"></script>
+  <script type="application/javascript" 
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+  <body  xmlns="http://www.w3.org/1999/xhtml">
+    <a target="_blank" 
+       href="https://bugzilla.mozilla.org/show_bug.cgi?id=437844">
+      Mozilla Bug 437844
+    </a>
+
+    <p id="display"></p>
+    <div id="content" style="display: none">
+    </div>
+    <pre id="test">
+    </pre>
+  </body>
+
+  <script type="application/javascript">
+    <![CDATA[
+
+      /* This code is mostly copied from chrome/test/unit/head_crtestutils.js */
+      const NS_CHROME_MANIFESTS_FILE_LIST = "ChromeML";
+
+      const Cc = Components.classes;
+      const Ci = Components.interfaces;
+      const Cr = Components.results;
+
+      function ArrayEnumerator(array)
+      {
+        this.array = array;
+      }
+
+      ArrayEnumerator.prototype = {
+        pos: 0,
+        
+        hasMoreElements: function() {
+          return this.pos < this.array.length;
+        },
+        
+        getNext: function() {
+          if (this.pos < this.array.length)
+            return this.array[this.pos++];
+          throw Cr.NS_ERROR_FAILURE;
+        },
+
+        QueryInterface: function(iid) {
+          if (iid.equals(Ci.nsISimpleEnumerator)
+           || iid.equals(Ci.nsISupports))
+            return this;
+
+          throw Cr.NS_ERROR_NO_INTERFACE;
+        }
+      };
+
+      function ChromeProvider(manifests)
+      {
+        this._manifests = manifests;
+      }
+
+      ChromeProvider.prototype = {
+        getFile: function(prop, persistent) {
+          throw Cr.NS_ERROR_FAILURE;
+        },
+
+        getFiles: function(prop) {
+          if (prop == NS_CHROME_MANIFESTS_FILE_LIST) {
+            return new ArrayEnumerator(this._manifests);
+          }
+          throw Cr.NS_ERROR_FAILURE;
+        },
+
+        QueryInterface: function(iid) {
+          if (iid.equals(Ci.nsIDirectoryServiceProvider)
+           || iid.equals(Ci.nsIDirectoryServiceProvider2)
+           || iid.equals(Ci.nsISupports))
+            return this;
+
+          throw Cr.NS_ERROR_NO_INTERFACE;
+        }
+      };
+
+      let dirSvc = Cc["@mozilla.org/file/directory_service;1"].
+                   getService(Ci.nsIDirectoryService);
+      function registerManifests(manifests)
+      {
+        let provider = new ChromeProvider(manifests);
+        dirSvc.registerProvider(provider);
+        return provider;
+      }
+
+
+    ]]>
+  </script>
+
+  <script class="testbody" type="application/javascript">
+    <![CDATA[
+
+      /** Test for Bug 437844 **/
+      SimpleTest.waitForExplicitFinish();
+
+      // Disable XUL cache temporarily
+      let prefs = Cc["@mozilla.org/preferences-service;1"].
+                  getService(Ci.nsIPrefBranch);
+      const XUL_CACHE_PREF = "nglayout.debug.disable_xul_cache";
+      prefs.setBoolPref(XUL_CACHE_PREF, true);
+
+      // Register our manifest
+      let cr = Cc["@mozilla.org/chrome/chrome-registry;1"].
+               getService(Ci.nsIXULChromeRegistry);
+      let manifests = [];
+      let currentManifests = dirSvc.QueryInterface(Ci.nsIProperties)
+                                   .get(NS_CHROME_MANIFESTS_FILE_LIST,
+                                        Ci.nsISimpleEnumerator);
+      while (currentManifests.hasMoreElements())
+        manifests.push(currentManifests.getNext());
+      let uri = Cc["@mozilla.org/network/io-service;1"].
+                getService(Ci.nsIIOService).
+                newURI("chrome://mochikit/content/chrome/toolkit/content/tests/chrome/", null, null);
+      uri = cr.convertChromeURL(uri);
+      let newChromePath = uri.QueryInterface(Ci.nsIFileURL).file;
+      manifests.push(newChromePath);
+      let provider = registerManifests(manifests);
+      cr.checkForNewChrome();
+      cr.refreshSkins();
+
+      // Load about:plugins in an iframe
+      let frame = document.createElement("iframe");
+      frame.setAttribute("src", "about:plugins");
+      frame.addEventListener("load", function () {
+          frame.removeEventListener("load", arguments.callee, false);
+
+          is(frame.contentDocument.dir, "rtl", "about:plugins should be RTL in RTL locales");
+
+          // cleanup
+          dirSvc.unregisterProvider(provider);
+          cr.checkForNewChrome();
+          cr.refreshSkins();
+          prefs.clearUserPref(XUL_CACHE_PREF);
+          SimpleTest.finish();
+        }, false);
+      document.documentElement.appendChild(frame);
+
+    ]]>
+  </script>
+
+</window>