Bug 1538968 - don't register link updates for localization links in system-principal docs, r=smaug
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Fri, 29 Mar 2019 16:01:37 +0000
changeset 466785 f7f9e20d71b78bdbd94d73d9ab3225b212a2be37
parent 466784 657dd79f0363df00daeb7873429a19c1fbb8028c
child 466786 9414b7e93b3570b3e4209992a3adf3c94e388dc1
push id35780
push useropoprus@mozilla.com
push dateFri, 29 Mar 2019 21:53:01 +0000
treeherdermozilla-central@414f37afbe07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1538968
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1538968 - don't register link updates for localization links in system-principal docs, r=smaug Differential Revision: https://phabricator.services.mozilla.com/D24909
dom/html/HTMLLinkElement.cpp
--- a/dom/html/HTMLLinkElement.cpp
+++ b/dom/html/HTMLLinkElement.cpp
@@ -113,28 +113,33 @@ bool HTMLLinkElement::HasDeferredDNSPref
 nsresult HTMLLinkElement::BindToTree(Document* aDocument, nsIContent* aParent,
                                      nsIContent* aBindingParent) {
   Link::ResetLinkState(false, Link::ElementHasHref());
 
   nsresult rv =
       nsGenericHTMLElement::BindToTree(aDocument, aParent, aBindingParent);
   NS_ENSURE_SUCCESS(rv, rv);
 
+  bool isLocalizationLink =
+      aDocument && this->AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel,
+                                     nsGkAtoms::localization, eIgnoreCase);
+
   if (Document* doc = GetComposedDoc()) {
-    doc->RegisterPendingLinkUpdate(this);
+    if (!isLocalizationLink || !doc->NodePrincipal()->IsSystemPrincipal()) {
+      doc->RegisterPendingLinkUpdate(this);
+    }
     TryDNSPrefetchOrPreconnectOrPrefetchOrPreloadOrPrerender();
   }
 
   void (HTMLLinkElement::*update)() =
       &HTMLLinkElement::UpdateStyleSheetInternal;
   nsContentUtils::AddScriptRunner(
       NewRunnableMethod("dom::HTMLLinkElement::BindToTree", this, update));
 
-  if (aDocument && this->AttrValueIs(kNameSpaceID_None, nsGkAtoms::rel,
-                                     nsGkAtoms::localization, eIgnoreCase)) {
+  if (isLocalizationLink) {
     aDocument->LocalizationLinkAdded(this);
   }
 
   CreateAndDispatchEvent(aDocument, NS_LITERAL_STRING("DOMLinkAdded"));
 
   return rv;
 }