Bug 1406505 - Fix element.isInView to use table cells instead of rows.
As long as
bug 1413493 has not been fixed the <tr> nodes will not be part
of the element tree. To workaround this problem we could use the first
found cell of the given row to check for visibility.
MozReview-Commit-ID: 57nuvxYrSMg
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -890,19 +890,27 @@ element.getContainer = function(el) {
* @param {Element} el
* Element to check if is in view.
*
* @return {boolean}
* True if <var>el</var> is inside the viewport, or false otherwise.
*/
element.isInView = function(el) {
let originalPointerEvents = el.style.pointerEvents;
+
try {
el.style.pointerEvents = "auto";
const tree = element.getPointerInteractablePaintTree(el);
+
+ // Bug 1413493 - <tr> is not part of the returned paint tree yet. As
+ // workaround check the visibility based on the first contained cell.
+ if (el.localName === "tr" && el.cells && el.cells.length > 0) {
+ return tree.includes(el.cells[0]);
+ }
+
return tree.includes(el);
} finally {
el.style.pointerEvents = originalPointerEvents;
}
};
/**
* This function throws the visibility of the element error if the element is
--- a/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
+++ b/testing/marionette/harness/marionette_harness/tests/unit/test_click.py
@@ -249,16 +249,27 @@ class TestClick(TestLegacyClick):
self.marionette.navigate(inline("""
<select style="margin-top: 100vh">
<option>foo</option>
</select>"""))
option = self.marionette.find_element(By.TAG_NAME, "option")
option.click()
self.assertTrue(option.get_property("selected"))
+ def test_table_tr(self):
+ self.marionette.navigate(inline("""
+ <table>
+ <tr><td onclick="window.clicked = true;">
+ foo
+ </td></tr>
+ </table>"""))
+ tr = self.marionette.find_element(By.TAG_NAME, "tr")
+ tr.click()
+ self.assertTrue(self.marionette.execute_script("return window.clicked", sandbox=None))
+
def test_obscured_element(self):
self.marionette.navigate(obscured_overlay)
overlay = self.marionette.find_element(By.ID, "overlay")
obscured = self.marionette.find_element(By.ID, "obscured")
overlay.click()
with self.assertRaises(errors.ElementClickInterceptedException):
obscured.click()