Bug 1551320 - Don't allow CreateElement in XUL documents. r=bzbarsky
☠☠ backed out by 31a636751e55 ☠ ☠
authorBrendan Dahl <bdahl@mozilla.com>
Thu, 16 May 2019 07:12:15 +0000
changeset 474545 d19dbdb939af89443317fc7a2b26c64f44569d56
parent 474544 307d9921bdf21a8943f26ebba9a3b0c08ebc3cf9
child 474546 4a73759aafa6f3168453b2765f9b13e5fdc640d3
push id36042
push userdvarga@mozilla.com
push dateTue, 21 May 2019 04:19:40 +0000
treeherdermozilla-central@ca560ff55451 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs1551320
milestone69.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 1551320 - Don't allow CreateElement in XUL documents. r=bzbarsky Soon XUL documents will be loaded as XHTML and createElement will create HTML elements instead of XUL element by default. This restriction can be removed once we migrate everything. Differential Revision: https://phabricator.services.mozilla.com/D31294
dom/base/Document.cpp
--- a/dom/base/Document.cpp
+++ b/dom/base/Document.cpp
@@ -5478,16 +5478,24 @@ static PseudoStyleType GetPseudoElementT
 already_AddRefed<Element> Document::CreateElement(
     const nsAString& aTagName, const ElementCreationOptionsOrString& aOptions,
     ErrorResult& rv) {
   rv = nsContentUtils::CheckQName(aTagName, false);
   if (rv.Failed()) {
     return nullptr;
   }
 
+  // Temporary check until XULDocument has been removed.
+  if (IsXULDocument()) {
+    MOZ_DIAGNOSTIC_ASSERT(false,
+                          "CreateElement() not allowed in XUL document.");
+    rv.Throw(NS_ERROR_FAILURE);
+    return nullptr;
+  }
+
   bool needsLowercase = IsHTMLDocument() && !IsLowercaseASCII(aTagName);
   nsAutoString lcTagName;
   if (needsLowercase) {
     nsContentUtils::ASCIIToLower(aTagName, lcTagName);
   }
 
   const nsString* is = nullptr;
   PseudoStyleType pseudoType = PseudoStyleType::NotPseudo;