Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | * http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | function is_hidden(aElement) { |
michael@0 | 5 | var style = aElement.ownerDocument.defaultView.getComputedStyle(aElement, ""); |
michael@0 | 6 | if (style.display == "none") |
michael@0 | 7 | return true; |
michael@0 | 8 | if (style.visibility != "visible") |
michael@0 | 9 | return true; |
michael@0 | 10 | |
michael@0 | 11 | // Hiding a parent element will hide all its children |
michael@0 | 12 | if (aElement.parentNode != aElement.ownerDocument) |
michael@0 | 13 | return is_hidden(aElement.parentNode); |
michael@0 | 14 | |
michael@0 | 15 | return false; |
michael@0 | 16 | } |
michael@0 | 17 | |
michael@0 | 18 | function is_element_visible(aElement, aMsg) { |
michael@0 | 19 | isnot(aElement, null, "Element should not be null, when checking visibility"); |
michael@0 | 20 | ok(!is_hidden(aElement), aMsg); |
michael@0 | 21 | } |
michael@0 | 22 | |
michael@0 | 23 | function is_element_hidden(aElement, aMsg) { |
michael@0 | 24 | isnot(aElement, null, "Element should not be null, when checking visibility"); |
michael@0 | 25 | ok(is_hidden(aElement), aMsg); |
michael@0 | 26 | } |
michael@0 | 27 | |
michael@0 | 28 | function open_preferences(aCallback) { |
michael@0 | 29 | gBrowser.selectedTab = gBrowser.addTab("about:preferences"); |
michael@0 | 30 | let newTabBrowser = gBrowser.getBrowserForTab(gBrowser.selectedTab); |
michael@0 | 31 | newTabBrowser.addEventListener("Initialized", function () { |
michael@0 | 32 | newTabBrowser.removeEventListener("Initialized", arguments.callee, true); |
michael@0 | 33 | aCallback(gBrowser.contentWindow); |
michael@0 | 34 | }, true); |
michael@0 | 35 | } |