Bug 1533883 - Use prototype for chrome privilege docs. r=smaug
authorBrendan Dahl <bdahl@mozilla.com>
Tue, 16 Apr 2019 18:27:52 +0000
changeset 469806 aeb8b8977e8e3470aa434f9bad99e78c4ee3bb31
parent 469805 70a566b541e084238195ec57a504154812b9ba6b
child 469807 2ccc88672342a7cd5708e6a984f62c71e4294a39
push id35883
push userbtara@mozilla.com
push dateWed, 17 Apr 2019 21:47:29 +0000
treeherdermozilla-central@02b89c29412b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1533883
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 1533883 - Use prototype for chrome privilege docs. r=smaug Instead of only allowing chrome docshells to use the document prototype, allow any chrome url with chrome privileges to use it. Differential Revision: https://phabricator.services.mozilla.com/D27744
dom/html/nsHTMLDocument.cpp
--- a/dom/html/nsHTMLDocument.cpp
+++ b/dom/html/nsHTMLDocument.cpp
@@ -440,22 +440,22 @@ void nsHTMLDocument::TryFallback(int32_t
                                  NotNull<const Encoding*>& aEncoding) {
   if (kCharsetFromFallback <= aCharsetSource) return;
 
   aCharsetSource = kCharsetFromFallback;
   aEncoding = FallbackEncoding::FromLocale();
 }
 
 // Using a prototype document is only allowed with chrome privilege.
-bool ShouldUsePrototypeDocument(nsIChannel* aChannel, nsIDocShell* aDocShell) {
-  if (!aChannel || !aDocShell ||
+bool ShouldUsePrototypeDocument(nsIChannel* aChannel, Document* aDoc) {
+  if (!aChannel || !aDoc ||
       !StaticPrefs::dom_prototype_document_cache_enabled()) {
     return false;
   }
-  if (aDocShell->ItemType() != nsIDocShellTreeItem::typeChrome) {
+  if (!nsContentUtils::IsChromeDoc(aDoc)) {
     return false;
   }
   nsCOMPtr<nsIURI> originalURI;
   aChannel->GetOriginalURI(getter_AddRefs(originalURI));
   return IsChromeURI(originalURI);
 }
 
 nsresult nsHTMLDocument::StartDocumentLoad(const char* aCommand,
@@ -554,17 +554,17 @@ nsresult nsHTMLDocument::StartDocumentLo
       } else {
         mParser->MarkAsNotScriptCreated("plain-text");
       }
     } else if (viewSource && !html) {
       mParser->MarkAsNotScriptCreated("view-source-xml");
     } else {
       mParser->MarkAsNotScriptCreated(aCommand);
     }
-  } else if (xhtml && ShouldUsePrototypeDocument(aChannel, docShell)) {
+  } else if (xhtml && ShouldUsePrototypeDocument(aChannel, this)) {
     loadWithPrototype = true;
     nsCOMPtr<nsIURI> originalURI;
     aChannel->GetOriginalURI(getter_AddRefs(originalURI));
     mParser = new mozilla::parser::PrototypeDocumentParser(originalURI, this);
   } else {
     mParser = do_CreateInstance(kCParserCID, &rv);
     NS_ENSURE_SUCCESS(rv, rv);
   }