browser/components/tabview/test/browser_tabview_rtl.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/tabview/test/browser_tabview_rtl.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,46 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 +   http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +// ----------
     1.8 +function test() {
     1.9 +  waitForExplicitFinish();
    1.10 +
    1.11 +  // verify initial state
    1.12 +  ok(!TabView.isVisible(), "Tab View starts hidden");
    1.13 +
    1.14 +  showTabView(onTabViewLoadedAndShown("ltr"));
    1.15 +}
    1.16 +
    1.17 +// ----------
    1.18 +function onTabViewLoadedAndShown(dir) {
    1.19 +  return function() {
    1.20 +    ok(TabView.isVisible(), "Tab View is visible.");
    1.21 +
    1.22 +    let contentWindow = document.getElementById("tab-view").contentWindow;
    1.23 +    let contentDocument = contentWindow.document;
    1.24 +    is(contentDocument.documentElement.getAttribute("dir"), dir,
    1.25 +       "The direction should be set to " + dir.toUpperCase());
    1.26 +
    1.27 +    // kick off the series
    1.28 +    hideTabView(onTabViewHidden(dir));
    1.29 +  };
    1.30 +}
    1.31 +
    1.32 +// ---------- 
    1.33 +function onTabViewHidden(dir) {
    1.34 +  return function() {
    1.35 +    ok(!TabView.isVisible(), "Tab View is hidden.");
    1.36 +
    1.37 +    if (dir == "ltr") {
    1.38 +      // Switch to RTL mode
    1.39 +      Services.prefs.setCharPref("intl.uidirection.en-US", "rtl");
    1.40 +
    1.41 +      showTabView(onTabViewLoadedAndShown("rtl"));
    1.42 +    } else {
    1.43 +      // Switch to LTR mode
    1.44 +      Services.prefs.clearUserPref("intl.uidirection.en-US");
    1.45 +
    1.46 +      finish();
    1.47 +    }
    1.48 +  };
    1.49 +}

mercurial