author | Johann Hofmann <jhofmann@mozilla.com> |
Wed, 22 Aug 2018 13:30:04 +0000 | |
changeset 487942 | d99190a5b731a101fe1852a2fa7d9af69e6412f9 |
parent 487941 | 2331359b5aec0ec017616710a86d6f7bb0e60e46 |
child 487943 | 928dc169698aad907fe9fb9881340a4a88f76851 |
push id | 9719 |
push user | ffxbld-merge |
push date | Fri, 24 Aug 2018 17:49:46 +0000 |
treeherder | mozilla-beta@719ec98fba77 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | nhnt11 |
bugs | 1484259 |
milestone | 63.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
testing/mochitest/BrowserTestUtils/ContentTaskUtils.jsm | file | annotate | diff | comparison | revisions |
--- a/testing/mochitest/BrowserTestUtils/ContentTaskUtils.jsm +++ b/testing/mochitest/BrowserTestUtils/ContentTaskUtils.jsm @@ -15,16 +15,60 @@ var EXPORTED_SYMBOLS = [ "ContentTaskUtils", ]; ChromeUtils.import("resource://gre/modules/Timer.jsm"); var ContentTaskUtils = { /** + * Checks if a DOM element is hidden. + * + * @param {Element} element + * The element which is to be checked. + * + * @return {boolean} + */ + is_hidden(element) { + var style = element.ownerGlobal.getComputedStyle(element); + if (style.display == "none") + return true; + if (style.visibility != "visible") + return true; + + // Hiding a parent element will hide all its children + if (element.parentNode != element.ownerDocument) + return ContentTaskUtils.is_hidden(element.parentNode); + + return false; + }, + + /** + * Checks if a DOM element is visible. + * + * @param {Element} element + * The element which is to be checked. + * + * @return {boolean} + */ + is_visible(element) { + var style = element.ownerGlobal.getComputedStyle(element); + if (style.display == "none") + return false; + if (style.visibility != "visible") + return false; + + // Hiding a parent element will hide all its children + if (element.parentNode != element.ownerDocument) + return ContentTaskUtils.is_visible(element.parentNode); + + return true; + }, + + /** * Will poll a condition function until it returns true. * * @param condition * A condition function that must return true or false. If the * condition ever throws, this is also treated as a false. * @param msg * The message to use when the returned promise is rejected. * This message will be extended with additional information