toolkit/content/tests/chrome/test_righttoleft.xul

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

     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"?>
     7 <window title="Right to Left UI Test"
     8         onload="runTest()"
     9         xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    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>
    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>
    26   <iframe id="subframe" width="100" height="100" onload="frameLoaded();"/>
    28   <script type="application/javascript">
    29     <![CDATA[
    31       SimpleTest.waitForExplicitFinish();
    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");
    38       let rootDir = getRootDirectory(window.location.href);
    39       registerManifestPermanently(rootDir + "rtltest/righttoleft.manifest");
    41       function runTest()
    42       {
    43         var subframe = document.getElementById("subframe");
    44         subframe.setAttribute("src", "chrome://ltrtest/content/dirtest.xul");
    45       }
    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)");
    59           is(subwin.getComputedStyle(subdoc.documentElement, "").direction, "ltr",
    60              "left to right direction");
    62           subdoc.documentElement.setAttribute("localedir", "rtl");
    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'");
    71           subdoc.documentElement.removeAttribute("localedir");
    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");
    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");
    90           subdoc.documentElement.setAttribute("localedir", "ltr");
    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'");
    99           subdoc.documentElement.removeAttribute("localedir");
   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");
   117           if (prefs.prefHasUserValue(UI_DIRECTION_PREF))
   118             prefs.clearUserPref(UI_DIRECTION_PREF);
   120           SimpleTest.finish();
   121         }
   122       }
   123     ]]>
   124   </script>
   126 </window>

mercurial