diff --git a/javascript/atoms/dom.js b/javascript/atoms/dom.js index 1d2495ae49d60..f738dafd4526f 100644 --- a/javascript/atoms/dom.js +++ b/javascript/atoms/dom.js @@ -559,6 +559,12 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) { throw new Error('Argument to isShown must be of type Element'); } + // By convention, BODY element is always shown: BODY represents the document + // and even if there's nothing rendered in there, user can always see there's the document. + if (bot.dom.isElement(elem, goog.dom.TagName.BODY)) { + return true; + } + // Option or optgroup is shown iff enclosing select is shown (ignoring the // select's opacity). if (bot.dom.isElement(elem, goog.dom.TagName.OPTION) || diff --git a/javascript/atoms/test/shown_test.html b/javascript/atoms/test/shown_test.html index 369542065a7d8..a42e0a1407b03 100644 --- a/javascript/atoms/test/shown_test.html +++ b/javascript/atoms/test/shown_test.html @@ -40,9 +40,9 @@ expectedFailures = new goog.testing.ExpectedFailures(); } - function tearDown() { expectedFailures.handleTearDown(); + goog.style.setStyle(document.body, 'display', 'block'); goog.style.setStyle(document.body, 'overflow', 'auto'); } @@ -52,6 +52,15 @@ }); } + function testBodyShown() { + assertTrue(isShown(document.body)); + } + + function testBodyAlwaysShown() { + goog.style.setStyle(document.body, 'display', 'none'); + assertTrue("BODY element must *always* be shown", isShown(document.body)); + } + function testCanDetermineIfAnElementIsShownOrNot() { assertTrue(isShown(findElement({id: 'displayed'}))); assertFalse(isShown(findElement({id: 'none'})));