Bug 1551320 - Don't allow CreateElement in XUL documents. r=bzbarsky
☠☠ backed out by 7047af39c5bb ☠ ☠
authorBrendan Dahl <bdahl@mozilla.com>
Mon, 20 May 2019 16:50:28 +0000
changeset 474616 b8b69c177520654c6707b7cc20d5cc0d3d310573
parent 474615 91837a92ccf50661a810bae5f130d049cb88a060
child 474617 adaa62b87e68c628582be6662ba35e5459441ef3
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;