Bug 1425866: Just null-check the CSS Loader for now. r?heycam draft
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 27 Apr 2018 01:46:50 +0200
changeset 788761 1427978bc7c62ccf214a39dbf3f7d3a404ce36e2
parent 788760 c1c9799b890613f9911fdefa75df4f8e9021b9c4
push id108085
push userbmo:emilio@crisal.io
push dateThu, 26 Apr 2018 23:49:30 +0000
reviewersheycam
bugs1425866
milestone61.0a1
Bug 1425866: Just null-check the CSS Loader for now. r?heycam After discussing with Olli there isn't any kind of severe problem out of this. Shadow subtrees will be disconnected just like the rest, and they shouldn't assume that the document hasn't been disconnected first. MozReview-Commit-ID: CX4fXOqEIFj
dom/base/nsStyleLinkElement.cpp
--- a/dom/base/nsStyleLinkElement.cpp
+++ b/dom/base/nsStyleLinkElement.cpp
@@ -251,17 +251,18 @@ nsStyleLinkElement::DoUpdateStyleSheet(n
   // When static documents are created, stylesheets are cloned manually.
   if (mDontLoadStyle || !mUpdatesEnabled ||
       thisContent->OwnerDoc()->IsStaticDocument()) {
     return Update { };
   }
 
   nsCOMPtr<nsIDocument> doc = thisContent->IsInShadowTree() ?
     thisContent->OwnerDoc() : thisContent->GetUncomposedDoc();
-  if (!doc || !doc->CSSLoader()->GetEnabled()) {
+  // Loader could be null during unlink, see bug 1425866.
+  if (!doc || !doc->CSSLoader() || !doc->CSSLoader()->GetEnabled()) {
     return Update { };
   }
 
   bool isInline;
   nsCOMPtr<nsIPrincipal> triggeringPrincipal;
   nsCOMPtr<nsIURI> uri = GetStyleSheetURL(&isInline, getter_AddRefs(triggeringPrincipal));
 
   if (aForceUpdate == ForceUpdate::No && mStyleSheet && !isInline && uri) {