|
1 <?xml version="1.0"?> |
|
2 <?xml-stylesheet href="chrome://global/skin" type="text/css"?> |
|
3 <?xml-stylesheet |
|
4 href="chrome://mochikit/content/tests/SimpleTest/test.css" |
|
5 type="text/css"?> |
|
6 |
|
7 <window title="Right to Left UI Test" |
|
8 onload="runTest()" |
|
9 xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"> |
|
10 |
|
11 <script type="application/javascript" |
|
12 src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> |
|
13 <script type="application/javascript" |
|
14 src="chrome://mochikit/content/chrome-harness.js"></script> |
|
15 <script type="application/javascript" |
|
16 src="RegisterUnregisterChrome.js"></script> |
|
17 |
|
18 <body xmlns="http://www.w3.org/1999/xhtml"> |
|
19 <p id="display"></p> |
|
20 <div id="content" style="display: none"> |
|
21 </div> |
|
22 <pre id="test"> |
|
23 </pre> |
|
24 </body> |
|
25 |
|
26 <iframe id="subframe" width="100" height="100" onload="frameLoaded();"/> |
|
27 |
|
28 <script type="application/javascript"> |
|
29 <![CDATA[ |
|
30 |
|
31 SimpleTest.waitForExplicitFinish(); |
|
32 |
|
33 let prefs = Cc["@mozilla.org/preferences-service;1"]. |
|
34 getService(Ci.nsIPrefBranch); |
|
35 const UI_DIRECTION_PREF = "intl.uidirection.ar"; |
|
36 prefs.setCharPref(UI_DIRECTION_PREF, "rtl"); |
|
37 |
|
38 let rootDir = getRootDirectory(window.location.href); |
|
39 registerManifestPermanently(rootDir + "rtltest/righttoleft.manifest"); |
|
40 |
|
41 function runTest() |
|
42 { |
|
43 var subframe = document.getElementById("subframe"); |
|
44 subframe.setAttribute("src", "chrome://ltrtest/content/dirtest.xul"); |
|
45 } |
|
46 |
|
47 function frameLoaded() |
|
48 { |
|
49 var subframe = document.getElementById("subframe"); |
|
50 var subwin = subframe.contentWindow; |
|
51 var subdoc = subframe.contentDocument; |
|
52 var url = String(subwin.location); |
|
53 if (url.indexOf("chrome://ltrtest") == 0) { |
|
54 is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, |
|
55 "rgb(255, 255, 0)", "left to right with :-moz-locale-dir(ltr)"); |
|
56 is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, |
|
57 "rgb(255, 255, 255)", "left to right with :-moz-locale-dir(rtl)"); |
|
58 |
|
59 is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", |
|
60 "left to right direction"); |
|
61 |
|
62 subdoc.documentElement.setAttribute("localedir", "rtl"); |
|
63 |
|
64 is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, |
|
65 "rgb(255, 255, 255)", "left to right with :-moz-locale-dir(ltr) and localedir='rtl'"); |
|
66 is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, |
|
67 "rgb(0, 128, 0)", "left to right with :-moz-locale-dir(rtl) and localedir='rtl'"); |
|
68 is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "rtl", |
|
69 "left to right direction with localedir='rtl'"); |
|
70 |
|
71 subdoc.documentElement.removeAttribute("localedir"); |
|
72 |
|
73 is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, |
|
74 "rgb(255, 255, 0)", "left to right with :-moz-locale-dir(ltr) and localedir removed"); |
|
75 is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, |
|
76 "rgb(255, 255, 255)", "left to right with :-moz-locale-dir(rtl) and localedir removed"); |
|
77 is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", |
|
78 "left to right direction with localedir removed"); |
|
79 |
|
80 subframe.setAttribute("src", "chrome://rtltest/content/dirtest.xul"); |
|
81 } |
|
82 else if (url.indexOf("chrome://rtltest") == 0) { |
|
83 is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, |
|
84 "rgb(255, 255, 255)", "right to left with :-moz-locale-dir(ltr)"); |
|
85 is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, |
|
86 "rgb(0, 128, 0)", "right to left with :-moz-locale-dir(rtl)"); |
|
87 is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "rtl", |
|
88 "right to left direction"); |
|
89 |
|
90 subdoc.documentElement.setAttribute("localedir", "ltr"); |
|
91 |
|
92 is(subwin.getComputedStyle(subdoc.getElementById("hbox"), "").backgroundColor, |
|
93 "rgb(255, 255, 0)", "right to left with :-moz-locale-dir(ltr) and localedir='ltr'"); |
|
94 is(subwin.getComputedStyle(subdoc.getElementById("vbox"), "").backgroundColor, |
|
95 "rgb(255, 255, 255)", "right to left with :-moz-locale-dir(rtl) and localedir='ltr'"); |
|
96 is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", |
|
97 "right to left direction with localedir='ltr'"); |
|
98 |
|
99 subdoc.documentElement.removeAttribute("localedir"); |
|
100 |
|
101 prefs.setCharPref(UI_DIRECTION_PREF, ""); |
|
102 is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", |
|
103 "left to right direction with no preference set"); |
|
104 prefs.setCharPref(UI_DIRECTION_PREF + "-QA", "rtl"); |
|
105 is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "rtl", |
|
106 "right to left direction with more specific preference set"); |
|
107 prefs.setCharPref(UI_DIRECTION_PREF, "ltr"); |
|
108 is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "rtl", |
|
109 "right to left direction with less specific and more specific preference set"); |
|
110 prefs.setCharPref(UI_DIRECTION_PREF, "rtl"); |
|
111 prefs.setCharPref(UI_DIRECTION_PREF + "-QA", "ltr"); |
|
112 is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr", |
|
113 "left to right direction specific preference overrides"); |
|
114 if (prefs.prefHasUserValue(UI_DIRECTION_PREF + "-QA")) |
|
115 prefs.clearUserPref(UI_DIRECTION_PREF + "-QA"); |
|
116 |
|
117 if (prefs.prefHasUserValue(UI_DIRECTION_PREF)) |
|
118 prefs.clearUserPref(UI_DIRECTION_PREF); |
|
119 |
|
120 SimpleTest.finish(); |
|
121 } |
|
122 } |
|
123 ]]> |
|
124 </script> |
|
125 |
|
126 </window> |