959bf37
# HG changeset patch
959bf37
# User Emilio Cobos Alvarez <emilio@crisal.io>
959bf37
# Date 1524786410 -7200
959bf37
# Node ID a42293258ab3dffb794f3a1e8fe2c3937dd81bb5
959bf37
# Parent  18e58f90f23b4ee1d14078787e2409bd80eba945
959bf37
Bug 1425866: Just null-check the CSS Loader for now. r=heycam
959bf37
959bf37
After discussing with Olli there isn't any kind of severe problem out of this.
959bf37
Shadow subtrees will be disconnected just like the rest, and they shouldn't
959bf37
assume that the document hasn't been disconnected first.
959bf37
959bf37
MozReview-Commit-ID: CX4fXOqEIFj
959bf37
959bf37
diff --git a/dom/base/nsStyleLinkElement.cpp b/dom/base/nsStyleLinkElement.cpp
959bf37
--- a/dom/base/nsStyleLinkElement.cpp
959bf37
+++ b/dom/base/nsStyleLinkElement.cpp
959bf37
@@ -254,17 +254,18 @@ nsStyleLinkElement::DoUpdateStyleSheet(n
959bf37
   // When static documents are created, stylesheets are cloned manually.
959bf37
   if (mDontLoadStyle || !mUpdatesEnabled ||
959bf37
       thisContent->OwnerDoc()->IsStaticDocument()) {
959bf37
     return Update { };
959bf37
   }
959bf37
 
959bf37
   nsCOMPtr<nsIDocument> doc = thisContent->IsInShadowTree() ?
959bf37
     thisContent->OwnerDoc() : thisContent->GetUncomposedDoc();
959bf37
-  if (!doc || !doc->CSSLoader()->GetEnabled()) {
959bf37
+  // Loader could be null during unlink, see bug 1425866.
959bf37
+  if (!doc || !doc->CSSLoader() || !doc->CSSLoader()->GetEnabled()) {
959bf37
     return Update { };
959bf37
   }
959bf37
 
959bf37
   bool isInline;
959bf37
   nsCOMPtr<nsIPrincipal> triggeringPrincipal;
959bf37
   nsCOMPtr<nsIURI> uri = GetStyleSheetURL(&isInline, getter_AddRefs(triggeringPrincipal));
959bf37
   if (aForceUpdate == ForceUpdate::No && mStyleSheet && !isInline && uri) {
959bf37
     if (nsIURI* oldURI = mStyleSheet->GetSheetURI()) {