Commit 8e318ae1 authored by Andreas Tolfsen's avatar Andreas Tolfsen
Browse files

Bug 13954695 - Check discarded ChromeWindow in staleness test. r=me

HTML elements' ownerGlobal is a WindowProxy that indirects operations
to the current browsing context.  However, for XUL elements this global
is ChromeWindow which gets reset to null when the window is discarded.

For the same reason, since win indirects to the current browsing context's
associated window, we need to test that the element's node document is
not the active document.

Finally test that its shadow-including root is a document.

MozReview-Commit-ID: EYh18P8DbcN
parent 178ae7e0
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -624,8 +624,7 @@ element.generateUUID = function() {
 * Determines if <var>el</var> is stale.
 *
 * A stale element is an element no longer attached to the DOM or which
 * <code>ownerDocument</coded> is not the same as {@link WindowProxy}'s
 * document.
 * node document is not the active document.
 *
 * @param {Element} el
 *     DOM element to check for staleness.
@@ -636,8 +635,11 @@ element.generateUUID = function() {
element.isStale = function(el) {
  let doc = el.ownerDocument;
  let win = doc.defaultView;
  let sameDoc = el.ownerDocument === win.document;
  return !sameDoc || !el.isConnected;

  if (!win || el.ownerDocument !== win.document) {
    return true;
  }
  return !el.isConnected;
};

/**