Skip to content

Commit 039b6a4

Browse files
committed
BODY element is always shown/displayed.
related section in the W3C spec: https://dvcs.w3.org/hg/webdriver/raw-file/default/webdriver-spec.html#determining-if-an-element-is-displayed
1 parent 9292f01 commit 039b6a4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

javascript/atoms/dom.js

+6
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,12 @@ bot.dom.isShown = function(elem, opt_ignoreOpacity) {
559559
throw new Error('Argument to isShown must be of type Element');
560560
}
561561

562+
// By convention, BODY element is always shown: BODY represents the document
563+
// and even if there's nothing rendered in there, user can always see there's the document.
564+
if (bot.dom.isElement(elem, goog.dom.TagName.BODY)) {
565+
return true;
566+
}
567+
562568
// Option or optgroup is shown iff enclosing select is shown (ignoring the
563569
// select's opacity).
564570
if (bot.dom.isElement(elem, goog.dom.TagName.OPTION) ||

javascript/atoms/test/shown_test.html

+10-1
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
expectedFailures = new goog.testing.ExpectedFailures();
4141
}
4242

43-
4443
function tearDown() {
4544
expectedFailures.handleTearDown();
45+
goog.style.setStyle(document.body, 'display', 'block');
4646
goog.style.setStyle(document.body, 'overflow', 'auto');
4747
}
4848

@@ -52,6 +52,15 @@
5252
});
5353
}
5454

55+
function testBodyShown() {
56+
assertTrue(isShown(document.body));
57+
}
58+
59+
function testBodyAlwaysShown() {
60+
goog.style.setStyle(document.body, 'display', 'none');
61+
assertTrue("BODY element must *always* be shown", isShown(document.body));
62+
}
63+
5564
function testCanDetermineIfAnElementIsShownOrNot() {
5665
assertTrue(isShown(findElement({id: 'displayed'})));
5766
assertFalse(isShown(findElement({id: 'none'})));

0 commit comments

Comments
 (0)