Bug 1359054 - Take shadow DOM into account when getting paint tree; r?maja_zf draft
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 17 Apr 2017 17:51:13 +0100
changeset 567142 c74bbd6d7b319da1edb50c54453ef12c3b7a7916
parent 567113 e17cbb839dd225a2da7e5d5bec43cf94e11749d8
child 625545 906915b4b2ef23b995d4f022672e3494695bca0c
push id55465
push userbmo:ato@mozilla.com
push dateMon, 24 Apr 2017 13:39:49 +0000
reviewersmaja_zf
bugs1359054
milestone55.0a1
Bug 1359054 - Take shadow DOM into account when getting paint tree; r?maja_zf We want to take shadow DOM into account when getting an element's pointer-interactable paint tree. Marionette is currently unable to determine if an element inside a shadow DOM host is disconnected from the document because we are constructing the frame container with only the main document. MozReview-Commit-ID: IPDi8fQZYRP
testing/marionette/element.js
--- a/testing/marionette/element.js
+++ b/testing/marionette/element.js
@@ -990,19 +990,27 @@ element.getInViewCentrePoint = function 
  *     Element to determine if is pointer-interactable.
  *
  * @return {Array.<DOMElement>}
  *     Sequence of elements in paint order.
  */
 element.getPointerInteractablePaintTree = function (el) {
   const doc = el.ownerDocument;
   const win = doc.defaultView;
+  const container = {frame: win};
+  const rootNode = el.getRootNode();
+
+  // Include shadow DOM host only if the element's root node is not the
+  // owner document.
+  if (rootNode !== doc) {
+    container.shadowRoot = rootNode;
+  }
 
   // pointer-interactable elements tree, step 1
-  if (element.isDisconnected(el, {frame: win})) {
+  if (element.isDisconnected(el, container)) {
     return [];
   }
 
   // steps 2-3
   let rects = el.getClientRects();
   if (rects.length == 0) {
     return [];
   }