1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/toolkit/content/tests/chrome/test_righttoleft.xul Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,126 @@ 1.4 +<?xml version="1.0"?> 1.5 +<?xml-stylesheet href="chrome://global/skin" type="text/css"?> 1.6 +<?xml-stylesheet 1.7 + href="chrome://mochikit/content/tests/SimpleTest/test.css" 1.8 + type="text/css"?> 1.9 + 1.10 +<window title="Right to Left UI Test" 1.11 + onload="runTest()" 1.12 + xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> 1.13 + 1.14 + <script type="application/javascript" 1.15 + src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> 1.16 + <script type="application/javascript" 1.17 + src="chrome://mochikit/content/chrome-harness.js"></script> 1.18 + <script type="application/javascript" 1.19 + src="RegisterUnregisterChrome.js"></script> 1.20 + 1.21 + <body xmlns="http://www.w3.org/1999/xhtml"> 1.22 + <p id="display"></p> 1.23 + <div id="content" style="display: none"> 1.24 + </div> 1.25 + <pre id="test"> 1.26 + </pre> 1.27 + </body> 1.28 + 1.29 + <iframe id="subframe" width="100" height="100" onload="frameLoaded();"/> 1.30 + 1.31 + <script type="application/javascript"> 1.32 + <![CDATA[ 1.33 + 1.34 + SimpleTest.waitForExplicitFinish(); 1.35 + 1.36 + let prefs = Cc["@mozilla.org/preferences-service;1"]. 1.37 + getService(Ci.nsIPrefBranch); 1.38 + const UI_DIRECTION_PREF = "intl.uidirection.ar"; 1.39 + prefs.setCharPref(UI_DIRECTION_PREF, "rtl"); 1.40 + 1.41 + let rootDir = getRootDirectory(window.location.href); 1.42 + registerManifestPermanently(rootDir + "rtltest/righttoleft.manifest"); 1.43 + 1.44 + function runTest() 1.45 + { 1.46 + var subframe = document.getElementById("subframe"); 1.47 + subframe.setAttribute("src", "chrome://ltrtest/content/dirtest.xul"); 1.48 + } 1.49 + 1.50 + function frameLoaded() 1.51 + { 1.52 + var subframe = document.getElementById("subframe"); 1.53 + var subwin = subframe.contentWindow; 1.54 + var subdoc = subframe.contentDocument; 1.55 + var url = String(subwin.location); 1.56 + if (url.indexOf("chrome://ltrtest") == 0) { 1.57 + is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, 1.58 + "rgb(255, 255, 0)", "left to right with :-moz-locale-dir(ltr)"); 1.59 + is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, 1.60 + "rgb(255, 255, 255)", "left to right with :-moz-locale-dir(rtl)"); 1.61 + 1.62 + is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", 1.63 + "left to right direction"); 1.64 + 1.65 + subdoc.documentElement.setAttribute("localedir", "rtl"); 1.66 + 1.67 + is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, 1.68 + "rgb(255, 255, 255)", "left to right with :-moz-locale-dir(ltr) and localedir='rtl'"); 1.69 + is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, 1.70 + "rgb(0, 128, 0)", "left to right with :-moz-locale-dir(rtl) and localedir='rtl'"); 1.71 + is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "rtl", 1.72 + "left to right direction with localedir='rtl'"); 1.73 + 1.74 + subdoc.documentElement.removeAttribute("localedir"); 1.75 + 1.76 + is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, 1.77 + "rgb(255, 255, 0)", "left to right with :-moz-locale-dir(ltr) and localedir removed"); 1.78 + is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, 1.79 + "rgb(255, 255, 255)", "left to right with :-moz-locale-dir(rtl) and localedir removed"); 1.80 + is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", 1.81 + "left to right direction with localedir removed"); 1.82 + 1.83 + subframe.setAttribute("src", "chrome://rtltest/content/dirtest.xul"); 1.84 + } 1.85 + else if (url.indexOf("chrome://rtltest") == 0) { 1.86 + is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, 1.87 + "rgb(255, 255, 255)", "right to left with :-moz-locale-dir(ltr)"); 1.88 + is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, 1.89 + "rgb(0, 128, 0)", "right to left with :-moz-locale-dir(rtl)"); 1.90 + is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "rtl", 1.91 + "right to left direction"); 1.92 + 1.93 + subdoc.documentElement.setAttribute("localedir", "ltr"); 1.94 + 1.95 + is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, 1.96 + "rgb(255, 255, 0)", "right to left with :-moz-locale-dir(ltr) and localedir='ltr'"); 1.97 + is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, 1.98 + "rgb(255, 255, 255)", "right to left with :-moz-locale-dir(rtl) and localedir='ltr'"); 1.99 + is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", 1.100 + "right to left direction with localedir='ltr'"); 1.101 + 1.102 + subdoc.documentElement.removeAttribute("localedir"); 1.103 + 1.104 + prefs.setCharPref(UI_DIRECTION_PREF, ""); 1.105 + is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", 1.106 + "left to right direction with no preference set"); 1.107 + prefs.setCharPref(UI_DIRECTION_PREF + "-QA", "rtl"); 1.108 + is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "rtl", 1.109 + "right to left direction with more specific preference set"); 1.110 + prefs.setCharPref(UI_DIRECTION_PREF, "ltr"); 1.111 + is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "rtl", 1.112 + "right to left direction with less specific and more specific preference set"); 1.113 + prefs.setCharPref(UI_DIRECTION_PREF, "rtl"); 1.114 + prefs.setCharPref(UI_DIRECTION_PREF + "-QA", "ltr"); 1.115 + is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", 1.116 + "left to right direction specific preference overrides"); 1.117 + if (prefs.prefHasUserValue(UI_DIRECTION_PREF + "-QA")) 1.118 + prefs.clearUserPref(UI_DIRECTION_PREF + "-QA"); 1.119 + 1.120 + if (prefs.prefHasUserValue(UI_DIRECTION_PREF)) 1.121 + prefs.clearUserPref(UI_DIRECTION_PREF); 1.122 + 1.123 + SimpleTest.finish(); 1.124 + } 1.125 + } 1.126 + ]]> 1.127 + </script> 1.128 + 1.129 +</window>