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