browser/components/preferences/in-content/tests/head.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/browser/components/preferences/in-content/tests/head.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,35 @@
     1.4 +/* Any copyright is dedicated to the Public Domain.
     1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */
     1.6 +
     1.7 +function is_hidden(aElement) {
     1.8 +  var style = aElement.ownerDocument.defaultView.getComputedStyle(aElement, "");
     1.9 +  if (style.display == "none")
    1.10 +    return true;
    1.11 +  if (style.visibility != "visible")
    1.12 +    return true;
    1.13 +
    1.14 +  // Hiding a parent element will hide all its children
    1.15 +  if (aElement.parentNode != aElement.ownerDocument)
    1.16 +    return is_hidden(aElement.parentNode);
    1.17 +
    1.18 +  return false;
    1.19 +}
    1.20 +
    1.21 +function is_element_visible(aElement, aMsg) {
    1.22 +  isnot(aElement, null, "Element should not be null, when checking visibility");
    1.23 +  ok(!is_hidden(aElement), aMsg);
    1.24 +}
    1.25 +
    1.26 +function is_element_hidden(aElement, aMsg) {
    1.27 +  isnot(aElement, null, "Element should not be null, when checking visibility");
    1.28 +  ok(is_hidden(aElement), aMsg);
    1.29 +}
    1.30 +
    1.31 +function open_preferences(aCallback) {
    1.32 +  gBrowser.selectedTab = gBrowser.addTab("about:preferences");
    1.33 +  let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab);
    1.34 +  newTabBrowser.addEventListener("Initialized", function () {
    1.35 +    newTabBrowser.removeEventListener("Initialized", arguments.callee, true);
    1.36 +    aCallback(gBrowser.contentWindow);
    1.37 +  }, true);
    1.38 +}

mercurial