michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: * http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function is_hidden(aElement) { michael@0: var style = aElement.ownerDocument.defaultView.getComputedStyle(aElement, ""); michael@0: if (style.display == "none") michael@0: return true; michael@0: if (style.visibility != "visible") michael@0: return true; michael@0: michael@0: // Hiding a parent element will hide all its children michael@0: if (aElement.parentNode != aElement.ownerDocument) michael@0: return is_hidden(aElement.parentNode); michael@0: michael@0: return false; michael@0: } michael@0: michael@0: function is_element_visible(aElement, aMsg) { michael@0: isnot(aElement, null, "Element should not be null, when checking visibility"); michael@0: ok(!is_hidden(aElement), aMsg); michael@0: } michael@0: michael@0: function is_element_hidden(aElement, aMsg) { michael@0: isnot(aElement, null, "Element should not be null, when checking visibility"); michael@0: ok(is_hidden(aElement), aMsg); michael@0: } michael@0: michael@0: function open_preferences(aCallback) { michael@0: gBrowser.selectedTab = gBrowser.addTab("about:preferences"); michael@0: let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab); michael@0: newTabBrowser.addEventListener("Initialized", function () { michael@0: newTabBrowser.removeEventListener("Initialized", arguments.callee, true); michael@0: aCallback(gBrowser.contentWindow); michael@0: }, true); michael@0: }