Bug 1546338 - Port [Bug 1551320 - In XUL documents replace all callers of createElement with createXULElement]. r=jorgk
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Thu, 16 May 2019 15:21:51 +0300
changeset 26632 7e3a1808d30d74cd63009b3a518d417566dd206d
parent 26631 88f230af325e08d0a148c8c04fb691c92b58e600
child 26633 8e708fca38cc203419b6b41158bf6c2b32e64ba1
push id15930
push usermozilla@jorgk.com
push dateFri, 17 May 2019 16:33:06 +0000
treeherdercomm-central@7e3a1808d30d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1546338, 1551320
Bug 1546338 - Port [Bug 1551320 - In XUL documents replace all callers of createElement with createXULElement]. r=jorgk find . -type f -not -path "*.hg/*" -not -path "*suite/*" -not -path "./chat/protocols/matrix/matrix-sdk/*" -not -path "./mail/components/about-support/*" -not -path "./mail/components/newmailaccount/content/*" -not -path "./mailnews/extensions/newsblog/content/*" -not -path "./mailnews/extensions/newsblog/content/*" -name '*.js' -exec sed -r -i '/React.|("(iframe|div|hr|img|title|a|li|ol|ul|h2|h3|facet-result-message|facet-boolean|facet-boolean-filtered| facet-discrete|select|option|canvas|strong|td|tr|tbody|pre|span|head|meta|map|area|table|caption|p|br|b))"/! s/createElement[(]/createXULElement(/g' {} \;
calendar/base/content/agenda-listbox-utils.js
calendar/base/content/agenda-listbox.js
calendar/base/content/calendar-base-view.js
calendar/base/content/calendar-event-gripbar.js
calendar/base/content/calendar-task-view.js
calendar/base/content/calendar-ui-utils.js
calendar/base/content/dialogs/calendar-alarm-dialog.js
calendar/base/content/dialogs/calendar-event-dialog-attendees-custom-elements.js
calendar/base/content/dialogs/calendar-migration-dialog.js
calendar/base/content/dialogs/chooseCalendarDialog.js
calendar/base/content/preferences/categories.js
calendar/lightning/content/lightning-item-iframe.js
calendar/providers/gdata/content/gdata-calendar-creation.js
calendar/providers/gdata/content/gdata-event-dialog.js
calendar/providers/gdata/content/gdata-migration.js
calendar/resources/content/datetimepickers/datetimepickers.js
calendar/resources/content/mouseoverPreviews.js
chat/content/conversation-browser.js
chat/content/imAccountOptionsHelper.js
common/src/browser-development-helpers.js
common/src/viewSource.js
editor/ui/composer/content/StructBarContextMenu.js
editor/ui/composer/content/editingOverlay.js
editor/ui/dialogs/content/EdDialogCommon.js
mail/base/content/FilterListDialog.js
mail/base/content/aboutAddonsExtra.js
mail/base/content/folderPane.js
mail/base/content/foldersummary.js
mail/base/content/glodaFacet.js
mail/base/content/mailCore.js
mail/base/content/mailWidgets.js
mail/base/content/mailWindowOverlay.js
mail/base/content/msgHdrView.js
mail/base/content/specialTabs.js
mail/base/content/statuspanel.js
mail/components/accountcreation/content/emailWizard.js
mail/components/activity/content/activity.js
mail/components/addrbook/content/abCard.js
mail/components/addrbook/content/abCardView.js
mail/components/addrbook/content/menulist-addrbooks.js
mail/components/compose/content/MsgComposeCommands.js
mail/components/compose/content/addressingWidgetOverlay.js
mail/components/downloads/content/aboutDownloads.js
mail/components/im/content/chat-group.js
mail/components/im/content/chat-messenger.js
mail/components/im/content/imAccountWizard.js
mail/components/im/content/imAccounts.js
mail/components/im/content/imContextMenu.js
mail/components/im/content/joinchat.js
mail/components/migration/content/migration.js
mail/components/preferences/advanced.js
mail/components/preferences/applicationManager.js
mail/components/preferences/applications.js
mail/components/preferences/chat.js
mail/components/preferences/messagestyle.js
mail/components/preferences/messengerLanguages.js
mail/components/preferences/preferences.js
mail/components/preferences/sendoptions.js
mail/extensions/mailviews/content/msgViewPickerOverlay.js
mailnews/addrbook/content/map-list.js
mailnews/addrbook/prefs/content/pref-editdirectories.js
mailnews/base/content/menulist-charsetpicker.js
mailnews/base/content/msgPrintEngine.js
mailnews/base/prefs/content/AccountManager.js
mailnews/base/prefs/content/am-identities-list.js
mailnews/base/prefs/content/am-junk.js
mailnews/base/prefs/content/am-smtp.js
mailnews/base/search/content/FilterEditor.js
mailnews/base/search/content/searchTerm.js
mailnews/base/search/content/searchWidgets.js
mailnews/base/util/JXON.js
mailnews/db/gloda/content/autocomplete-richlistitem.js
mailnews/extensions/smime/content/certpicker.js
mailnews/extensions/smime/content/msgCompSecurityInfo.js
mailnews/import/content/fieldMapImport.js
mailnews/import/content/importDialog.js
--- a/calendar/base/content/agenda-listbox-utils.js
+++ b/calendar/base/content/agenda-listbox-utils.js
@@ -282,19 +282,19 @@ agendaListbox.getEnd = function() {
  * @param aAgendaItem   The existing item to insert before.
  * @param aPeriod       The period to add the item to.
  * @param visible       If true, the item should be visible.
  * @return              The newly created XUL element.
  */
 agendaListbox.addItemBefore = function(aNewItem, aAgendaItem, aPeriod, visible) {
     let newelement = null;
     if (aNewItem.startDate.isDate) {
-        newelement = document.createElement("richlistitem", { is: "agenda-allday-richlist-item" });
+        newelement = document.createXULElement("richlistitem", { is: "agenda-allday-richlist-item" });
     } else {
-        newelement = document.createElement("richlistitem", { is: "agenda-richlist-item" });
+        newelement = document.createXULElement("richlistitem", { is: "agenda-richlist-item" });
     }
     // set the item at the richlistItem. When the duration of the period
     // is bigger than 1 (day) the starttime of the item has to include
     // information about the day of the item
     if (aAgendaItem == null) {
         this.agendaListboxControl.appendChild(newelement);
     } else {
         this.agendaListboxControl.insertBefore(newelement, aAgendaItem);
--- a/calendar/base/content/agenda-listbox.js
+++ b/calendar/base/content/agenda-listbox.js
@@ -17,17 +17,17 @@
         static get inheritedAttributes() {
             return { ".agenda-checkbox": "selected,label,hidden,disabled" };
         }
 
         connectedCallback() {
             if (this.delayConnectedCallback() || this.hasChildNodes()) {
                 return;
             }
-            this.kCheckbox = document.createElement("checkbox");
+            this.kCheckbox = document.createXULElement("checkbox");
             this.kCheckbox.classList.add("agenda-checkbox", "treenode-checkbox");
             this.appendChild(this.kCheckbox);
 
             this.dispatchEvent(new CustomEvent("bindingattached", { bubbles: false }));
             this.initializeAttributeInheritance();
         }
 
         getItem() {
--- a/calendar/base/content/calendar-base-view.js
+++ b/calendar/base/content/calendar-base-view.js
@@ -12,20 +12,20 @@ class MozCalendarDayLabel extends MozXUL
     connectedCallback() {
         if (this.delayConnectedCallback()) {
             return;
         }
         this.textContent = "";
         this.setAttribute("flex", "1");
         this.setAttribute("pack", "center");
 
-        this.longWeekdayName = document.createElement("label");
+        this.longWeekdayName = document.createXULElement("label");
         this.longWeekdayName.classList.add("calendar-day-label-name");
 
-        this.shortWeekdayName = document.createElement("label");
+        this.shortWeekdayName = document.createXULElement("label");
         this.shortWeekdayName.classList.add("calendar-day-label-name");
         this.shortWeekdayName.setAttribute("hidden", "true");
 
         this.appendChild(this.longWeekdayName);
         this.appendChild(this.shortWeekdayName);
 
         this.mWeekday = -1;
 
--- a/calendar/base/content/calendar-event-gripbar.js
+++ b/calendar/base/content/calendar-event-gripbar.js
@@ -36,17 +36,17 @@ class MozCalendarEventGripbar extends Mo
             }
             // parent event-column has event listner for click so
             // stopPropagation() is called.
             event.stopPropagation();
         });
     }
 
     connectedCallback() {
-        this._image = document.createElement("image");
+        this._image = document.createXULElement("image");
         this._image.setAttribute("pack", "center");
 
         this.appendChild(this._image);
 
         this.parentorient = this.getAttribute("parentorient");
     }
 
     /**
--- a/calendar/base/content/calendar-task-view.js
+++ b/calendar/base/content/calendar-task-view.js
@@ -175,27 +175,27 @@ var taskDetailsView = {
         cal.l10n.sortArrayByLocaleCollator(categoryList);
 
         let maxCount = item.calendar.getProperty("capabilities.categories.maxCount");
 
         while (categoryPopup.childElementCount > 2) {
             categoryPopup.lastElementChild.remove();
         }
         if (maxCount == 1) {
-            let menuitem = document.createElement("menuitem");
+            let menuitem = document.createXULElement("menuitem");
             menuitem.setAttribute("class", "menuitem-iconic");
             menuitem.setAttribute("label", cal.l10n.getCalString("None"));
             menuitem.setAttribute("type", "radio");
             if (itemCategories.length === 0) {
                 menuitem.setAttribute("checked", "true");
             }
             categoryPopup.appendChild(menuitem);
         }
         for (let cat of categoryList) {
-            let menuitem = document.createElement("menuitem");
+            let menuitem = document.createXULElement("menuitem");
             menuitem.setAttribute("class", "menuitem-iconic calendar-category");
             menuitem.setAttribute("label", cat);
             menuitem.setAttribute("value", cat);
             menuitem.setAttribute("type", (maxCount === null || maxCount > 1) ? "checkbox" : "radio");
             if (itemCategories.includes(cat)) {
                 menuitem.setAttribute("checked", "true");
             }
             categoryPopup.appendChild(menuitem);
@@ -286,17 +286,17 @@ var taskDetailsView = {
         } else {
             let localeCollator = cal.l10n.createLocaleCollator();
             let compare = localeCollator.compareString.bind(localeCollator, 0);
             newIndex = cal.data.binaryInsert(categories, category, compare, true);
 
             let item = document.getElementById("calendar-task-tree").currentTask;
             let maxCount = item.calendar.getProperty("capabilities.categories.maxCount");
 
-            let menuitem = document.createElement("menuitem");
+            let menuitem = document.createXULElement("menuitem");
             menuitem.setAttribute("class", "menuitem-iconic calendar-category");
             menuitem.setAttribute("label", category);
             menuitem.setAttribute("value", category);
             menuitem.setAttribute("type", (maxCount === null || maxCount > 1) ? "checkbox" : "radio");
             menuitem.setAttribute("checked", true);
             categoryPopup.insertBefore(menuitem, categoryList[newIndex]);
 
             modified = true;
--- a/calendar/base/content/calendar-ui-utils.js
+++ b/calendar/base/content/calendar-ui-utils.js
@@ -720,17 +720,17 @@ function setupAttendanceMenu(aMenu, aIte
                     switch (item.nodeName) {
                         case "menu": {
                             // Since menu elements cannot have checkmarks,
                             // we add a menuitem for this partstat and hide
                             // the menu element instead
                             let checkedId = "checked-" + item.getAttribute("id");
                             if (!document.getElementById(checkedId)) {
                                 let checked = item.ownerDocument
-                                                  .createElement("menuitem");
+                                                  .createXULElement("menuitem");
                                 checked.setAttribute("type", "checkbox");
                                 checked.setAttribute("checked", "true");
                                 checked.setAttribute("label",
                                                      item.getAttribute("label"));
                                 checked.setAttribute("value",
                                                      item.getAttribute("value"));
                                 checked.setAttribute("scope",
                                                      item.getAttribute("scope"));
--- a/calendar/base/content/dialogs/calendar-alarm-dialog.js
+++ b/calendar/base/content/dialogs/calendar-alarm-dialog.js
@@ -287,17 +287,17 @@ function widgetAlarmComptor(aItem, aWidg
 
 /**
  * Add an alarm widget for the passed alarm and item.
  *
  * @param aItem       The calendar item to add a widget for.
  * @param aAlarm      The alarm to add a widget for.
  */
 function addWidgetFor(aItem, aAlarm) {
-    let widget = document.createElement("calendar-alarm-widget");
+    let widget = document.createXULElement("calendar-alarm-widget");
     let alarmRichlist = document.getElementById("alarm-richlist");
 
     // Add widgets sorted by start date ascending
     cal.data.binaryInsertNode(alarmRichlist, widget, aItem, widgetAlarmComptor, false);
 
     widget.item = aItem;
     widget.alarm = aAlarm;
     widget.addEventListener("snooze", onSnoozeAlarm);
--- a/calendar/base/content/dialogs/calendar-event-dialog-attendees-custom-elements.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog-attendees-custom-elements.js
@@ -1101,21 +1101,21 @@ class MozCalendarEventAttendeesList exte
     }
 
     /**
      * Creates dummy item.
      *
      * @returns {Node}       Dummy item
      */
     createDummyItem() {
-        let titem = document.createElement("richlistitem");
+        let titem = document.createXULElement("richlistitem");
         titem.setAttribute("_isDummyRow", "true");
         titem.setAttribute("class", "dummy-row");
         for (let i = this.mNumColumns; i > 0; i--) {
-            let cell = document.createElement("hbox");
+            let cell = document.createXULElement("hbox");
             cell.setAttribute("class", "addressingWidgetCell dummy-row-cell");
             titem.appendChild(cell);
         }
         this.appendChild(titem);
         return titem;
     }
 
     /**
@@ -1384,19 +1384,19 @@ customElements.define("calendar-event-at
 /**
  * MozCalendarEventFreebusyRow is a widget that represents a row in freebusy-grid element.
  *
  * @extends {MozXULElement}
  */
 class MozCalendarEventFreebusyRow extends MozXULElement {
     connectedCallback() {
         if (!this.hasChildNodes()) {
-            this.containerNodeElem = document.createElement("calendar-event-scroll-container");
+            this.containerNodeElem = document.createXULElement("calendar-event-scroll-container");
             this.containerNodeElem.setAttribute("flex", "1");
-            this.hoursNodeElem = document.createElement("box");
+            this.hoursNodeElem = document.createXULElement("box");
             this.hoursNodeElem.setAttribute("equalsize", "always");
             this.containerNodeElem.appendChild(this.hoursNodeElem);
             this.appendChild(this.containerNodeElem);
         }
 
         this.state = null;
         this.Entries = null;
         this.offset = 0;
@@ -1849,24 +1849,24 @@ customElements.define("calendar-event-fr
  * MozFreebusyDay is a widget showing time slots labels - dates and a number of times instances of a
  * particular day.
  *
  * @extends {MozXULElement}
  */
 class MozCalendarEventFreebusyDay extends MozXULElement {
     connectedCallback() {
         if (!this.hasChildNodes()) {
-            const wrapper = document.createElement("box");
+            const wrapper = document.createXULElement("box");
             wrapper.setAttribute("orient", "vertical");
 
-            this.text = document.createElement("text");
+            this.text = document.createXULElement("text");
             this.text.classList.add("freebusy-timebar-title");
             this.text.style.fontWeight = "bold";
 
-            this.box = document.createElement("box");
+            this.box = document.createXULElement("box");
             this.box.setAttribute("equalsize", "always");
 
             wrapper.appendChild(this.text);
             wrapper.appendChild(this.box);
             this.appendChild(wrapper);
         }
 
         this.mDateFormatter = null;
@@ -2066,20 +2066,20 @@ class MozCalendarEventScrollContainer ex
     static get observedAttributes() {
         return ["flex", "orient"];
     }
 
     connectedCallback() {
         if (!this.delayConnectedCallback() || !this.container || !this.content) {
             const childrenFragment = this._getChildrenFragment();
 
-            this.container = document.createElement("box");
+            this.container = document.createXULElement("box");
             this.container.classList.add("container");
 
-            this.content = document.createElement("box");
+            this.content = document.createXULElement("box");
             this.content.classList.add("content");
 
             this.content.appendChild(childrenFragment);
             this.container.appendChild(this.content);
             this.appendChild(this.container);
 
             this._updateAttributes();
         }
@@ -3187,20 +3187,20 @@ class MozCalendarEventFreebusyGrid exten
     }
 
     /**
      * Returns new dummy item.
      *
      * @returns {Node}       Dummy item
      */
     createDummyItem() {
-        let item = document.createElement("richlistitem");
+        let item = document.createXULElement("richlistitem");
         item.setAttribute("_isDummyRow", "true");
         item.setAttribute("class", "dummy-row");
-        let cell = document.createElement("hbox");
+        let cell = document.createXULElement("hbox");
         cell.setAttribute("flex", "1");
         cell.setAttribute("class", "addressingWidgetCell dummy-row-cell");
         item.appendChild(cell);
         this.appendChild(item);
         return item;
     }
 
     /**
--- a/calendar/base/content/dialogs/calendar-migration-dialog.js
+++ b/calendar/base/content/dialogs/calendar-migration-dialog.js
@@ -35,17 +35,17 @@ var gMigrateWizard = {
                                                   ["Lightning"],
                                                   1);
         desc.textContent = props.formatStringFromName("migrationDescription",
                                                       ["Lightning"],
                                                       1);
 
         migLOG("migrators: " + window.arguments.length);
         for (let migrator of window.arguments[0]) {
-            let checkbox = document.createElement("checkbox");
+            let checkbox = document.createXULElement("checkbox");
             checkbox.setAttribute("checked", true);
             checkbox.setAttribute("label", migrator.title);
             checkbox.migrator = migrator;
             listbox.appendChild(checkbox);
         }
     },
 
     /**
--- a/calendar/base/content/dialogs/chooseCalendarDialog.js
+++ b/calendar/base/content/dialogs/chooseCalendarDialog.js
@@ -20,27 +20,27 @@ function loadCalendars() {
         calendars = window.arguments[0].calendars;
     } else {
         calendars = calendarManager.getCalendars({});
     }
     calendars = sortCalendarArray(calendars);
 
     for (let i = 0; i < calendars.length; i++) {
         let calendar = calendars[i];
-        let listItem = document.createElement("richlistitem");
+        let listItem = document.createXULElement("richlistitem");
 
-        let colorCell = document.createElement("box");
+        let colorCell = document.createXULElement("box");
         try {
             let calColor = calendar.getProperty("color");
             colorCell.style.background = calColor || "#a8c2e1";
         } catch (e) {}
         colorCell.style.width = "17px";
         listItem.appendChild(colorCell);
 
-        let nameCell = document.createElement("label");
+        let nameCell = document.createXULElement("label");
         nameCell.setAttribute("value", calendar.name);
         nameCell.setAttribute("flex", "1");
         listItem.appendChild(nameCell);
 
         listItem.calendar = calendar;
         listbox.appendChild(listItem);
 
         // Select the default calendar of the opening calendar window.
--- a/calendar/base/content/preferences/categories.js
+++ b/calendar/base/content/preferences/categories.js
@@ -88,24 +88,24 @@ var gCategoriesPane = {
         this.updateButtons();
 
 
         while (listbox.lastChild) {
             listbox.lastChild.remove();
         }
 
         for (let i = 0; i < gCategoryList.length; i++) {
-            let newListItem = document.createElement("richlistitem");
-            let categoryName = document.createElement("label");
+            let newListItem = document.createXULElement("richlistitem");
+            let categoryName = document.createXULElement("label");
             categoryName.setAttribute("id", gCategoryList[i]);
             categoryName.setAttribute("flex", "1");
             categoryName.setAttribute("value", gCategoryList[i]);
             let categoryNameFix = cal.view.formatStringForCSSRule(gCategoryList[i]);
 
-            let categoryColor = document.createElement("box");
+            let categoryColor = document.createXULElement("box");
             categoryColor.setAttribute("width", "150");
             try {
                 let colorCode = categoryPrefBranch.getCharPref(categoryNameFix);
                 categoryColor.setAttribute("id", colorCode);
                 categoryColor.setAttribute("style", "background-color: " + colorCode + ";");
             } catch (ex) {
                 categoryColor.setAttribute("label", noneLabel);
             }
--- a/calendar/lightning/content/lightning-item-iframe.js
+++ b/calendar/lightning/content/lightning-item-iframe.js
@@ -870,27 +870,27 @@ function loadCategories(aItem) {
     cal.l10n.sortArrayByLocaleCollator(categoryList);
 
     // Make sure the maximum number of categories is applied to the listbox
     let calendar = getCurrentCalendar();
     let maxCount = calendar.getProperty("capabilities.categories.maxCount");
 
     let categoryPopup = document.getElementById("item-categories-popup");
     if (maxCount == 1) {
-        let item = document.createElement("menuitem");
+        let item = document.createXULElement("menuitem");
         item.setAttribute("class", "menuitem-iconic");
         item.setAttribute("label", cal.l10n.getCalString("None"));
         item.setAttribute("type", "radio");
         if (itemCategories.length === 0) {
             item.setAttribute("checked", "true");
         }
         categoryPopup.appendChild(item);
     }
     for (let cat of categoryList) {
-        let item = document.createElement("menuitem");
+        let item = document.createXULElement("menuitem");
         item.setAttribute("class", "menuitem-iconic calendar-category");
         item.setAttribute("label", cat);
         item.setAttribute("value", cat);
         item.setAttribute("type", (maxCount === null || maxCount > 1) ? "checkbox" : "radio");
         if (itemCategories.includes(cat)) {
             item.setAttribute("checked", "true");
         }
         categoryPopup.appendChild(item);
@@ -995,17 +995,17 @@ function categoryTextboxKeypress(event) 
     } else {
         let localeCollator = cal.l10n.createLocaleCollator();
         let compare = localeCollator.compareString.bind(localeCollator, 0);
         newIndex = cal.data.binaryInsert(categories, category, compare, true);
 
         let calendar = getCurrentCalendar();
         let maxCount = calendar.getProperty("capabilities.categories.maxCount");
 
-        let item = document.createElement("menuitem");
+        let item = document.createXULElement("menuitem");
         item.setAttribute("class", "menuitem-iconic calendar-category");
         item.setAttribute("label", category);
         item.setAttribute("value", category);
         item.setAttribute("type", (maxCount === null || maxCount > 1) ? "checkbox" : "radio");
         item.setAttribute("checked", true);
         categoryPopup.insertBefore(item, categoryList[newIndex]);
     }
 
@@ -2276,19 +2276,19 @@ function addAttachment(attachment, cloud
         attachment.hashId in gAttachMap) {
         return;
     }
 
     // We currently only support uri attachments
     if (attachment.uri) {
         let documentLink = document.getElementById("attachment-link");
         let listItem = document.createXULElement("richlistitem");
-        let image = document.createElement("image");
+        let image = document.createXULElement("image");
         listItem.appendChild(image);
-        let label = document.createElement("label");
+        let label = document.createXULElement("label");
         label.setAttribute("value", makePrettyName(attachment.uri));
         label.setAttribute("crop", "end");
         listItem.appendChild(label);
         listItem.setAttribute("tooltiptext", attachment.uri.spec);
         if (cloudFileAccount) {
             if (attachment.uri.schemeIs("file")) {
                 // Its still a local url, needs to be uploaded
                 image.setAttribute("src", "chrome://messenger/skin/icons/connecting.png");
--- a/calendar/providers/gdata/content/gdata-calendar-creation.js
+++ b/calendar/providers/gdata/content/gdata-calendar-creation.js
@@ -137,17 +137,17 @@ var { monkeyPatch } = ChromeUtils.import
         }
 
         // forEach is needed for backwards compatibility.
         sessions.forEach((session) => {
             if (!session) {
                 return;
             }
 
-            let radio = document.createElement("radio");
+            let radio = document.createXULElement("radio");
             radio.setAttribute("value", session.id);
             radio.setAttribute("label", session.id);
             sessionContainer.insertBefore(radio, newSessionItem);
             radio.gdataSession = session;
         });
 
         sessionContainer.value = sessionContainer.firstChild.value;
         if (sessionContainer.value == "") {
--- a/calendar/providers/gdata/content/gdata-event-dialog.js
+++ b/calendar/providers/gdata/content/gdata-event-dialog.js
@@ -26,17 +26,17 @@ window.addEventListener("message", (aEve
                     node.disabled = aEvent.data.isGoogleTask;
                 }
             }
         }
     }
 });
 
 
-const gdataStatusPrivacyHbox = document.createElement("hbox");
+const gdataStatusPrivacyHbox = document.createXULElement("hbox");
 gdataStatusPrivacyHbox.setAttribute("id", "gdata-status-privacy-default-box");
 gdataStatusPrivacyHbox.setAttribute("privacy", "DEFAULT");
 gdataStatusPrivacyHbox.setAttribute("provider", "gdata");
 
 const statusPrivacy = document.getElementById("status-privacy");
 statusPrivacy.insertBefore(
     gdataStatusPrivacyHbox,
     document.getElementById("status-privacy-public-box")
--- a/calendar/providers/gdata/content/gdata-migration.js
+++ b/calendar/providers/gdata/content/gdata-migration.js
@@ -66,17 +66,17 @@ function getMigratableCalendars() {
  * Load Handler for both the wizard and the Thunderbird main window.
  */
 function gdata_migration_loader() {
     if (document.documentElement.id == "gdata-migration-wizard") {
         // This is the migration wizard, load the calendars needed.
         let listbox = document.getElementById("calendars-listbox");
 
         for (let calendar of sortCalendarArray(getMigratableCalendars())) {
-            let item = document.createElement("checkbox");
+            let item = document.createXULElement("checkbox");
             item.setAttribute("label", calendar.name);
             item.setAttribute("value", calendar.id);
             item.calendar = calendar;
             listbox.appendChild(item);
         }
 
         // Set up the "always check" field
         document.getElementById("showagain-checkbox").checked =
--- a/calendar/resources/content/datetimepickers/datetimepickers.js
+++ b/calendar/resources/content/datetimepickers/datetimepickers.js
@@ -59,27 +59,27 @@ var { Services } = ChromeUtils.import("r
             };
         }
 
         connectedCallback() {
             if (this.hasChildNodes()) {
                 return;
             }
 
-            const spacer = document.createElement("spacer");
+            const spacer = document.createXULElement("spacer");
             spacer.setAttribute("flex", "1");
 
-            const minutebox = document.createElement("vbox");
+            const minutebox = document.createXULElement("vbox");
             minutebox.addEventListener("click", () => {
                 this.clickMinute(this, this.getAttribute("value"));
             });
 
-            const box = document.createElement("box");
+            const box = document.createXULElement("box");
 
-            this.label = document.createElement("label");
+            this.label = document.createXULElement("label");
             this.label.classList.add("time-picker-minute-label");
 
             box.appendChild(this.label);
             minutebox.appendChild(box);
 
             this.appendChild(spacer.cloneNode());
             this.appendChild(minutebox);
             this.appendChild(spacer);
@@ -161,30 +161,30 @@ var { Services } = ChromeUtils.import("r
             };
         }
 
         connectedCallback() {
             if (this.hasChildNodes()) {
                 return;
             }
 
-            const spacer = document.createElement("spacer");
+            const spacer = document.createXULElement("spacer");
             spacer.setAttribute("flex", "1");
 
-            const hourbox = document.createElement("vbox");
+            const hourbox = document.createXULElement("vbox");
             hourbox.addEventListener("click", () => {
                 this.clickHour(this, this.getAttribute("value"));
             });
             hourbox.addEventListener("dblclick", () => {
                 this.doubleClickHour(this, this.getAttribute("value"));
             });
 
-            const box = document.createElement("box");
+            const box = document.createXULElement("box");
 
-            this.label = document.createElement("label");
+            this.label = document.createXULElement("label");
             this.label.classList.add("time-picker-hour-label");
 
             box.appendChild(this.label);
             hourbox.appendChild(box);
             hourbox.appendChild(spacer.cloneNode());
 
             this.appendChild(spacer.cloneNode());
             this.appendChild(hourbox);
@@ -748,19 +748,19 @@ var { Services } = ChromeUtils.import("r
             this._popup = this._menulist.menupopup;
             this._minimonth = this.querySelector("minimonth");
 
             if (this.getAttribute("type") == "forever") {
                 this._valueIsForever = false;
                 this._foreverString =
                     cal.l10n.getString("calendar-event-dialog", "eventRecurrenceForeverLabel");
 
-                this._foreverItem = document.createElement("button");
+                this._foreverItem = document.createXULElement("button");
                 this._foreverItem.setAttribute("label", this._foreverString);
-                this._popup.appendChild(document.createElement("menuseparator"));
+                this._popup.appendChild(document.createXULElement("menuseparator"));
                 this._popup.appendChild(this._foreverItem);
 
                 this._foreverItem.addEventListener("command", () => {
                     this._inputBoxValue = "forever";
                     this._valueIsForever = true;
                     this._popup.hidePopup();
                 });
             }
@@ -1063,20 +1063,20 @@ var { Services } = ChromeUtils.import("r
     ]);
 
     class CalendarDateTimePicker extends MozXULElement {
         connectedCallback() {
             if (this.delayConnectedCallback()) {
                 return;
             }
 
-            this._datepicker = document.createElement("datepicker");
+            this._datepicker = document.createXULElement("datepicker");
             this._datepicker.classList.add("datetimepicker-datepicker");
             this._datepicker.setAttribute("anonid", "datepicker");
-            this._timepicker = document.createElement("timepicker");
+            this._timepicker = document.createXULElement("timepicker");
             this._timepicker.classList.add("datetimepicker-timepicker");
             this._timepicker.setAttribute("anonid", "timepicker");
             this.appendChild(this._datepicker);
             this.appendChild(this._timepicker);
 
             if (this.getAttribute("value")) {
                 this._datepicker.value = this.getAttribute("value");
                 this._timepicker.value = this.getAttribute("value");
--- a/calendar/resources/content/mouseoverPreviews.js
+++ b/calendar/resources/content/mouseoverPreviews.js
@@ -124,17 +124,17 @@ function getToDoStatusString(aToDo) {
  * PRIVATE: Called when a user hovers over a todo element and the text for the
  * mouse overis changed.
  *
  * @param {calIToDo} toDoItem    the item to create the preview for
  * @param {boolean}  aIsTooltip  enabled if used for tooltip composition (default)
  */
 function getPreviewForTask(toDoItem, aIsTooltip=true) {
     if (toDoItem) {
-        const vbox = document.createElement("vbox");
+        const vbox = document.createXULElement("vbox");
         vbox.setAttribute("class", "tooltipBox");
         if (aIsTooltip) {
             // tooltip appears above or below pointer, so may have as little as
             // one half the screen height available (avoid top going off screen).
             vbox.maxHeight = Math.floor(screen.height / 2);
         } else {
             vbox.setAttribute("flex", "1");
         }
@@ -224,17 +224,17 @@ function getPreviewForTask(toDoItem, aIs
  * box (recurring or multiday events may be displayed by more than one event box
  * for different days), or null if should compute next instance from now.
  *
  * @param {calIEvent} aEvent       the item to create the preview for
  * @param {boolean}   aIsTooltip   enabled if used for tooltip composition (default)
  */
 function getPreviewForEvent(aEvent, aIsTooltip=true) {
     let event = aEvent;
-    const vbox = document.createElement("vbox");
+    const vbox = document.createXULElement("vbox");
     vbox.setAttribute("class", "tooltipBox");
     if (aIsTooltip) {
         // tooltip appears above or below pointer, so may have as little as
         // one half the screen height available (avoid top going off screen).
         vbox.maxHeight = Math.floor(screen.height / 2);
     } else {
         vbox.setAttribute("flex", "1");
     }
@@ -285,33 +285,33 @@ function getPreviewForEvent(aEvent, aIsT
 }
 
 /**
  * PRIVATE: Append a separator, a thin space between header and body.
  *
  * @param {Node}  vbox  box to which to append separator.
  */
 function boxAppendBodySeparator(vbox) {
-    const separator = document.createElement("separator");
+    const separator = document.createXULElement("separator");
     separator.setAttribute("class", "tooltipBodySeparator");
     vbox.appendChild(separator);
 }
 
 /**
  * PRIVATE: Append description to box for body text.  Text may contain
  * paragraphs; line indent and line breaks will be preserved by CSS.
  *
  * @param box           box to which to append body
  * @param textString    text of body
  * @param aIsTooltip    true for "tooltip" and false for "conflict-dialog" case
  */
 function boxAppendBody(box, textString, aIsTooltip) {
     let type = (aIsTooltip) ? "description": "vbox";
     let textNode = document.createTextNode(textString);
-    let xulDescription = document.createElement(type);
+    let xulDescription = document.createXULElement(type);
     xulDescription.setAttribute("class", "tooltipBody");
     if (!aIsTooltip) {
         xulDescription.setAttribute("flex", "1");
     }
     xulDescription.appendChild(textNode);
     box.appendChild(xulDescription);
 }
 
@@ -343,76 +343,76 @@ function boxAppendLabeledDateTimeInterva
 }
 
 /**
  * PRIVATE: create empty 2-column grid for header fields, and append it to box.
  *
  * @param  {Node}  box  The node to create a column grid for
  */
 function boxInitializeHeaderGrid(box) {
-    let grid = document.createElement("grid");
+    let grid = document.createXULElement("grid");
     grid.setAttribute("class", "tooltipHeaderGrid");
     let rows;
     {
-        let columns = document.createElement("columns");
+        let columns = document.createXULElement("columns");
         {
-            let labelColumn = document.createElement("column");
+            let labelColumn = document.createXULElement("column");
             labelColumn.setAttribute("class", "tooltipLabelColumn");
             columns.appendChild(labelColumn);
-            let valueColumn = document.createElement("column");
+            let valueColumn = document.createXULElement("column");
             valueColumn.setAttribute("class", "tooltipValueColumn");
             columns.appendChild(valueColumn);
         }
         grid.appendChild(columns);
-        rows = document.createElement("rows");
+        rows = document.createXULElement("rows");
         grid.appendChild(rows);
     }
     box.appendChild(grid);
 }
 
 /**
  * PRIVATE: To headers grid, append a row containing Label: value, where label
  * is localized text for labelProperty.
  *
  * @param box               box containing headers grid
  * @param labelProperty     name of property for localized name of header
  * @param textString        value of header field.
  */
 function boxAppendLabeledText(box, labelProperty, textString) {
     let labelText = cal.l10n.getCalString(labelProperty);
     let rows = box.getElementsByTagNameNS(box.namespaceURI, "rows")[0];
-    let row = document.createElement("row");
+    let row = document.createXULElement("row");
 
     row.appendChild(createTooltipHeaderLabel(labelText));
     row.appendChild(createTooltipHeaderDescription(textString));
 
     rows.appendChild(row);
 }
 
 /**
  * PRIVATE: Creates an element for field label (for header grid)
  *
  * @param   {String} text  The text to display in the node
  * @returns {Node}         The node
  */
 function createTooltipHeaderLabel(text) {
-    let label = document.createElement("label");
+    let label = document.createXULElement("label");
     label.setAttribute("class", "tooltipHeaderLabel");
     label.appendChild(document.createTextNode(text));
     return label;
 }
 
 /**
  * PRIVATE: Creates an element for field value (for header grid)
  *
  * @param   {String} text  The text to display in the node
  * @returns {Node}         The node
  */
 function createTooltipHeaderDescription(text) {
-    let label = document.createElement("description");
+    let label = document.createXULElement("description");
     label.setAttribute("class", "tooltipHeaderDescription");
     label.appendChild(document.createTextNode(text));
     return label;
 }
 
 /**
  * PRIVATE: If now is during an occurrence, return the occurrence. If now is
  * before an occurrence, return the next occurrence or otherwise the previous
--- a/chat/content/conversation-browser.js
+++ b/chat/content/conversation-browser.js
@@ -19,17 +19,17 @@ var {smileTextNode} = ChromeUtils.import
 var {cleanupImMarkup} = ChromeUtils.import("resource:///modules/imContentSink.jsm");
 
 (function() {
   // <browser> is lazily set up through setElementCreationCallback,
   // i.e. put into customElements the first time it's really seen.
   // Create a fake to ensure browser exists in customElements, since otherwise
   // we can't extend it. Then make sure this fake doesn't stay around.
   if (!customElements.get("browser")) {
-    delete document.createElement("browser");
+    delete document.createXULElement("browser");
   }
 })();
 
 /**
  * The chat conversation browser, i.e. the main content on the chat tab.
  * @augments {MozBrowser}
  */
 class MozConversationBrowser extends customElements.get("browser") {
--- a/chat/content/imAccountOptionsHelper.js
+++ b/chat/content/imAccountOptionsHelper.js
@@ -1,58 +1,58 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 var accountOptionsHelper = {
   createTextbox(aType, aValue, aLabel, aName) {
-    let container = document.createElement("hbox");
+    let container = document.createXULElement("hbox");
     container.setAttribute("align", "baseline");
     container.setAttribute("equalsize", "always");
 
-    let label = document.createElement("label");
+    let label = document.createXULElement("label");
     label.textContent = aLabel;
     label.setAttribute("control", aName);
     label.setAttribute("flex", "1");
     container.appendChild(label);
 
-    let hbox = document.createElement("hbox");
-    let textbox = document.createElement("textbox");
+    let hbox = document.createXULElement("hbox");
+    let textbox = document.createXULElement("textbox");
     if (aType) {
       textbox.setAttribute("type", aType);
     }
     textbox.setAttribute("value", aValue);
     textbox.setAttribute("id", aName);
     textbox.setAttribute("flex", "1");
     hbox.setAttribute("flex", "1");
     hbox.setAttribute("align", "start");
     hbox.appendChild(textbox);
 
     container.appendChild(hbox);
     return container;
   },
 
   createMenulist(aList, aLabel, aName) {
-    let vbox = document.createElement("vbox");
-    let hbox = document.createElement("hbox");
+    let vbox = document.createXULElement("vbox");
+    let hbox = document.createXULElement("hbox");
 
-    let label = document.createElement("label");
+    let label = document.createXULElement("label");
     label.setAttribute("value", aLabel);
     label.setAttribute("control", aName);
     hbox.appendChild(label);
     vbox.appendChild(hbox);
 
     aList.QueryInterface(Ci.nsISimpleEnumerator);
-    let menulist = document.createElement("menulist");
+    let menulist = document.createXULElement("menulist");
     menulist.setAttribute("id", aName);
     menulist.setAttribute("flex", "1");
-    let popup = menulist.appendChild(document.createElement("menupopup"));
+    let popup = menulist.appendChild(document.createXULElement("menupopup"));
     while (aList.hasMoreElements()) {
       let elt = aList.getNext();
-      let item = document.createElement("menuitem");
+      let item = document.createXULElement("menuitem");
       item.setAttribute("label", elt.name);
       item.setAttribute("value", elt.value);
       popup.appendChild(item);
     }
     vbox.appendChild(menulist);
     return vbox;
   },
 
@@ -66,18 +66,18 @@ var accountOptionsHelper = {
     }
 
     let haveOptions = false;
     for (let opt of aOptions) {
       let text = opt.label;
       let name = aIdPrefix + opt.name;
       switch (opt.type) {
         case Ci.prplIPref.typeBool:
-          let chk = document.createElement("checkbox");
-          let hbox = document.createElement("hbox");
+          let chk = document.createXULElement("checkbox");
+          let hbox = document.createXULElement("hbox");
           hbox.setAttribute("flex", "1");
           chk.setAttribute("label", text);
           chk.setAttribute("id", name);
           if (opt.getBool()) {
             chk.setAttribute("checked", "true");
           }
           hbox.appendChild(chk);
           vbox.appendChild(hbox);
--- a/common/src/browser-development-helpers.js
+++ b/common/src/browser-development-helpers.js
@@ -21,30 +21,30 @@ var DevelopmentHelpers = {
     let env = Cc["@mozilla.org/process/environment;1"].
               getService(Ci.nsIEnvironment);
     env.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
 
     Services.startup.quit(Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart);
   },
 
   addRestartShortcut() {
-    let command = document.createElement("command");
+    let command = document.createXULElement("command");
     command.setAttribute("id", "cmd_quickRestart");
     command.addEventListener("command", this.quickRestart, true);
     command.setAttribute("oncommand", "void 0;"); // Needed - bug 371900
     document.getElementById("mainCommandSet").prepend(command);
 
-    let key = document.createElement("key");
+    let key = document.createXULElement("key");
     key.setAttribute("id", "key_quickRestart");
     key.setAttribute("key", "r");
     key.setAttribute("modifiers", "accel,alt");
     key.setAttribute("command", "cmd_quickRestart");
     key.setAttribute("oncommand", "void 0;"); // Needed - bug 371900
     document.getElementById("mainKeyset").prepend(key);
 
-    let menuitem = document.createElement("menuitem");
+    let menuitem = document.createXULElement("menuitem");
     menuitem.setAttribute("id", "menu_FileRestartItem");
     menuitem.setAttribute("key", "key_quickRestart");
     menuitem.setAttribute("label", "Restart (Developer)");
     menuitem.addEventListener("command", this.quickRestart, true);
     document.getElementById("menu_FilePopup").appendChild(menuitem);
   },
 };
--- a/common/src/viewSource.js
+++ b/common/src/viewSource.js
@@ -680,17 +680,17 @@ var viewSourceChrome = new ViewSourceChr
 /**
  * PrintUtils uses this to make Print Preview work.
  */
 var PrintPreviewListener = {
   _ppBrowser: null,
 
   getPrintPreviewBrowser() {
     if (!this._ppBrowser) {
-      this._ppBrowser = document.createElement("browser");
+      this._ppBrowser = document.createXULElement("browser");
       this._ppBrowser.setAttribute("flex", "1");
       this._ppBrowser.setAttribute("type", "content");
     }
 
     if (gBrowser.isRemoteBrowser) {
       this._ppBrowser.setAttribute("remote", "true");
     } else {
       this._ppBrowser.removeAttribute("remote");
--- a/editor/ui/composer/content/StructBarContextMenu.js
+++ b/editor/ui/composer/content/StructBarContextMenu.js
@@ -146,17 +146,17 @@ function OnKeyPress(event)
     var childNodes = element.parentNode.childNodes;
     while (childNodes.item(offset) != element) {
       offset++;
     }
 
     editor.beginTransaction();
 
     try {
-      var newElt = editor.document.createElement(newTag);
+      var newElt = editor.document.createXULElement(newTag);
       if (newElt) {
         childNodes = element.childNodes;
         var childNodesLength = childNodes.length;
         var i;
         for (i = 0; i < childNodesLength; i++) {
           var clone = childNodes.item(i).cloneNode(true);
           newElt.appendChild(clone);
         }
--- a/editor/ui/composer/content/editingOverlay.js
+++ b/editor/ui/composer/content/editingOverlay.js
@@ -127,17 +127,17 @@ function toggleAffectedChrome(aHide)
   document.getElementById("EditorToolbox").hidden = aHide;
   document.getElementById("appcontent").collapsed = aHide;
 }
 
 var PrintPreviewListener = {
   getPrintPreviewBrowser: function () {
     var browser = document.getElementById("ppBrowser");
     if (!browser) {
-      browser = document.createElement("browser");
+      browser = document.createXULElement("browser");
       browser.setAttribute("id", "ppBrowser");
       browser.setAttribute("flex", "1");
       browser.setAttribute("disablehistory", "true");
       browser.setAttribute("disablesecurity", "true");
       browser.setAttribute("type", "content");
       document.getElementById("sidebar-parent").
         insertBefore(browser, document.getElementById("appcontent"));
     }
@@ -279,17 +279,17 @@ function BuildRecentPagesMenu()
   }
 }
 
 function AppendRecentMenuitem(aPopup, aTitle, aUrl, aFileType, aIndex)
 {
   if (!aPopup)
     return;
 
-  var menuItem = document.createElement("menuitem");
+  var menuItem = document.createXULElement("menuitem");
   if (!menuItem)
     return;
 
   var accessKey = aIndex <= 10 ? String(aIndex % 10) : " ";
 
   // Show "title [url]" or just the URL.
   var itemString = aTitle ? aTitle + " [" + aUrl + "]" : aUrl;
 
--- a/editor/ui/dialogs/content/EdDialogCommon.js
+++ b/editor/ui/dialogs/content/EdDialogCommon.js
@@ -851,17 +851,17 @@ function FillLinkMenulist(linkMenulist, 
       }
       var item = createMenuItem(menupopup, GetString("NoNamedAnchorsOrHeadings"));
       item.setAttribute("disabled", "true");
     }
   } catch (e) {}
 }
 
 function createMenuItem(aMenuPopup, aLabel) {
-  var menuitem = document.createElement("menuitem");
+  var menuitem = document.createXULElement("menuitem");
   menuitem.setAttribute("label", aLabel);
   aMenuPopup.appendChild(menuitem);
   return menuitem;
 }
 
 // Shared by Image and Link dialogs for the "Choose" button for links
 function chooseLinkFile() {
   GetLocalFileURL("html, img").then(fileURL => {
--- a/mail/base/content/FilterListDialog.js
+++ b/mail/base/content/FilterListDialog.js
@@ -703,22 +703,22 @@ function rebuildFilterList() {
     if (listitemCount > listitemIndex) {
       // If there is a free existing listitem, reuse it.
       // Use .itemChildren[] instead of .getItemAtIndex() as it is much faster.
       listitem = gFilterListbox.itemChildren[listitemIndex];
       nameCell = listitem.firstChild;
       enabledCell = nameCell.nextSibling;
     } else {
       // If there are not enough listitems in the list, create a new one.
-      listitem = document.createElement("richlistitem");
+      listitem = document.createXULElement("richlistitem");
       listitem.setAttribute("align", "center");
       listitem.setAttribute("role", "checkbox");
-      nameCell = document.createElement("label");
+      nameCell = document.createXULElement("label");
       nameCell.setAttribute("flex", "1");
-      enabledCell = document.createElement("checkbox");
+      enabledCell = document.createXULElement("checkbox");
       enabledCell.setAttribute("style", "padding-inline-start: 25px;");
       enabledCell.addEventListener("CheckboxStateChange", onFilterClick, true);
       listitem.appendChild(nameCell);
       listitem.appendChild(enabledCell);
       gFilterListbox.appendChild(listitem);
       // We have to attach this listener to the listitem, even though we only care
       // about clicks on the enabledCell. However, attaching to that item doesn't
       // result in any events actually getting received.
--- a/mail/base/content/aboutAddonsExtra.js
+++ b/mail/base/content/aboutAddonsExtra.js
@@ -14,29 +14,29 @@ gStrings.mailExt =
   window.isCorrectlySigned = function() { return true; };
 
   let contentStylesheet = document.createProcessingInstruction(
     "xml-stylesheet",
     'href="chrome://messenger/content/extensionsOverlay.css" type="text/css"');
   document.insertBefore(contentStylesheet, document.documentElement);
 
   // Add navigation buttons for back and forward on the addons page.
-  let hbox = document.createElement("hbox");
+  let hbox = document.createXULElement("hbox");
   hbox.setAttribute("id", "nav-header");
   hbox.setAttribute("align", "center");
   hbox.setAttribute("pack", "center");
 
-  let backButton = document.createElement("toolbarbutton");
+  let backButton = document.createXULElement("toolbarbutton");
   backButton.setAttribute("id", "back-btn");
   backButton.setAttribute("class", "nav-button");
   backButton.setAttribute("command", "cmd_back");
   backButton.setAttribute("tooltiptext", gStrings.mailExt.GetStringFromName("cmdBackTooltip"));
   backButton.setAttribute("disabled", "true");
 
-  let forwardButton = document.createElement("toolbarbutton");
+  let forwardButton = document.createXULElement("toolbarbutton");
   forwardButton.setAttribute("id", "forward-btn");
   forwardButton.setAttribute("class", "nav-button");
   forwardButton.setAttribute("command", "cmd_forward");
   forwardButton.setAttribute("tooltiptext", gStrings.mailExt.GetStringFromName("cmdForwardTooltip"));
   forwardButton.setAttribute("disabled", "true");
   hbox.appendChild(backButton);
   hbox.appendChild(forwardButton);
 
@@ -45,30 +45,30 @@ gStrings.mailExt =
 
   // Fix the "Search on addons.mozilla.org" placeholder text in the searchbox.
   let textbox = document.getElementById("header-search");
   let placeholder = textbox.getAttribute("placeholder");
   placeholder = placeholder.replace("addons.mozilla.org", "addons.thunderbird.net");
   textbox.setAttribute("placeholder", placeholder);
 
   // Tell the world about legacy extensions.
-  let alertContainer = document.createElement("vbox");
+  let alertContainer = document.createXULElement("vbox");
   alertContainer.id = "tb-legacy-extensions-notice";
   alertContainer.className = "alert-container";
 
-  let alert = document.createElement("vbox");
+  let alert = document.createXULElement("vbox");
   alert.className = "alert";
 
-  let description = document.createElement("description");
+  let description = document.createXULElement("description");
   let messageString = gStrings.mailExt.GetStringFromName("legacyInfo") + " ";
   messageString = messageString.replace("#1", gStrings.brandShortName);
   messageString = messageString.replace("#2", Services.appinfo.version);
   description.textContent = messageString;
 
-  let label = document.createElement("label");
+  let label = document.createXULElement("label");
   label.className = "text-link plain";
   label.href = "https://support.mozilla.org/kb/unable-install-add-on-extension-theme-thunderbird";
   label.value = gStrings.mailExt.GetStringFromName("legacyLearnMore");
 
   description.appendChild(label);
   alert.appendChild(description);
   alertContainer.appendChild(alert);
 
@@ -148,29 +148,29 @@ gDetailView.updateState = function() {
         stringName, [this._addon.name, gStrings.brandShortName], 2
       );
 
       if (version) {
         document.getElementById("detail-version").value = version;
       }
 
       if (!restartButton) {
-        restartButton = document.createElement("button");
+        restartButton = document.createXULElement("button");
         restartButton.id = "restart-btn";
         restartButton.className = "button-link restart-btn";
         restartButton.setAttribute(
           "label", gStrings.mailExt.GetStringFromName("warnLegacyRestartButton")
         );
         restartButton.setAttribute("oncommand", "BrowserUtils.restartApplication()");
         warningContainer.insertBefore(restartButton, warningContainer.lastElementChild);
       }
       restartButton.hidden = false;
       if (undoCommand) {
         if (!undoButton) {
-          undoButton = document.createElement("button");
+          undoButton = document.createXULElement("button");
           undoButton.className = "button-link undo-btn";
           undoButton.setAttribute(
             "label", gStrings.mailExt.GetStringFromName("warnLegacyUndoButton")
           );
           // We shouldn't really attach non-anonymous content to anonymous content, but we can.
           warningContainer.insertBefore(undoButton, warningContainer.lastElementChild);
         }
         undoButton.setAttribute("oncommand", undoCommand);
--- a/mail/base/content/folderPane.js
+++ b/mail/base/content/folderPane.js
@@ -502,17 +502,17 @@ var gFolderTreeView = {
       else
         item.setAttribute("checked", "false");
     }
 
     for (let mode of fullModes)
       appendMode(mode);
 
     if ((fullModes.length > 0) && (compactModes.length > 0))
-      modeSelector.menupopup.appendChild(document.createElement("menuseparator"));
+      modeSelector.menupopup.appendChild(document.createXULElement("menuseparator"));
 
     for (let mode of compactModes)
       appendMode(mode);
   },
 
   _selectModeInSelector(aMode) {
     // Show the mode in the mode selector, if it is on a toolbar.
     let modeSelector = document.getElementById("folderpane-mode-selector");
--- a/mail/base/content/foldersummary.js
+++ b/mail/base/content/foldersummary.js
@@ -151,35 +151,35 @@ class MozFolderSummary extends MozXULEle
         }
         this.appendChild(msgPopup);
       }
     }
     return foundNewMsg;
   }
 
   _folderSummaryMessagePopup() {
-    let vbox = document.createElement("vbox");
+    let vbox = document.createXULElement("vbox");
     vbox.setAttribute("class", "folderSummaryMessage");
 
-    let hbox = document.createElement("hbox");
+    let hbox = document.createXULElement("hbox");
     hbox.setAttribute("class", "folderSummary-message-row");
 
-    let subject = document.createElement("label");
+    let subject = document.createXULElement("label");
     subject.setAttribute("class", "folderSummary-subject");
     subject.setAttribute("flex", "1");
     subject.setAttribute("crop", "right");
 
-    let sender = document.createElement("label");
+    let sender = document.createXULElement("label");
     sender.setAttribute("class", "folderSummary-sender");
     sender.setAttribute("crop", "right");
 
     hbox.appendChild(subject);
     hbox.appendChild(sender);
 
-    let preview = document.createElement("description");
+    let preview = document.createXULElement("description");
     preview.setAttribute("class", "folderSummary-message-row folderSummary-previewText");
     preview.setAttribute("crop", "right");
 
     vbox.appendChild(hbox);
     vbox.appendChild(preview);
     return vbox;
   }
 }
@@ -250,17 +250,17 @@ class MozFolderTooltip extends MozFolder
   _addLocationInfo(folder, cropped, node) {
       // Display also server name for items that are on level 0 and are not
       // server names by themselves and do not have server name already appended
       // in their label.
       let folderIndex = gFolderTreeView.getIndexOfFolder(folder);
       if (!folder.isServer &&
           gFolderTreeView.getLevel(folderIndex) == 0 &&
           !gFolderTreeView.getServerNameAdded(folderIndex)) {
-        let loc = document.createElement("label");
+        let loc = document.createXULElement("label");
         let midPath = "";
         let midFolder = folder.parent;
         while (folder.server.rootFolder != midFolder) {
           midPath = midFolder.name + " - " + midPath;
           midFolder = midFolder.parent;
         }
         loc.setAttribute("value", folder.server.prettyName + " - " + midPath + folder.name);
         node.appendChild(loc);
@@ -268,39 +268,39 @@ class MozFolderTooltip extends MozFolder
       }
 
       // If folder name is cropped or is a newsgroup and abbreviated per
       // pref, use the full name as a tooltip.
       if (cropped ||
           ((folder.server instanceof Ci.nsINntpIncomingServer) &&
            !(folder.flags & Ci.nsMsgFolderFlags.Virtual) &&
            folder.server.abbreviate) && !folder.isServer) {
-        let loc = document.createElement("label");
+        let loc = document.createXULElement("label");
         loc.setAttribute("value", folder.name);
         node.appendChild(loc);
         return true;
       }
       return false;
     }
 
   /** Add information about unread messages in this folder and subfolders. */
   _addSummarizeExplain(counts, node) {
       if (!counts || !counts[1]) {
         return false;
       }
-      let expl = document.createElement("label");
+      let expl = document.createXULElement("label");
       let sumString = document.getElementById("bundle_messenger")
         .getFormattedString("subfoldersExplanation", [counts[0], counts[1]], 2);
       expl.setAttribute("value", sumString);
       node.appendChild(expl);
       return true;
     }
 
   _addCroppedText(text, node) {
-      let expl = document.createElement("label");
+      let expl = document.createXULElement("label");
       expl.setAttribute("value", text);
       node.appendChild(expl);
       return true;
     }
 }
 
 customElements.define("folder-summary", MozFolderSummary);
 customElements.define("folder-tooltip", MozFolderTooltip);
--- a/mail/base/content/glodaFacet.js
+++ b/mail/base/content/glodaFacet.js
@@ -258,17 +258,17 @@ class MozFacetBoolean extends HTMLElemen
       this.build(true);
     }
   }
 
   addChildren() {
     this.bubble = document.createElement("span");
     this.bubble.classList.add("facet-checkbox-bubble");
 
-    this.checkbox = document.createElement("input");
+    this.checkbox = document.createXULElement("input");
     this.checkbox.setAttribute("type", "checkbox");
 
     this.labelNode = document.createElement("span");
     this.labelNode.classList.add("facet-checkbox-label");
 
     this.countNode = document.createElement("span");
     this.countNode.classList.add("facet-checkbox-count");
 
--- a/mail/base/content/mailCore.js
+++ b/mail/base/content/mailCore.js
@@ -327,17 +327,17 @@ function onViewToolbarsPopupShowing(aEve
 
     for (let toolbarElement of potentialToolbars) {
       // We have to bind to toolbar because Javascript doesn't do fresh
       // let-bindings per Iteration.
       let toolbar = toolbarElement;
 
       let toolbarName = toolbar.getAttribute("toolbarname");
       if (toolbarName) {
-        let menuItem = document.createElement("menuitem");
+        let menuItem = document.createXULElement("menuitem");
         let hidingAttribute = toolbar.getAttribute("type") == "menubar" ?
                               "autohide" : "collapsed";
         menuItem.setAttribute("type", "checkbox");
         // Mark this menuitem with an iscollapsible attribute, so we
         // know we can wipe it out later on.
         menuItem.setAttribute("iscollapsible", true);
         menuItem.setAttribute("toolbarid", toolbar.id);
         menuItem.setAttribute("label", toolbarName);
--- a/mail/base/content/mailWidgets.js
+++ b/mail/base/content/mailWidgets.js
@@ -84,17 +84,17 @@ class MozMailHeaderfieldTags extends Moz
 
       let color = MailServices.tags.getColorForKey(tagsArray[i]);
       let textColor = "black";
       if (!TagUtils.isColorContrastEnough(color)) {
         textColor = "white";
       }
 
       // now create a label for the tag name, and set the color
-      const label = document.createElement("label");
+      const label = document.createXULElement("label");
       label.setAttribute("value", tagName);
       label.className = "tagvalue";
       label.setAttribute("style", "color: " + textColor + "; background-color: " + color + ";");
 
       this.appendChild(label);
     }
   }
 }
@@ -116,19 +116,19 @@ class MozMailNewsgroupsHeaderfield exten
   }
 
   addNewsgroupView(aNewsgroup) {
     this.mNewsgroups.push(aNewsgroup);
   }
 
   buildViews() {
     for (let i = 0; i < this.mNewsgroups.length; i++) {
-      const newNode = document.createElement("mail-newsgroup");
+      const newNode = document.createXULElement("mail-newsgroup");
       if (i > 0) {
-        const textNode = document.createElement("text");
+        const textNode = document.createXULElement("text");
         textNode.setAttribute("value", ",");
         textNode.setAttribute("class", "newsgroupSeparator");
         this.appendChild(textNode);
       }
 
       newNode.textContent = this.mNewsgroups[i];
       newNode.setAttribute("newsgroup", this.mNewsgroups[i]);
       this.appendChild(newNode);
@@ -197,24 +197,24 @@ class MozMailMessageidsHeaderfield exten
       return;
     }
 
     this.setAttribute("context", "messageIdsHeaderfieldContext");
 
     this.mMessageIds = [];
     this.showFullMessageIds = false;
 
-    this.toggleIcon = document.createElement("image");
+    this.toggleIcon = document.createXULElement("image");
     this.toggleIcon.classList.add("emailToggleHeaderfield");
     this.toggleIcon.addEventListener("click", () => {
       this._toggleWrap();
     });
     this.appendChild(this.toggleIcon);
 
-    this.headerValue = document.createElement("hbox");
+    this.headerValue = document.createXULElement("hbox");
     this.headerValue.classList.add("headerValue");
     this.headerValue.setAttribute("flex", "1");
     this.appendChild(this.headerValue);
   }
 
   _toggleWrap() {
     for (let i = 0; i < this.headerValue.childNodes.length; i += 2) {
       if (!this.showFullMessageIds) {
@@ -239,20 +239,20 @@ class MozMailMessageidsHeaderfield exten
 
     this.toggleIcon.hidden = this.mMessageIds.length <= 1;
 
     for (let i = 0; i < this.mMessageIds.length; i++) {
       if (i * 2 <= this.headerValue.childNodes.length - 1) {
         this._updateMessageIdNode(this.headerValue.childNodes[i * 2], i + 1,
           this.mMessageIds[i], this.mMessageIds.length);
       } else {
-        let newMessageIdNode = document.createElement("mail-messageid");
+        let newMessageIdNode = document.createXULElement("mail-messageid");
 
         if (i > 0) {
-          let textNode = document.createElement("text");
+          let textNode = document.createXULElement("text");
           textNode.setAttribute("value", ", ");
           textNode.setAttribute("class", "messageIdSeparator");
           this.headerValue.appendChild(textNode);
         }
         let itemInDocument = this.headerValue.appendChild(newMessageIdNode);
         this._updateMessageIdNode(itemInDocument, i + 1,
           this.mMessageIds[i], this.mMessageIds.length);
       }
@@ -301,24 +301,24 @@ class MozMailEmailaddress extends MozXUL
   connectedCallback() {
     if (this.hasChildNodes() || this.delayConnectedCallback()) {
       return;
     }
     this.classList.add("emailDisplayButton");
     this.setAttribute("context", "emailAddressPopup");
     this.setAttribute("popup", "emailAddressPopup");
 
-    const label = document.createElement("label");
+    const label = document.createXULElement("label");
     label.classList.add("emaillabel");
 
-    const emailStarImage = document.createElement("image");
+    const emailStarImage = document.createXULElement("image");
     emailStarImage.classList.add("emailStar");
     emailStarImage.setAttribute("context", "emailAddressPopup");
 
-    const emailPresenceImage = document.createElement("image");
+    const emailPresenceImage = document.createXULElement("image");
     emailPresenceImage.classList.add("emailPresence");
 
     this.appendChild(label);
     this.appendChild(emailStarImage);
     this.appendChild(emailPresenceImage);
 
     this._update();
     this._setupEventListeners();
@@ -382,17 +382,17 @@ class MozMailEmailaddress extends MozXUL
 }
 customElements.define("mail-emailaddress", MozMailEmailaddress);
 
 class MozMailEmailheaderfield extends MozXULElement {
   connectedCallback() {
     if (this.hasChildNodes() || this.delayConnectedCallback()) {
       return;
     }
-    this._mailEmailAddress = document.createElement("mail-emailaddress");
+    this._mailEmailAddress = document.createXULElement("mail-emailaddress");
     this._mailEmailAddress.classList.add("headerValue");
     this._mailEmailAddress.setAttribute("containsEmail", "true");
 
     this.appendChild(this._mailEmailAddress);
   }
 
   get emailAddressNode() {
     return this._mailEmailAddress;
@@ -404,17 +404,17 @@ class MozTreecolImage extends customElem
   static get observedAttributes() {
     return ["src"];
   }
 
   connectedCallback() {
     if (this.hasChildNodes() || this.delayConnectedCallback()) {
       return;
     }
-    this.image = document.createElement("image");
+    this.image = document.createXULElement("image");
     this.image.classList.add("treecol-icon");
 
     this.appendChild(this.image);
     this._updateAttributes();
   }
 
   attributeChangedCallback() {
     if (!this.isConnectedAndReady) {
@@ -568,17 +568,17 @@ class MozThreadPaneTreeColpicker extends
     }
   }
 }
 customElements.define("thread-pane-treecolpicker", MozThreadPaneTreeColpicker, { extends: "treecolpicker" });
 
 // The menulist CE is defined lazily. Create one now to get menulist defined,
 // allowing us to inherit from it.
 if (!customElements.get("menulist")) {
-  delete document.createElement("menulist");
+  delete document.createXULElement("menulist");
 }
 customElements.whenDefined("menulist").then(() => {
   /**
    * MozMenulistEditable is a menulist widget that can be made editable by setting editable="true".
    * With an additional type="description" the list also contains an additional label that can hold
    * for instance, a description of a menu item.
    * It is typically used e.g. for the "Custom From Address..." feature to let the user chose and
    * edit the address to send from.
@@ -591,17 +591,17 @@ customElements.whenDefined("menulist").t
       }
 
       this.prepend(MozMenulistEditable.fragment.cloneNode(true));
       this._inputField = this.querySelector(".menulist-input");
       this._labelBox = this.querySelector(".menulist-label-box");
       this._dropmarker = this.querySelector(".menulist-dropmarker");
 
       if (this.getAttribute("type") == "description") {
-        this._description = document.createElement("label");
+        this._description = document.createXULElement("label");
         this._description.classList.add("menulist-description");
         this._description.setAttribute("crop", "right");
         this._description.setAttribute("flex", "10000");
         this._description.setAttribute("role", "none");
         this.querySelector(".menulist-label").after(this._description);
       }
 
       this.initializeAttributeInheritance();
@@ -789,30 +789,30 @@ class MozMailMultiEmailheaderfield exten
     this.addresses = [];
   }
 
   connectedCallback() {
     if (this.delayConnectedCallback() || this.hasChildNodes()) {
       return;
     }
 
-    this.longEmailAddresses = document.createElement("hbox");
+    this.longEmailAddresses = document.createXULElement("hbox");
     this.longEmailAddresses.classList.add("headerValueBox");
     this.longEmailAddresses.setAttribute("flex", "1");
     this.longEmailAddresses.setAttribute("singleline", "true");
     this.longEmailAddresses.setAttribute("align", "baseline");
 
-    this.emailAddresses = document.createElement("description");
+    this.emailAddresses = document.createXULElement("description");
     this.emailAddresses.classList.add("class", "headerValue");
     this.emailAddresses.setAttribute("containsEmail", "true");
     this.emailAddresses.setAttribute("flex", "1");
     this.emailAddresses.setAttribute("orient", "vertical");
     this.emailAddresses.setAttribute("pack", "start");
 
-    this.more = document.createElement("label");
+    this.more = document.createXULElement("label");
     this.more.classList.add("class", "moreIndicator");
     this.more.addEventListener("click", this.toggleWrap.bind(this));
     this.more.setAttribute("collapsed", "true");
 
     this.longEmailAddresses.appendChild(this.emailAddresses);
     this.appendChild(this.longEmailAddresses);
     this.appendChild(this.more);
   }
@@ -901,17 +901,17 @@ class MozMailMultiEmailheaderfield exten
         }
       }
 
       // Now add an email address.
       if (cached-- > 0) {
         newAddressNode = this.emailAddresses.childNodes[i * 2];
         newAddressNode.hidden = false;
       } else {
-        newAddressNode = document.createElement("mail-emailaddress");
+        newAddressNode = document.createXULElement("mail-emailaddress");
 
         // Stash the headerName somewhere that UpdateEmailNodeDetails will be able to find it.
         newAddressNode.setAttribute("headerName", this.headerName);
 
         newAddressNode = this.emailAddresses.appendChild(newAddressNode);
       }
       this._updateEmailAddressNode(newAddressNode, this.addresses[i]);
 
@@ -999,17 +999,17 @@ class MozMailMultiEmailheaderfield exten
   }
 
   /**
    * Append a comma after the (currently) final (email address, we hope!) node of
    * this.emailAddresses.
    */
   appendComma() {
     // Create and append a comma.
-    let commaNode = document.createElement("text");
+    let commaNode = document.createXULElement("text");
     commaNode.setAttribute("value", ",");
     commaNode.setAttribute("class", "emailSeparator");
     this.emailAddresses.appendChild(commaNode);
   }
 
   /**
    * Add a (N more) widget which can be clicked to reveal the rest.
    */
--- a/mail/base/content/mailWindowOverlay.js
+++ b/mail/base/content/mailWindowOverlay.js
@@ -986,17 +986,17 @@ function InitMessageTags(menuPopup) {
 
   for (var i = 0; i < tagCount; ++i) {
     var taginfo = tagArray[i];
     let removeKey = (" " + curKeys + " ").includes(" " + taginfo.key + " ");
     if (taginfo.ordinal.includes("~AUTOTAG") && !removeKey)
       continue;
 
     // TODO we want to either remove or "check" the tags that already exist
-    var newMenuItem = document.createElement("menuitem");
+    var newMenuItem = document.createXULElement("menuitem");
     SetMessageTagLabel(newMenuItem, i + 1, taginfo.tag);
     newMenuItem.setAttribute("value", taginfo.key);
     newMenuItem.setAttribute("type", "checkbox");
     newMenuItem.setAttribute("checked", removeKey);
     newMenuItem.setAttribute("oncommand", "ToggleMessageTagMenu(event.target);");
     var color = taginfo.color;
     if (color)
       newMenuItem.setAttribute("style", "color: " + color + ";");
@@ -1012,31 +1012,31 @@ function InitRecentlyClosedTabsPopup(men
     return false;
 
   // Clear the list before rebuilding it.
   while (menuPopup.hasChildNodes())
     menuPopup.lastChild.remove();
 
   // Rebuild the recently closed tab list
   for (let i = 0; i < tabs.length; i++) {
-    let menuItem = document.createElement("menuitem");
+    let menuItem = document.createXULElement("menuitem");
     menuItem.setAttribute("label", tabs[i].title);
     menuItem.setAttribute("oncommand", `document.getElementById("tabmail").undoCloseTab(${i});`);
 
     if (i == 0)
       menuItem.setAttribute("key", "key_undoCloseTab");
 
     menuPopup.appendChild(menuItem);
   }
 
   // "Restore All Tabs" with only one entry does not make sense
   if (tabs.length > 1) {
-    menuPopup.appendChild(document.createElement("menuseparator"));
-
-    let menuItem = document.createElement("menuitem");
+    menuPopup.appendChild(document.createXULElement("menuseparator"));
+
+    let menuItem = document.createXULElement("menuitem");
     menuItem.setAttribute("label", document.getElementById("bundle_messenger")
                                            .getString("restoreAllTabs"));
     menuItem.setAttribute("oncommand", "goRestoreAllTabs();");
     menuPopup.appendChild(menuItem);
   }
 
   return true;
 }
@@ -1107,17 +1107,17 @@ function populateHistoryMenu(menuPopup, 
     if (msgHdr.flags & Ci.nsMsgMessageFlags.HasRe)
       subject = "Re: ";
     if (msgHdr.mime2DecodedSubject)
       subject += msgHdr.mime2DecodedSubject;
     if (subject)
       menuText += subject + " - ";
 
     menuText += msgHdr.mime2DecodedAuthor;
-    newMenuItem = document.createElement("menuitem");
+    newMenuItem = document.createXULElement("menuitem");
     newMenuItem.setAttribute("label", menuText);
     relPos += isBackMenu ? -1 : 1;
     newMenuItem.setAttribute("value", relPos);
     newMenuItem.folder = folder;
     newMenuItem.setAttribute("oncommand", "NavigateToUri(event.target); event.stopPropagation();");
     menuPopup.appendChild(newMenuItem);
     if (!(relPos % 20))
       break;
@@ -2787,17 +2787,17 @@ function onRemoteContentOptionsShowing(a
       childNodes[i].remove();
   }
 
 
   let urlSepar = document.getElementById("remoteContentAllMenuSeparator");
 
   // ... and in with the new.
   for (let origin of origins) {
-    let menuitem = document.createElement("menuitem");
+    let menuitem = document.createXULElement("menuitem");
     menuitem.setAttribute("label",
       messengerBundle.getFormattedString("remoteAllowResource",
         [origin.replace("chrome://messenger/content/email=", "")]));
     menuitem.setAttribute("value", origin);
     menuitem.setAttribute("class", "allow-remote-uri");
     menuitem.setAttribute("oncommand", "allowRemoteContentForURI(this.value);");
     if (origin.startsWith("chrome://messenger/content/email="))
       aEvent.target.appendChild(menuitem);
@@ -3254,17 +3254,17 @@ async function initAddonPrefsMenu(aMenup
   }
 
   // Populate the menu with addon names and icons.
   // Note: Having the following code in the getAddonsByTypes() async callback
   // above works on Windows and Linux but doesn't work on Mac, see bug 1419145.
   if (addonsFound.length > 0) {
     addonsFound.sort((a, b) => a.addon.name.localeCompare(b.addon.name));
     for (let { addon, optionsURL, optionsOpenInTab } of addonsFound) {
-      let newItem = document.createElement("menuitem");
+      let newItem = document.createXULElement("menuitem");
       newItem.setAttribute("label", addon.name);
       newItem.setAttribute("value", optionsURL);
       if (optionsOpenInTab) {
         newItem.setAttribute("optionsType", "tab");
       }
       let iconURL = addon.iconURL || addon.icon64URL;
       if (iconURL) {
         newItem.setAttribute("class", "menuitem-iconic");
--- a/mail/base/content/msgHdrView.js
+++ b/mail/base/content/msgHdrView.js
@@ -917,30 +917,30 @@ function HeaderView(headerName, label) {
   headerName = headerName.toLowerCase();
   let rowId = "expanded" + headerName + "Row";
   let idName = "expanded" + headerName + "Box";
   let newHeaderNode;
   // If a row for this header already exists, do not create another one.
   let newRowNode = document.getElementById(rowId);
   if (!newRowNode) {
     // Create new collapsed row.
-    newRowNode = document.createElement("row");
+    newRowNode = document.createXULElement("row");
     newRowNode.setAttribute("id", rowId);
     newRowNode.collapsed = true;
 
     // Create and append the label which contains the header name.
-    let newLabelNode = document.createElement("label");
+    let newLabelNode = document.createXULElement("label");
     newLabelNode.setAttribute("id", "expanded" + headerName + "Label");
     newLabelNode.setAttribute("value", label);
     newLabelNode.setAttribute("class", "headerName");
     newLabelNode.setAttribute("control", idName);
     newRowNode.appendChild(newLabelNode);
 
     // Create and append the new header value.
-    newHeaderNode = document.createElement("mail-headerfield");
+    newHeaderNode = document.createXULElement("mail-headerfield");
     newHeaderNode.setAttribute("id", idName);
     newHeaderNode.setAttribute("flex", "1");
 
     newRowNode.appendChild(newHeaderNode);
 
     // This new element needs to be inserted into the view...
     let topViewNode = document.getElementById("expandedHeader2Rows");
     topViewNode.appendChild(newRowNode);
@@ -2611,17 +2611,17 @@ function ClearAttachmentMenu(popup) {
  * @param popup  the popup to add the menu to
  * @param attachment  the AttachmentInfo object to add
  * @param attachmentIndex  the index (starting at 0) of this attachment
  */
 function addAttachmentToPopup(popup, attachment, attachmentIndex) {
   if (!popup)
     return;
 
-  var item = document.createElement("menu");
+  var item = document.createXULElement("menu");
   if (!item)
     return;
 
   function getString(aName) {
     return document.getElementById("bundle_messenger").getString(aName);
   }
 
   // Insert the item just before the separator. The separator is the 2nd to
@@ -2642,17 +2642,17 @@ function addAttachmentToPopup(popup, att
                       .getFormattedString("attachmentDisplayNameFormat",
                                           [attachmentIndex, displayName]);
   item.setAttribute("crop", "center");
   item.setAttribute("label", label);
   item.setAttribute("accesskey", attachmentIndex % 10);
 
   // Each attachment in the list gets its own menupopup with options for
   // saving, deleting, detaching, etc.
-  var openpopup = document.createElement("menupopup");
+  var openpopup = document.createXULElement("menupopup");
   openpopup = item.appendChild(openpopup);
   openpopup.addEventListener("popupshowing", function(aEvent) {
     aEvent.stopPropagation();
   });
 
   // Due to Bug #314228, we must append our menupopup to the new attachment
   // menu item before we inserting the attachment menu into the popup. If we
   // don't, our attachment menu items will not show up.
@@ -2680,60 +2680,60 @@ function addAttachmentToPopup(popup, att
 
   if (deleted) {
     // We can't do anything with a deleted attachment, so just return.
     item.disabled = true;
     return;
   }
 
   // Create the "open" menu item
-  var menuitementry = document.createElement("menuitem");
+  var menuitementry = document.createXULElement("menuitem");
   menuitementry.attachment = attachment;
   menuitementry.setAttribute("oncommand", "this.attachment.open();");
   menuitementry.setAttribute("label", getString("openLabel"));
   menuitementry.setAttribute("accesskey", getString("openLabelAccesskey"));
   menuitementry.setAttribute("disabled", deleted);
   menuitementry = openpopup.appendChild(menuitementry);
 
   // Create a menuseparator
-  var menuseparator = document.createElement("menuseparator");
+  var menuseparator = document.createXULElement("menuseparator");
   openpopup.appendChild(menuseparator);
 
   // Create the "save" menu item
-  menuitementry = document.createElement("menuitem");
+  menuitementry = document.createXULElement("menuitem");
   menuitementry.attachment = attachment;
   menuitementry.setAttribute("oncommand", "this.attachment.save();");
   menuitementry.setAttribute("label", getString("saveLabel"));
   menuitementry.setAttribute("accesskey", getString("saveLabelAccesskey"));
   menuitementry.setAttribute("disabled", deleted);
   menuitementry = openpopup.appendChild(menuitementry);
 
   // Create the "detach" menu item
-  menuitementry = document.createElement("menuitem");
+  menuitementry = document.createXULElement("menuitem");
   menuitementry.attachment = attachment;
   menuitementry.setAttribute("oncommand", "this.attachment.detach(true);");
   menuitementry.setAttribute("label", getString("detachLabel"));
   menuitementry.setAttribute("accesskey", getString("detachLabelAccesskey"));
   menuitementry.setAttribute("disabled", !canDetach);
   menuitementry = openpopup.appendChild(menuitementry);
 
   // Create the "delete" menu item
-  menuitementry = document.createElement("menuitem");
+  menuitementry = document.createXULElement("menuitem");
   menuitementry.attachment = attachment;
   menuitementry.setAttribute("oncommand", "this.attachment.detach(false);");
   menuitementry.setAttribute("label", getString("deleteLabel"));
   menuitementry.setAttribute("accesskey", getString("deleteLabelAccesskey"));
   menuitementry.setAttribute("disabled", !canDetach);
   menuitementry = openpopup.appendChild(menuitementry);
 
   // Create the "open containing folder" menu item, for existing detached only.
   if (attachment.isFileAttachment) {
-    let menuseparator = document.createElement("menuseparator");
+    let menuseparator = document.createXULElement("menuseparator");
     openpopup.appendChild(menuseparator);
-    menuitementry = document.createElement("menuitem");
+    menuitementry = document.createXULElement("menuitem");
     menuitementry.attachment = attachment;
     menuitementry.setAttribute("oncommand", "this.attachment.openFolder();");
     menuitementry.setAttribute("label", getString("openFolderLabel"));
     menuitementry.setAttribute("accesskey", getString("openFolderLabelAccesskey"));
     menuitementry.setAttribute("disabled", !attachment.hasFile);
     menuitementry = openpopup.appendChild(menuitementry);
   }
 }
--- a/mail/base/content/specialTabs.js
+++ b/mail/base/content/specialTabs.js
@@ -714,17 +714,17 @@ var specialTabs = {
         throw new Error("contentPage must be specified");
 
       // First clone the page and set up the basics.
       let clone = document.getElementById("contentTab").firstChild.cloneNode(true);
 
       if ("opener" in aArgs && aArgs.opener)
         clone.querySelector("browser").presetOpenerWindow(aArgs.opener);
 
-      const findbar = document.createElement("findbar");
+      const findbar = document.createXULElement("findbar");
       // Adding browserid to findbar so that browser property can be set
       // in findbar custom element.
       findbar.setAttribute("browserid", "dummycontentbrowser");
       clone.appendChild(findbar);
 
       clone.setAttribute("id", "contentTab" + this.lastBrowserId);
       clone.setAttribute("collapsed", false);
 
--- a/mail/base/content/statuspanel.js
+++ b/mail/base/content/statuspanel.js
@@ -6,20 +6,20 @@
 /* global MozXULElement */
 
 class MozStatuspanel extends MozXULElement {
   static get observedAttributes() {
     return ["label", "mirror"];
   }
 
   connectedCallback() {
-    const hbox = document.createElement("hbox");
+    const hbox = document.createXULElement("hbox");
     hbox.classList.add("statuspanel-inner");
 
-    const label = document.createElement("label");
+    const label = document.createXULElement("label");
     label.classList.add("statuspanel-label");
     label.setAttribute("flex", "1");
     label.setAttribute("crop", "end");
 
     hbox.appendChild(label);
     this.appendChild(hbox);
 
     this._labelElement = label;
--- a/mail/components/accountcreation/content/emailWizard.js
+++ b/mail/components/accountcreation/content/emailWizard.js
@@ -771,23 +771,23 @@ EmailConfigWizard.prototype = {
     e("status_msg").textContent = msg;
     gEmailWizardLogger.info("status msg: " + msg);
   },
 
   // UI to show status updates in parallel
 
   addStatusLine(msgID, call) {
     _show("status-lines");
-    var statusLine = document.createElement("hbox");
+    var statusLine = document.createXULElement("hbox");
     e("status-lines").appendChild(statusLine);
     statusLine.classList.add("status-line");
-    var statusDescr = document.createElement("description");
+    var statusDescr = document.createXULElement("description");
     statusDescr.classList.add("status_msg");
     statusLine.appendChild(statusDescr);
-    var statusImg = document.createElement("vbox");
+    var statusImg = document.createXULElement("vbox");
     statusImg.classList.add("status-img");
     statusImg.setAttribute("pack", "start");
     statusLine.appendChild(statusImg);
     let msg = msgID;
     try {
       msg = gStringsBundle.getFormattedString(msgID, [gBrandShortName]);
     } catch (e) {
       console.error(e);
@@ -896,20 +896,20 @@ EmailConfigWizard.prototype = {
             //     A third party addon that ...
             //   </label>
             //   <button
             //     class="larger-button"
             //     orient="vertical" crop="right"
             //     label="Install"
             //     oncommand="…" />
             // </row>
-            let addonE = document.createElement("row");
-            let iconE = document.createElement("image");
-            let descrE = document.createElement("label", {is: "text-link"}); // must be <label> to be clickable
-            let buttonE = document.createElement("button");
+            let addonE = document.createXULElement("row");
+            let iconE = document.createXULElement("image");
+            let descrE = document.createXULElement("label", {is: "text-link"}); // must be <label> to be clickable
+            let buttonE = document.createXULElement("button");
             addonE.appendChild(iconE);
             addonE.appendChild(descrE);
             addonE.appendChild(buttonE);
             containerE.appendChild(addonE);
             addonE.setAttribute("align", "center");
             iconE.classList.add("icon");
             if (addon.icon32) {
               iconE.setAttribute("src", addon.icon32);
@@ -948,17 +948,17 @@ EmailConfigWizard.prototype = {
       let ssl = gStringsBundle.getString(sanitize.translate(server.socketType,
           { 1: "resultNoEncryption", 2: "resultSSL", 3: "resultSTARTTLS" }),
           unknownString);
       let certStatus = gStringsBundle.getString(server.badCert ?
           "resultSSLCertWeak" : "resultSSLCertOK");
       // TODO: we should really also display authentication method here.
 
       function _addComponent(text, className) {
-        let textE = document.createElement("label");
+        let textE = document.createXULElement("label");
         textE.classList.add(className);
         textE.textContent = text;
         descrE.appendChild(textE);
       }
       removeChildNodes(descrE);
       _addComponent(type, "protocolType");
       _addComponent(host, "host-without-domain");
       _addComponent(domain, "domain");
--- a/mail/components/activity/content/activity.js
+++ b/mail/components/activity/content/activity.js
@@ -21,17 +21,17 @@ var activityObject = {
 
   // Utility Functions for Activity element management
 
   /**
    * Creates the proper element for the given activity
    */
   createActivityWidget(type) {
     let builtInName = type.bindingName;
-    let element = document.createElement("richlistitem", { is: builtInName });
+    let element = document.createXULElement("richlistitem", { is: builtInName });
 
     if (element) {
       element.setAttribute("actID", type.id);
     }
 
     return element;
   },
 
@@ -88,17 +88,17 @@ var activityObject = {
 
       // find out if an activity group has already been created for this context
       let group = null;
       if (isGroupByContext) {
         group = this.getActivityGroupElementByContext(aActivity.contextType,
                                                  aActivity.contextObj);
         // create a group if it's not already created.
         if (!group) {
-          group = document.createElement("richlistitem", { is: "activity-group" });
+          group = document.createXULElement("richlistitem", { is: "activity-group" });
           this._activityLogger.info("created group element");
           // Set the context type and object of the newly created group
           group.contextType = aActivity.contextType;
           group.contextObj = aActivity.contextObj;
           group.contextDisplayText = aActivity.contextDisplayText;
 
           // add group into the list
           this.placeActivityElement(group);
--- a/mail/components/addrbook/content/abCard.js
+++ b/mail/components/addrbook/content/abCard.js
@@ -388,25 +388,25 @@ function InitPhoneticFields() {
 function InitBirthDateFields() {
   let birthMonth = document.getElementById("BirthMonth");
   let birthDay = document.getElementById("BirthDay");
   let birthYear = document.getElementById("BirthYear");
 
   if (birthMonth.menupopup.childElementCount == 1) {
     let formatter = Intl.DateTimeFormat(undefined, { month: "long" });
     for (let m = 1; m <= 12; m++) {
-      let menuitem = document.createElement("menuitem");
+      let menuitem = document.createXULElement("menuitem");
       menuitem.setAttribute("value", m);
       menuitem.setAttribute("label", formatter.format(new Date(2000, m - 1, 2)));
       birthMonth.menupopup.appendChild(menuitem);
     }
 
     formatter = Intl.DateTimeFormat(undefined, { day: "numeric" });
     for (let d = 1; d <= 31; d++) {
-      let menuitem = document.createElement("menuitem");
+      let menuitem = document.createXULElement("menuitem");
       menuitem.setAttribute("value", d);
       menuitem.setAttribute("label", formatter.format(new Date(2000, 0, d)));
       birthDay.menupopup.appendChild(menuitem);
     }
   }
 
   birthMonth.addEventListener("command", setDisabledMonthDays);
   birthYear.addEventListener("change", setDisabledMonthDays);
--- a/mail/components/addrbook/content/abCardView.js
+++ b/mail/components/addrbook/content/abCardView.js
@@ -475,17 +475,17 @@ function cvAddAddressNodes(node, uri) {
 
     if (addressList) {
       var total = addressList.length;
       if (total > 0) {
         while (node.hasChildNodes()) {
           node.lastChild.remove();
         }
         for (let i = 0; i < total; i++) {
-          var descNode = document.createElement("description");
+          var descNode = document.createXULElement("description");
           var card = addressList.queryElementAt(i, Ci.nsIAbCard);
 
           descNode.setAttribute("class", "CardViewLink");
           node.appendChild(descNode);
 
           var linkNode = document.createElementNS("http://www.w3.org/1999/xhtml", "a");
           linkNode.setAttribute("id", "addr#" + i);
           linkNode.setAttribute("href", "mailto:" + card.primaryEmail);
--- a/mail/components/addrbook/content/menulist-addrbooks.js
+++ b/mail/components/addrbook/content/menulist-addrbooks.js
@@ -1,16 +1,16 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
 
  // The menulist CE is defined lazily. Create one now to get menulist defined,
 // allowing us to inherit from it.
 if (!customElements.get("menulist")) {
-  delete document.createElement("menulist");
+  delete document.createXULElement("menulist");
 }
 
 customElements.whenDefined("menulist").then(() => {
   const { MailServices } = ChromeUtils.import("resource:///modules/MailServices.jsm");
   const { fixIterator } = ChromeUtils.import("resource:///modules/iteratorUtils.jsm");
   /**
    * MozMenulistAddrbooks is a menulist widget that is automatically
    * populated with the complete address book list.
--- a/mail/components/compose/content/MsgComposeCommands.js
+++ b/mail/components/compose/content/MsgComposeCommands.js
@@ -199,17 +199,17 @@ function updateEditableFields(aDisable) 
 
 var PrintPreviewListener = {
   getPrintPreviewBrowser() {
     let browser = document.getElementById("cppBrowser");
     if (!gChromeState)
       gChromeState = {};
     preparePrintPreviewTitleHeader();
     if (!browser) {
-      browser = document.createElement("browser");
+      browser = document.createXULElement("browser");
       browser.setAttribute("id", "cppBrowser");
       browser.setAttribute("flex", "1");
       browser.setAttribute("disablehistory", "true");
       browser.setAttribute("type", "content");
       document.getElementById("headers-parent").
         insertBefore(browser, document.getElementById("appcontent"));
     }
     return browser;
@@ -1444,17 +1444,17 @@ function updateSendCommands(aHaveControl
   }
 }
 
 function addAttachCloudMenuItems(aParentMenu) {
   while (aParentMenu.hasChildNodes())
     aParentMenu.lastChild.remove();
 
   for (let account of cloudFileAccounts.configuredAccounts) {
-    let item = document.createElement("menuitem");
+    let item = document.createXULElement("menuitem");
     let iconURL = account.iconURL;
     item.cloudFileAccount = account;
     item.setAttribute("label", cloudFileAccounts.getDisplayName(account));
 
     if (iconURL) {
       item.setAttribute("class", "menu-iconic");
       item.setAttribute("image", iconURL);
     }
@@ -1469,17 +1469,17 @@ function addConvertCloudMenuItems(aParen
     afterNode.nextSibling.remove();
 
   if (!attachment.sendViaCloud) {
     let item = document.getElementById("convertCloudMenuItems_popup_convertAttachment");
     item.setAttribute("checked", "true");
   }
 
   for (let account of cloudFileAccounts.configuredAccounts) {
-    let item = document.createElement("menuitem");
+    let item = document.createXULElement("menuitem");
     let iconURL = account.iconURL;
     item.cloudFileAccount = account;
     item.setAttribute("label", cloudFileAccounts.getDisplayName(account));
     item.setAttribute("type", "radio");
     item.setAttribute("name", aRadioGroup);
 
     if (attachment.cloudFileAccount &&
         attachment.cloudFileAccount.accountKey == account.accountKey) {
@@ -2137,47 +2137,47 @@ function manageAttachmentNotification(aF
     let description = notification.querySelector("#attachmentReminderText");
     description.setAttribute("value", textValue);
     description = notification.querySelector("#attachmentKeywords");
     description.setAttribute("value", keywords);
     return;
   }
 
   // Construct the notification as we don't have one.
-  let msg = document.createElement("hbox");
+  let msg = document.createXULElement("hbox");
   msg.setAttribute("flex", "100");
   msg.onclick = function(event) {
     openOptionsDialog("paneCompose", "generalTab",
                       {subdialog: "attachment_reminder_button"});
   };
 
-  let msgText = document.createElement("label");
+  let msgText = document.createXULElement("label");
   msg.appendChild(msgText);
   msgText.id = "attachmentReminderText";
   msgText.setAttribute("crop", "end");
   msgText.setAttribute("flex", "1");
   msgText.setAttribute("value", textValue);
-  let msgKeywords = document.createElement("label");
+  let msgKeywords = document.createXULElement("label");
   msg.appendChild(msgKeywords);
   msgKeywords.id = "attachmentKeywords";
   msgKeywords.setAttribute("crop", "end");
   msgKeywords.setAttribute("flex", "1000");
   msgKeywords.setAttribute("value", keywords);
   let addButton = {
     accessKey: getComposeBundle().getString("addAttachmentButton.accesskey"),
     label: getComposeBundle().getString("addAttachmentButton"),
     callback(aNotificationBar, aButton) {
       goDoCommand("cmd_attachFile");
       return true; // keep notification open (the state machine will decide on it later)
     },
   };
 
-  let remindLaterMenuPopup = document.createElement("menupopup");
+  let remindLaterMenuPopup = document.createXULElement("menupopup");
   remindLaterMenuPopup.id = "reminderBarPopup";
-  let disableAttachmentReminder = document.createElement("menuitem");
+  let disableAttachmentReminder = document.createXULElement("menuitem");
   disableAttachmentReminder.id = "disableReminder";
   disableAttachmentReminder.setAttribute("label",
     getComposeBundle().getString("disableAttachmentReminderButton"));
   disableAttachmentReminder.setAttribute("command", "cmd_doNotRemindForAttachments");
   remindLaterMenuPopup.appendChild(disableAttachmentReminder);
 
   let remindButton = {
     type: "menu-button",
@@ -2455,27 +2455,27 @@ function onPasteOrDrop(e) {
     });
   }
 }
 
 /* eslint-disable complexity */
 function ComposeStartup(aParams) {
   // Findbar overlay
   if (!document.getElementById("findbar-replaceButton")) {
-    let replaceButton = document.createElement("toolbarbutton");
+    let replaceButton = document.createXULElement("toolbarbutton");
     replaceButton.setAttribute("id", "findbar-replaceButton");
     replaceButton.setAttribute("class", "findbar-button tabbable");
     replaceButton.setAttribute("label", getComposeBundle().getString("replaceButton.label"));
     replaceButton.setAttribute("accesskey", getComposeBundle().getString("replaceButton.accesskey"));
     replaceButton.setAttribute("tooltiptext", getComposeBundle().getString("replaceButton.tooltip"));
     replaceButton.setAttribute("oncommand", "findbarFindReplace();");
 
     let findbar = document.getElementById("FindToolbar");
     let lastButton = findbar.getElement("find-entire-word");
-    let tSeparator = document.createElement("toolbarseparator");
+    let tSeparator = document.createXULElement("toolbarseparator");
     tSeparator.setAttribute("id", "findbar-beforeReplaceSeparator");
     lastButton.parentNode.insertBefore(replaceButton, lastButton.nextSibling);
     lastButton.parentNode.insertBefore(tSeparator, lastButton.nextSibling);
   }
 
   var params = null; // New way to pass parameters to the compose window as a nsIMsgComposeParameters object
   var args = null;   // old way, parameters are passed as a string
   gBodyFromArgs = false;
@@ -3787,17 +3787,17 @@ function InitLanguageMenu() {
 
   var sortedList = gSpellChecker.sortDictionaryList(dictList);
 
   // Remove any languages from the list.
   while (languageMenuList.hasChildNodes())
     languageMenuList.lastChild.remove();
 
   for (let i = 0; i < count; i++) {
-    var item = document.createElement("menuitem");
+    var item = document.createXULElement("menuitem");
     item.setAttribute("label", sortedList[i].displayName);
     item.setAttribute("value", sortedList[i].localeCode);
     item.setAttribute("type", "radio");
     languageMenuList.appendChild(item);
   }
 }
 
 function OnShowDictionaryMenu(aTarget) {
@@ -3960,17 +3960,17 @@ function FillIdentityList(menulist) {
 
     let needSeparator = (identities.length > 1);
     if (needSeparator || accountHadSeparator) {
       // Separate identities from this account from the previous
       // account's identities if there is more than 1 in the current
       // or previous account.
       if (!firstAccountWithIdentities) {
         // only if this is not the first account shown
-        let separator = document.createElement("menuseparator");
+        let separator = document.createXULElement("menuseparator");
         menulist.menupopup.appendChild(separator);
       }
       accountHadSeparator = needSeparator;
     }
     firstAccountWithIdentities = false;
 
     for (let i = 0; i < identities.length; i++) {
       let identity = identities[i];
@@ -3989,18 +3989,18 @@ function FillIdentityList(menulist) {
       desc.value = item.getAttribute("description");
       desc.classList.add("menu-description");
       desc.setAttribute("crop", "right");
       desc.setAttribute("flex", "10000");
       item.querySelector("label:last-child").after(desc);
     }
   }
 
-  menulist.menupopup.appendChild(document.createElement("menuseparator"));
-  menulist.menupopup.appendChild(document.createElement("menuitem"))
+  menulist.menupopup.appendChild(document.createXULElement("menuseparator"));
+  menulist.menupopup.appendChild(document.createXULElement("menuitem"))
           .setAttribute("command", "cmd_customizeFromAddress");
 }
 
 function getCurrentAccountKey() {
   // Get the account's key.
   let identityList = GetMsgIdentityElement();
   return identityList.selectedItem.getAttribute("accountkey");
 }
@@ -6833,17 +6833,17 @@ function onBlockedContentOptionsShowing(
   // Out with the old...
   let childNodes = aEvent.target.childNodes;
   for (let i = childNodes.length - 1; i >= 0; i--) {
     childNodes[i].remove();
   }
 
   // ... and in with the new.
   for (let url of urls) {
-    let menuitem = document.createElement("menuitem");
+    let menuitem = document.createXULElement("menuitem");
     menuitem.setAttribute("label",
       getComposeBundle().getFormattedString("blockedAllowResource", [url]));
     menuitem.setAttribute("crop", "center");
     menuitem.setAttribute("value", url);
     menuitem.setAttribute("oncommand",
                           "onUnblockResource(this.value, this.parentNode);");
     aEvent.target.appendChild(menuitem);
   }
--- a/mail/components/compose/content/addressingWidgetOverlay.js
+++ b/mail/components/compose/content/addressingWidgetOverlay.js
@@ -904,17 +904,17 @@ function awCalcContentHeight() {
     gAWContentHeight = gAWRowHeight * items.length;
   }
 }
 
 function awCreateDummyItem(aParent) {
   var listbox = document.getElementById("addressingWidget");
   var item = listbox.getItemAtIndex(0);
 
-  var titem = document.createElement("richlistitem");
+  var titem = document.createXULElement("richlistitem");
   titem.setAttribute("_isDummyRow", "true");
   titem.setAttribute("class", "dummy-row");
   titem.style.height = item.getBoundingClientRect().height + "px";
 
   for (let i = 0; i < awGetNumberOfCols(); i++) {
     let cell = awCreateDummyCell(titem);
     if (item.children[i].hasAttribute("style")) {
       cell.setAttribute("style", item.children[i].getAttribute("style"));
@@ -927,17 +927,17 @@ function awCreateDummyItem(aParent) {
   if (aParent) {
     aParent.appendChild(titem);
   }
 
   return titem;
 }
 
 function awCreateDummyCell(aParent) {
-  var cell = document.createElement("hbox");
+  var cell = document.createXULElement("hbox");
   cell.setAttribute("class", "addressingWidgetCell dummy-row-cell");
   if (aParent)
     aParent.appendChild(cell);
 
   return cell;
 }
 
 function awGetNextDummyRow() {
--- a/mail/components/downloads/content/aboutDownloads.js
+++ b/mail/components/downloads/content/aboutDownloads.js
@@ -216,45 +216,45 @@ DownloadItem.prototype = {
     }
     return false;
   },
 
   get download() { return this._download; },
 
   get element() {
     if (!this._element) {
-      this._element = this.createElement();
+      this._element = this.createXULElement();
     }
 
     return this._element;
   },
 
-  createElement() {
-    let element = document.createElement("richlistitem");
+  createXULElement() {
+    let element = document.createXULElement("richlistitem");
     element.classList.add("download");
 
-    let image = document.createElement("image");
+    let image = document.createXULElement("image");
     image.setAttribute("validate", "always");
     image.classList.add("fileTypeIcon");
 
-    let vbox = document.createElement("vbox");
+    let vbox = document.createXULElement("vbox");
     vbox.setAttribute("pack", "center");
     vbox.setAttribute("flex", "1");
 
-    let sender = document.createElement("description");
+    let sender = document.createXULElement("description");
     sender.classList.add("sender");
 
-    let fileName = document.createElement("description");
+    let fileName = document.createXULElement("description");
     fileName.setAttribute("crop", "center");
     fileName.classList.add("fileName");
 
-    let size = document.createElement("description");
+    let size = document.createXULElement("description");
     size.classList.add("size");
 
-    let startDate = document.createElement("description");
+    let startDate = document.createXULElement("description");
     startDate.setAttribute("crop", "end");
     startDate.classList.add("startDate");
 
     vbox.appendChild(fileName);
     vbox.appendChild(size);
     vbox.appendChild(startDate);
 
     element.appendChild(image);
--- a/mail/components/im/content/chat-group.js
+++ b/mail/components/im/content/chat-group.js
@@ -22,20 +22,20 @@ class MozChatGroup extends MozElements.M
   connectedCallback() {
     if (this.delayConnectedCallback() || this.hasChildNodes()) {
       return;
     }
 
     this.setAttribute("is", "chat-group");
     this.setAttribute("collapsed", "true");
 
-    this._image = document.createElement("image");
+    this._image = document.createXULElement("image");
     this._image.classList.add("twisty");
 
-    this._label = document.createElement("label");
+    this._label = document.createXULElement("label");
     this._label.setAttribute("flex", "1");
     this._label.setAttribute("crop", "end");
 
     this.appendChild(this._image);
     this.appendChild(this._label);
 
     this.contacts = [];
 
@@ -83,19 +83,19 @@ class MozChatGroup extends MozElements.M
 
   addContact(contact, tagName) {
     if (this.contactsById.hasOwnProperty(contact.id)) {
       return null;
     }
 
     let contactElt;
     if (tagName) {
-      contactElt = document.createElement("richlistitem", { is: "chat-imconv" });
+      contactElt = document.createXULElement("richlistitem", { is: "chat-imconv" });
     } else {
-      contactElt = document.createElement("richlistitem", { is: "chat-contact" });
+      contactElt = document.createXULElement("richlistitem", { is: "chat-contact" });
     }
     if (this.classList.contains("closed")) {
       contactElt.setAttribute("collapsed", "true");
     }
 
     let end = this.contacts.length;
     // Avoid the binary search loop if the contacts were already sorted.
     if (end != 0 &&
--- a/mail/components/im/content/chat-messenger.js
+++ b/mail/components/im/content/chat-messenger.js
@@ -671,17 +671,17 @@ var chatHandler = {
           this._pendingSearchTerm = item.searchTerm || undefined;
           this._showLogList(aSimilarLogs, aLog);
         });
       });
     } else if (item.localName == "richlistitem" && item.getAttribute("is") == "chat-imconv") {
       let convDeck = document.getElementById("conversationsDeck");
       if (!item.convView) {
         // Create new conversation binding.
-        let conv = document.createElement("imconversation");
+        let conv = document.createXULElement("imconversation");
         convDeck.appendChild(conv);
         conv.conv = item.conv;
         conv.tab = item;
         conv.setAttribute("contentcontextmenu", "chatConversationContextMenu");
         conv.setAttribute("contenttooltip", "imTooltip");
         item.convView = conv;
         document.getElementById("contextSplitter").hidden = false;
         document.getElementById("contextPane").hidden = false;
--- a/mail/components/im/content/imAccountWizard.js
+++ b/mail/components/im/content/imAccountWizard.js
@@ -33,23 +33,23 @@ var accountWizard = {
     for (let proto of this.getProtocols())
       protos.push(proto);
     protos.sort((a, b) => {
       if (a.name < b.name)
         return -1;
       return a.name > b.name ? 1 : 0;
     });
     protos.forEach(function(proto) {
-      let image = document.createElement("image");
+      let image = document.createXULElement("image");
       image.setAttribute("src", proto.iconBaseURI + "icon.png");
 
-      let label = document.createElement("label");
+      let label = document.createXULElement("label");
       label.setAttribute("value", proto.name);
 
-      let item = document.createElement("richlistitem");
+      let item = document.createXULElement("richlistitem");
       item.setAttribute("value", proto.id);
       item.appendChild(image);
       item.appendChild(label);
       protoList.appendChild(item);
     });
 
     // there is a strange selection bug without this timeout
     setTimeout(function() {
@@ -97,28 +97,28 @@ var accountWizard = {
   selectProtocol() {
     var protoList = document.getElementById("protolist");
     var id = protoList.selectedItem.value;
     this.proto = Services.core.getProtocolById(id);
   },
 
 
   insertUsernameField(aName, aLabel, aParent, aDefaultValue) {
-    var hbox = document.createElement("hbox");
+    var hbox = document.createXULElement("hbox");
     hbox.setAttribute("id", aName + "-hbox");
     hbox.setAttribute("align", "baseline");
     hbox.setAttribute("equalsize", "always");
 
-    var label = document.createElement("label");
+    var label = document.createXULElement("label");
     label.setAttribute("value", aLabel);
     label.setAttribute("control", aName);
     label.setAttribute("id", aName + "-label");
     hbox.appendChild(label);
 
-    var textbox = document.createElement("textbox");
+    var textbox = document.createXULElement("textbox");
     textbox.setAttribute("id", aName);
     textbox.setAttribute("flex", 1);
     if (aDefaultValue)
       textbox.setAttribute("value", aDefaultValue);
     textbox.addEventListener("input", accountWizard.checkUsername);
     hbox.appendChild(textbox);
 
     aParent.appendChild(hbox);
@@ -198,33 +198,33 @@ var accountWizard = {
     if (haveOptions) {
       var bundle = document.getElementById("accountsBundle");
       document.getElementById("protoSpecificCaption").label =
         bundle.getFormattedString("protoOptions", [this.proto.name]);
     }
   },
 
   createSummaryRow(aLabel, aValue) {
-    var hbox = document.createElement("hbox");
+    var hbox = document.createXULElement("hbox");
     hbox.setAttribute("align", "baseline");
     hbox.setAttribute("equalsize", "always");
 
-    var label = document.createElement("label");
+    var label = document.createXULElement("label");
     label.setAttribute("class", "header");
     if (aLabel.length > 20) {
       aLabel = aLabel.substring(0, 20);
       aLabel += "…";
     }
 
     label.setAttribute("value", aLabel);
-    var hboxWrapper = document.createElement("hbox");
+    var hboxWrapper = document.createXULElement("hbox");
     hboxWrapper.appendChild(label);
     hbox.appendChild(hboxWrapper);
 
-    var textbox = document.createElement("textbox");
+    var textbox = document.createXULElement("textbox");
     textbox.setAttribute("value", aValue);
     textbox.setAttribute("class", "plain");
     textbox.setAttribute("readonly", true);
     hbox.appendChild(textbox);
 
     return hbox;
   },
 
--- a/mail/components/im/content/imAccounts.js
+++ b/mail/components/im/content/imAccounts.js
@@ -50,17 +50,17 @@ var gAccountManager = {
 
   load() {
     // Wait until the password service is ready before offering anything.
     Services.logins.initializationPromise.then(() => {
       this.accountList = document.getElementById("accountlist");
       let defaultID;
       Services.core.init(); // ensure the imCore is initialized.
       for (let acc of this.getAccounts()) {
-        let elt = document.createElement("richlistitem", { is: "chat-account-richlistitem" });
+        let elt = document.createXULElement("richlistitem", { is: "chat-account-richlistitem" });
         this.accountList.appendChild(elt);
         elt.build(acc);
         if (!defaultID && acc.firstConnectionState == acc.FIRST_CONNECTION_CRASHED)
           defaultID = acc.id;
       }
       for (let event of events)
         Services.obs.addObserver(this, event);
       if (!this.accountList.getRowCount()) {
@@ -144,17 +144,17 @@ var gAccountManager = {
       return;
     }
 
     // The following notification handlers need an account.
     aObject.QueryInterface(Ci.imIAccount);
 
     if (aTopic == "account-added") {
       document.getElementById("accountsDesk").selectedIndex = 1;
-      let elt = document.createElement("richlistitem", { is: "chat-account-richlistitem" });
+      let elt = document.createXULElement("richlistitem", { is: "chat-account-richlistitem" });
       this.accountList.appendChild(elt);
       elt.build(aObject);
       if (this.accountList.getRowCount() == 1)
         this.accountList.selectedIndex = 0;
     } else if (aTopic == "account-removed") {
       let elt = document.getElementById(aObject.id);
       elt.destroy();
       if (!elt.selected) {
--- a/mail/components/im/content/imContextMenu.js
+++ b/mail/components/im/content/imContextMenu.js
@@ -86,17 +86,17 @@ imContextMenu.prototype = {
 
     // Copy link location depends on whether we're on a non-mailto link.
     this.showItem("context-copylink", this.onLink && !this.onMailtoLink);
     this.showItem("context-sep-copylink", this.onLink && this.isContentSelected);
 
     // Display action menu items.
     let sep = document.getElementById("context-sep-messageactions");
     for (let action of actions) {
-      let menuitem = document.createElement("menuitem");
+      let menuitem = document.createXULElement("menuitem");
       menuitem.setAttribute("label", action.label);
       menuitem.setAttribute("oncommand", "this.action.run();");
       menuitem.action = action;
       sep.parentNode.appendChild(menuitem);
     }
   },
 
   // Set various context menu attributes based on the state of the world.
@@ -203,17 +203,17 @@ imContextMenu.prototype = {
       document.getElementById(aItemOrId) : aItemOrId;
     if (item)
       item.hidden = !aShow;
   },
 
   // Temporary workaround for DOM api not yet implemented by XUL nodes.
   cloneNode(aItem) {
     // Create another element like the one we're cloning.
-    var node = document.createElement(aItem.tagName);
+    var node = document.createXULElement(aItem.tagName);
 
     // Copy attributes from argument item to the new one.
     var attrs = aItem.attributes;
     for (var i = 0; i < attrs.length; i++) {
       var attr = attrs.item(i);
       node.setAttribute(attr.nodeName, attr.nodeValue);
     }
 
--- a/mail/components/im/content/joinchat.js
+++ b/mail/components/im/content/joinchat.js
@@ -40,30 +40,30 @@ var joinChat = {
 
     let protoId = acc.protocol.id;
     document.getElementById("autojoin").hidden =
       !(protoId == "prpl-irc" || protoId == "prpl-jabber" ||
       protoId == "prpl-gtalk");
 
     for (let field of fixIterator(acc.getChatRoomFields())) {
       let div1 = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
-      let label = document.createElement("label");
+      let label = document.createXULElement("label");
       let text = field.label;
       let match = /_(.)/.exec(text);
       if (match) {
         label.setAttribute("accesskey", match[1]);
         text = text.replace(/_/, "");
       }
       label.setAttribute("value", text);
       label.setAttribute("control", "field-" + field.identifier);
       div1.appendChild(label);
       joinChatGrid.appendChild(div1);
 
       let div2 = document.createElementNS("http://www.w3.org/1999/xhtml", "div");
-      let textbox = document.createElement("textbox");
+      let textbox = document.createXULElement("textbox");
       textbox.setAttribute("id", "field-" + field.identifier);
       let val = defaultValues.getValue(field.identifier);
       if (val) {
         textbox.setAttribute("value", val);
       }
       if (field.type == Ci.prplIChatRoomField.TYPE_PASSWORD) {
         textbox.setAttribute("type", "password");
       } else if (field.type == Ci.prplIChatRoomField.TYPE_INT) {
--- a/mail/components/migration/content/migration.js
+++ b/mail/components/migration/content/migration.js
@@ -167,17 +167,17 @@ var MigrationWizard = {
       profiles.lastChild.remove();
 
     if (!this._migrator) {
       return;
     }
     var sourceProfiles = this._migrator.sourceProfiles;
     var count = sourceProfiles.length;
     for (var i = 0; i < count; ++i) {
-      var item = document.createElement("radio");
+      var item = document.createXULElement("radio");
       item.id = sourceProfiles.queryElementAt(i, nsISupportsString).data;
       item.setAttribute("label", item.id);
       profiles.appendChild(item);
     }
 
     profiles.selectedItem = this._selectedProfile ? document.getElementById(this._selectedProfile) : profiles.firstChild;
   },
 
@@ -202,17 +202,17 @@ var MigrationWizard = {
       dataSources.lastChild.remove();
 
     var bundle = document.getElementById("bundle");
 
     var items = this._migrator.getMigrateData(this._selectedProfile, this._autoMigrate);
     for (var i = 0; i < 16; ++i) {
       var itemID = (items >> i) & 0x1 ? Math.pow(2, i) : 0;
       if (itemID > 0) {
-        var checkbox = document.createElement("checkbox");
+        var checkbox = document.createXULElement("checkbox");
         checkbox.id = itemID;
         checkbox.setAttribute("label", bundle.getString(itemID + "_" + this._source));
         dataSources.appendChild(checkbox);
         if (!this._itemsFlags || this._itemsFlags & itemID)
           checkbox.checked = true;
       }
     }
   },
@@ -266,17 +266,17 @@ var MigrationWizard = {
     var items = document.getElementById(aID);
     while (items.hasChildNodes())
       items.lastChild.remove();
 
     var bundle = document.getElementById("bundle");
     for (var i = 0; i < 16; ++i) {
       var itemID = (this._itemsFlags >> i) & 0x1 ? Math.pow(2, i) : 0;
       if (itemID > 0) {
-        var label = document.createElement("label");
+        var label = document.createXULElement("label");
         label.id = itemID + "_migrated";
         try {
           label.setAttribute("value", "- " + bundle.getString(itemID + "_" + this._source));
           items.appendChild(label);
         } catch (e) {
           // if the block above throws, we've enumerated all the import data types we
           // currently support and are now just wasting time, break.
           break;
--- a/mail/components/preferences/advanced.js
+++ b/mail/components/preferences/advanced.js
@@ -610,17 +610,17 @@ var gAdvancedPane = {
   async setMessengerLocales(selected) {
     let available = await getAvailableLocales();
     let localeNames = Services.intl.getLocaleDisplayNames(undefined, available);
     let locales = available.map((code, i) => ({code, name: localeNames[i]}));
     locales.sort((a, b) => a.name > b.name);
 
     let fragment = document.createDocumentFragment();
     for (let {code, name} of locales) {
-      let menuitem = document.createElement("menuitem");
+      let menuitem = document.createXULElement("menuitem");
       menuitem.setAttribute("value", code);
       menuitem.setAttribute("label", name);
       fragment.appendChild(menuitem);
     }
 
     // Add an option to search for more languages if downloading is supported.
     if (Services.prefs.getBoolPref("intl.multilingual.downloadEnabled")) {
       let menuitem = document.createXULElement("menuitem");
--- a/mail/components/preferences/applicationManager.js
+++ b/mail/components/preferences/applicationManager.js
@@ -29,21 +29,21 @@ var gAppManagerDialog = {
       app.QueryInterface(Ci.nsIHandlerApp);
 
       // Ensure the XBL binding is created eagerly.
       // eslint-disable-next-line no-undef
       list.appendChild(MozXULElement.parseXULToFragment("<richlistitem/>"));
       let item = list.lastChild;
       item.app = app;
 
-      let image = document.createElement("image");
+      let image = document.createXULElement("image");
       image.setAttribute("src", gApplicationsPane._getIconURLForHandlerApp(app));
       item.appendChild(image);
 
-      let label = document.createElement("label");
+      let label = document.createXULElement("label");
       label.setAttribute("value", app.name);
       item.appendChild(label);
     }
 
     list.selectedIndex = 0;
   },
 
   onOK() {
--- a/mail/components/preferences/applications.js
+++ b/mail/components/preferences/applications.js
@@ -621,68 +621,68 @@ var gCloudFileTab = {
 
     if (this._buttonContainer.childElementCount < 1) {
       this._buttonContainer.hidden = false;
       this._addAccountButton.hidden = true;
     }
   },
 
   makeRichListItemForAccount(aAccount) {
-    let rli = document.createElement("richlistitem");
+    let rli = document.createXULElement("richlistitem");
     rli.value = aAccount.accountKey;
     rli.setAttribute("align", "center");
     rli.setAttribute("class", "cloudfileAccount");
     rli.setAttribute("value", aAccount.accountKey);
 
     if (aAccount.iconURL)
       rli.style.listStyleImage = "url('" + aAccount.iconURL + "')";
 
-    let icon = document.createElement("image");
+    let icon = document.createXULElement("image");
     icon.setAttribute("class", "typeIcon");
     rli.appendChild(icon);
 
-    let label = document.createElement("label");
+    let label = document.createXULElement("label");
     label.setAttribute("crop", "end");
     label.setAttribute("flex", "1");
     label.setAttribute("value", cloudFileAccounts.getDisplayName(aAccount.accountKey));
     label.addEventListener("click", this, true);
     rli.appendChild(label);
 
-    let textBox = document.createElement("textbox");
+    let textBox = document.createXULElement("textbox");
     textBox.setAttribute("flex", "1");
     textBox.hidden = true;
     textBox.addEventListener("blur", this);
     textBox.addEventListener("keypress", this);
     rli.appendChild(textBox);
 
-    let warningIcon = document.createElement("image");
+    let warningIcon = document.createXULElement("image");
     warningIcon.setAttribute("class", "configuredWarning typeIcon");
     warningIcon.setAttribute("src", "chrome://global/skin/icons/warning.svg");
     warningIcon.setAttribute("tooltiptext", this._strings.GetStringFromName("notConfiguredYet"));
     if (aAccount.configured) {
       warningIcon.hidden = true;
     }
     rli.appendChild(warningIcon);
 
     return rli;
   },
 
   makeButtonForProvider(provider) {
-    let button = document.createElement("button");
+    let button = document.createXULElement("button");
     button.setAttribute("value", provider.type);
     button.setAttribute(
       "label", this._strings.formatStringFromName("addProvider", [provider.displayName], 1)
     );
     button.setAttribute("oncommand", `gCloudFileTab.addCloudFileAccount("${provider.type}")`);
     button.style.listStyleImage = `url("${provider.iconURL}")`;
     return button;
   },
 
   makeListItemForProvider(provider) {
-    let menuitem = document.createElement("menuitem");
+    let menuitem = document.createXULElement("menuitem");
     menuitem.classList.add("menuitem-iconic");
     menuitem.setAttribute("value", provider.type);
     menuitem.setAttribute("label", provider.displayName);
     menuitem.setAttribute("image", provider.iconURL);
     return menuitem;
   },
 
   // Sort the accounts by displayName.
@@ -1150,47 +1150,47 @@ var gApplicationsPane = {
     var handlerInfo = this.selectedHandlerListItem.handlerInfoWrapper;
     var menu = typeItem.querySelector(".actionsMenu");
     var menuPopup = menu.menupopup;
 
     // Clear out existing items.
     while (menuPopup.hasChildNodes())
       menuPopup.lastChild.remove();
 
-    var askMenuItem = document.createElement("menuitem");
+    var askMenuItem = document.createXULElement("menuitem");
     askMenuItem.setAttribute("alwaysAsk", "true");
     {
       let label = this._prefsBundle.getString("alwaysAsk");
       askMenuItem.setAttribute("label", label);
       askMenuItem.setAttribute("tooltiptext", label);
       askMenuItem.setAttribute(APP_ICON_ATTR_NAME, "ask");
       menuPopup.appendChild(askMenuItem);
     }
 
     // Create a menu item for saving to disk.
     // Note: this option isn't available to protocol types, since we don't know
     // what it means to save a URL having a certain scheme to disk.
     if ((handlerInfo.wrappedHandlerInfo instanceof Ci.nsIMIMEInfo)) {
-      var saveMenuItem = document.createElement("menuitem");
+      var saveMenuItem = document.createXULElement("menuitem");
       saveMenuItem.setAttribute("action", Ci.nsIHandlerInfo.saveToDisk);
       let label = this._prefsBundle.getString("saveFile");
       saveMenuItem.setAttribute("label", label);
       saveMenuItem.setAttribute("tooltiptext", label);
       saveMenuItem.setAttribute(APP_ICON_ATTR_NAME, "save");
       menuPopup.appendChild(saveMenuItem);
     }
 
     // Add a separator to distinguish these items from the helper app items
     // that follow them.
-    let menuItem = document.createElement("menuseparator");
+    let menuItem = document.createXULElement("menuseparator");
     menuPopup.appendChild(menuItem);
 
     // Create a menu item for the OS default application, if any.
     if (handlerInfo.hasDefaultHandler) {
-      var defaultMenuItem = document.createElement("menuitem");
+      var defaultMenuItem = document.createXULElement("menuitem");
       defaultMenuItem.setAttribute("action", Ci.nsIHandlerInfo.useSystemDefault);
       let label = this._prefsBundle.getFormattedString("useDefault",
                                                        [handlerInfo.defaultDescription]);
       defaultMenuItem.setAttribute("label", label);
       defaultMenuItem.setAttribute("tooltiptext", handlerInfo.defaultDescription);
       defaultMenuItem.setAttribute("image", handlerInfo.iconURLForSystemDefault);
 
       menuPopup.appendChild(defaultMenuItem);
@@ -1200,17 +1200,17 @@ var gApplicationsPane = {
     let preferredApp = handlerInfo.preferredApplicationHandler;
     let possibleApps = handlerInfo.possibleApplicationHandlers.enumerate();
     var possibleAppMenuItems = [];
     while (possibleApps.hasMoreElements()) {
       let possibleApp = possibleApps.getNext();
       if (!gApplicationsPane.isValidHandlerApp(possibleApp))
         continue;
 
-      let menuItem = document.createElement("menuitem");
+      let menuItem = document.createXULElement("menuitem");
       menuItem.setAttribute("action", Ci.nsIHandlerInfo.useHelperApp);
       let label;
       if (possibleApp instanceof Ci.nsILocalHandlerApp)
         label = getDisplayNameForFile(possibleApp.executable);
       else
         label = possibleApp.name;
       label = this._prefsBundle.getFormattedString("useApp", [label]);
       menuItem.setAttribute("label", label);
@@ -1234,37 +1234,37 @@ var gApplicationsPane = {
       var executableType = Cc["@mozilla.org/mime;1"]
                              .getService(Ci.nsIMIMEService)
                              .getTypeFromExtension("exe");
       if (handlerInfo.type == executableType)
         createItem = false;
     }
 
     if (createItem) {
-      let menuItem = document.createElement("menuitem");
+      let menuItem = document.createXULElement("menuitem");
       menuItem.setAttribute("oncommand", "gApplicationsPane.chooseApp(event)");
       let label = this._prefsBundle.getString("useOtherApp");
       menuItem.setAttribute("label", label);
       menuItem.setAttribute("tooltiptext", label);
       menuPopup.appendChild(menuItem);
     }
 
     // Create a menu item for managing applications.
     if (possibleAppMenuItems.length) {
-      let menuItem = document.createElement("menuseparator");
+      let menuItem = document.createXULElement("menuseparator");
       menuPopup.appendChild(menuItem);
-      menuItem = document.createElement("menuitem");
+      menuItem = document.createXULElement("menuitem");
       menuItem.setAttribute("oncommand", "gApplicationsPane.manageApp(event)");
       menuItem.setAttribute("label", this._prefsBundle.getString("manageApp"));
       menuPopup.appendChild(menuItem);
     }
 
-    menuItem = document.createElement("menuseparator");
+    menuItem = document.createXULElement("menuseparator");
     menuPopup.appendChild(menuItem);
-    menuItem = document.createElement("menuitem");
+    menuItem = document.createXULElement("menuitem");
     menuItem.setAttribute("oncommand", "gApplicationsPane.confirmDelete(event)");
     menuItem.setAttribute("label", this._prefsBundle.getString("delete"));
     menuPopup.appendChild(menuItem);
 
     // Select the item corresponding to the preferred action.  If the always
     // ask flag is set, it overrides the preferred action.  Otherwise we pick
     // the item identified by the preferred action (when the preferred action
     // is to use a helper app, we have to pick the specific helper app item).
--- a/mail/components/preferences/chat.js
+++ b/mail/components/preferences/chat.js
@@ -73,17 +73,17 @@ var gChatPane = {
       return;
     }
     if (this.mTabBox.selectedIndex != 1) {
       return;
     }
 
     window.removeEventListener("paneSelected", this.paneSelectionChanged);
 
-    let browser = document.createElement("browser", { is: "conversation-browser" });
+    let browser = document.createXULElement("browser", { is: "conversation-browser" });
     browser.setAttribute("id", "previewbrowser");
     browser.setAttribute("type", "content");
     browser.setAttribute("flex", "1");
     browser.setAttribute("tooltip", "aHTMLTooltip");
     previewDeck.appendChild(browser);
     previewObserver.load();
   },
 
--- a/mail/components/preferences/messagestyle.js
+++ b/mail/components/preferences/messagestyle.js
@@ -112,41 +112,41 @@ var previewObserver = {
     } catch (e) {
       document.getElementById("previewDeck").selectedIndex = 0;
       return;
     }
 
     let menulist = document.getElementById("themevariant");
     if (menulist.menupopup)
       menulist.menupopup.remove();
-    let popup = menulist.appendChild(document.createElement("menupopup"));
+    let popup = menulist.appendChild(document.createXULElement("menupopup"));
     let variants = getThemeVariants(this.theme);
 
     let defaultVariant = "";
     if (("DefaultVariant" in this.theme.metadata) &&
         variants.includes(this.theme.metadata.DefaultVariant))
       defaultVariant = this.theme.metadata.DefaultVariant.replace(/_/g, " ");
 
     let defaultText = defaultVariant;
     if (!defaultText && ("DisplayNameForNoVariant" in this.theme.metadata))
       defaultText = this.theme.metadata.DisplayNameForNoVariant;
     // if the name in the metadata is 'Default', use the localized version
     if (!defaultText || defaultText.toLowerCase() == "default")
       defaultText = document.getElementById("themesBundle").getString("default");
 
-    let menuitem = document.createElement("menuitem");
+    let menuitem = document.createXULElement("menuitem");
     menuitem.setAttribute("label", defaultText);
     menuitem.setAttribute("value", "default");
     popup.appendChild(menuitem);
-    popup.appendChild(document.createElement("menuseparator"));
+    popup.appendChild(document.createXULElement("menuseparator"));
 
     variants.sort().forEach(function(aVariantName) {
       let displayName = aVariantName.replace(/_/g, " ");
       if (displayName != defaultVariant) {
-        let menuitem = document.createElement("menuitem");
+        let menuitem = document.createXULElement("menuitem");
         menuitem.setAttribute("label", displayName);
         menuitem.setAttribute("value", aVariantName);
         popup.appendChild(menuitem);
       }
     });
     this._ignoreVariantChange = true;
     if (!this._loaded) {
       menulist.value = this.theme.variant = menulist.value;
--- a/mail/components/preferences/messengerLanguages.js
+++ b/mail/components/preferences/messengerLanguages.js
@@ -130,21 +130,21 @@ class OrderedListBox {
     }
     this.richlistbox.appendChild(frag);
 
     this.richlistbox.selectedIndex = 0;
     this.richlistbox.ensureElementIsVisible(this.richlistbox.selectedItem);
   }
 
   createItem({id, label, value}) {
-    let listitem = document.createElement("richlistitem");
+    let listitem = document.createXULElement("richlistitem");
     listitem.id = id;
     listitem.setAttribute("value", value);
 
-    let labelEl = document.createElement("label");
+    let labelEl = document.createXULElement("label");
     labelEl.textContent = label;
     listitem.appendChild(labelEl);
 
     return listitem;
   }
 }
 
 class SortedItemSelectList {
@@ -207,17 +207,17 @@ class SortedItemSelectList {
     // Find the index of the item to insert before.
     let i = items.findIndex(el => compareFn(el, item) >= 0);
     items.splice(i, 0, item);
     popup.insertBefore(this.createItem(item), menulist.getItemAtIndex(i));
     menulist.disabled = menulist.itemCount == 0;
   }
 
   createItem({label, value, className, disabled}) {
-    let item = document.createElement("menuitem");
+    let item = document.createXULElement("menuitem");
     item.setAttribute("label", label);
     if (value)
       item.value = value;
     if (className)
       item.classList.add(className);
     if (disabled)
       item.setAttribute("disabled", "true");
     return item;
--- a/mail/components/preferences/preferences.js
+++ b/mail/components/preferences/preferences.js
@@ -20,17 +20,17 @@ var selector = document.getElementById("
     if (pane.id == "paneChat" && !Services.prefs.getBoolPref("mail.chat.enabled")) {
       continue;
     }
     if (pane.id == "paneLightning" &&
         !ExtensionSupport.loadedLegacyExtensions.has("{e2fda1a4-762b-4020-b5ad-a41df1933103}")) {
       continue;
     }
 
-    var radio = document.createElement("radio");
+    var radio = document.createXULElement("radio");
     radio.setAttribute("pane", pane.id);
     radio.setAttribute("value", pane.id);
     radio.setAttribute("label", pane.getAttribute("label"));
     radio.setAttribute("oncommand", `showPane("${pane.id}");`);
     // Expose preference group choice to accessibility APIs as an unchecked list item
     // The parent group is exposed to accessibility APIs as a list
     if (pane.image) {
       radio.setAttribute("src", pane.image);
--- a/mail/components/preferences/sendoptions.js
+++ b/mail/components/preferences/sendoptions.js
@@ -95,15 +95,15 @@ var gSendOptionsDialog = {
       Services.prompt.alert(window, this.mPrefsBundle.getString("domainNameErrorTitle"),
                             this.mPrefsBundle.getFormattedString("domainDuplicationError", [aDomainName]));
     }
 
     return matchingDomains.length;
   },
 
   addItemToDomainList(aListBox, aDomainTitle) {
-    let label = document.createElement("label");
+    let label = document.createXULElement("label");
     label.setAttribute("value", aDomainTitle);
-    let item = document.createElement("richlistitem");
+    let item = document.createXULElement("richlistitem");
     item.appendChild(label);
     aListBox.appendChild(item);
   },
 };
--- a/mail/extensions/mailviews/content/msgViewPickerOverlay.js
+++ b/mail/extensions/mailviews/content/msgViewPickerOverlay.js
@@ -191,17 +191,17 @@ function RefreshCustomViewsPopup(aMenupo
   while (aMenupopup.hasChildNodes())
     aMenupopup.lastChild.remove();
 
   // now rebuild the list
   var currentView = ViewPickerBinding.currentViewValue;
   var numItems = gMailViewList.mailViewCount;
   for (var i = 0; i < numItems; ++i) {
     var viewInfo = gMailViewList.getMailViewAt(i);
-    var menuitem = document.createElement("menuitem");
+    var menuitem = document.createXULElement("menuitem");
     menuitem.setAttribute("label", viewInfo.prettyName);
     menuitem.setAttribute("value", kViewItemFirstCustom + i);
     menuitem.setAttribute("type", "radio");
     if (kViewItemFirstCustom + i == currentView)
       menuitem.setAttribute("checked", true);
     aMenupopup.appendChild(menuitem);
   }
 }
@@ -213,17 +213,17 @@ function RefreshTagsPopup(aMenupopup) {
     aMenupopup.lastChild.remove();
 
   // create tag menuitems
   let currentTagKey = gFolderDisplay.view.mailViewIndex == kViewItemTags ?
                         gFolderDisplay.view.mailViewData : "";
   let tagArray = MailServices.tags.getAllTags({});
   for (let i = 0; i < tagArray.length; ++i) {
     let tagInfo = tagArray[i];
-    let menuitem = document.createElement("menuitem");
+    let menuitem = document.createXULElement("menuitem");
     menuitem.setAttribute("label", tagInfo.tag);
     menuitem.setAttribute("value", kViewTagMarker + tagInfo.key);
     menuitem.setAttribute("type", "radio");
     if (tagInfo.key == currentTagKey)
       menuitem.setAttribute("checked", true);
     let color = tagInfo.color;
     if (color)
       menuitem.setAttribute("style", "color: " + color + ";");
--- a/mailnews/addrbook/content/map-list.js
+++ b/mailnews/addrbook/content/map-list.js
@@ -100,17 +100,17 @@
       while (mapList.hasChildNodes()) {
         mapList.lastChild.remove();
       }
 
       let defaultUrl = this._getMapURLPref();
 
       // Creates the menuitem with supplied data.
       function addMapService(url, name) {
-        let item = document.createElement("menuitem");
+        let item = document.createXULElement("menuitem");
         item.setAttribute("url", url);
         item.setAttribute("label", name);
         item.setAttribute("type", "radio");
         item.setAttribute("name", "mapit_service");
         if (url == defaultUrl) {
           item.setAttribute("checked", "true");
         }
         mapList.appendChild(item);
--- a/mailnews/addrbook/prefs/content/pref-editdirectories.js
+++ b/mailnews/addrbook/prefs/content/pref-editdirectories.js
@@ -66,18 +66,18 @@ function fillDirectoryList() {
     let ab = directories.getNext();
     if (ab instanceof Ci.nsIAbDirectory && ab.isRemote)
       holdingArray.push(ab);
   }
 
   holdingArray.sort(function(a, b) { return a.dirName.localeCompare(b.dirName); });
 
   holdingArray.forEach(function(ab) {
-    let item = document.createElement("richlistitem");
-    let label = document.createElement("label");
+    let item = document.createXULElement("richlistitem");
+    let label = document.createXULElement("label");
     label.setAttribute("value", ab.dirName);
     item.appendChild(label);
     item.setAttribute("value", ab.URI);
 
     abList.appendChild(item);
   });
 }
 
--- a/mailnews/base/content/menulist-charsetpicker.js
+++ b/mailnews/base/content/menulist-charsetpicker.js
@@ -111,10 +111,10 @@ customElements.whenDefined("menulist").t
   customElements.define("menulist-charsetpicker-viewing",
     MozMenulistCharsetpickerViewing, { extends: "menulist" }
   );
 });
 
 // The menulist CE is defined lazily. Create one now to get menulist defined,
 // allowing us to inherit from it.
 if (!customElements.get("menulist")) {
-  delete document.createElement("menulist");
+  delete document.createXULElement("menulist");
 }
--- a/mailnews/base/content/msgPrintEngine.js
+++ b/mailnews/base/content/msgPrintEngine.js
@@ -32,17 +32,17 @@ function PrintEngineCreateGlobals() {
     printSettings.isCancelled = false;
   }
 }
 
 var PrintPreviewListener = {
   getPrintPreviewBrowser() {
     var browser = document.getElementById("ppBrowser");
     if (!browser) {
-      browser = document.createElement("browser");
+      browser = document.createXULElement("browser");
       browser.setAttribute("id", "ppBrowser");
       browser.setAttribute("flex", "1");
       browser.setAttribute("disablehistory", "true");
       browser.setAttribute("disablesecurity", "true");
       browser.setAttribute("type", "content");
       document.documentElement.appendChild(browser);
     }
     return browser;
--- a/mailnews/base/prefs/content/AccountManager.js
+++ b/mailnews/base/prefs/content/AccountManager.js
@@ -1579,44 +1579,44 @@ var gAccountTree = {
         // is broken, with no child panels.
         let accountID = (accountName || accountKey);
         Cu.reportError("Error accessing account " + accountID + ": " + e);
         accountName = "Invalid account " + accountID;
         panelsToKeep.length = 0;
       }
 
       // Create the top level tree-item.
-      let treeitem = document.createElement("treeitem");
+      let treeitem = document.createXULElement("treeitem");
       mainTree.appendChild(treeitem);
-      let treerow = document.createElement("treerow");
+      let treerow = document.createXULElement("treerow");
       treeitem.appendChild(treerow);
-      let treecell = document.createElement("treecell");
+      let treecell = document.createXULElement("treecell");
       treerow.appendChild(treecell);
       treecell.setAttribute("label", accountName);
       treeitem.setAttribute("PageTag", amChrome);
       // Add icons based on account type.
       if (server) {
         treecell.setAttribute("properties", "folderNameCol isServer-true" +
                               " serverType-" + server.type);
         // For IM accounts, we can try to fetch a protocol specific icon.
         if (server.type == "im") {
           treecell.setAttribute("src", server.wrappedJSObject.imAccount
                                              .protocol.iconBaseURI + "icon.png");
         }
       }
 
       if (panelsToKeep.length > 0) {
-        var treekids = document.createElement("treechildren");
+        var treekids = document.createXULElement("treechildren");
         treeitem.appendChild(treekids);
         for (let panel of panelsToKeep) {
-          var kidtreeitem = document.createElement("treeitem");
+          var kidtreeitem = document.createXULElement("treeitem");
           treekids.appendChild(kidtreeitem);
-          var kidtreerow = document.createElement("treerow");
+          var kidtreerow = document.createXULElement("treerow");
           kidtreeitem.appendChild(kidtreerow);
-          var kidtreecell = document.createElement("treecell");
+          var kidtreecell = document.createXULElement("treecell");
           kidtreerow.appendChild(kidtreecell);
           setAccountLabel(null, kidtreecell, panel.string);
           kidtreeitem.setAttribute("PageTag", panel.src);
           kidtreeitem._account = account;
         }
         treeitem.setAttribute("container", "true");
         treeitem.id = accountKey;
         // Load the 'open' state of the account from XULStore.json.
@@ -1626,20 +1626,20 @@ var gAccountTree = {
         treeitem.setAttribute("persist", "open");
       }
       treeitem._account = account;
     }
 
     markDefaultServer(MailServices.accounts.defaultAccount, null);
 
     // Now add the outgoing server node.
-    let treeitem = document.createElement("treeitem");
+    let treeitem = document.createXULElement("treeitem");
     mainTree.appendChild(treeitem);
-    let treerow = document.createElement("treerow");
+    let treerow = document.createXULElement("treerow");
     treeitem.appendChild(treerow);
-    let treecell = document.createElement("treecell");
+    let treecell = document.createXULElement("treecell");
     treerow.appendChild(treecell);
     treecell.setAttribute("label", getString("prefPanel-smtp"));
     treeitem.setAttribute("PageTag", "am-smtp.xul");
     treecell.setAttribute("properties",
                           "folderNameCol isServer-true serverType-smtp");
   },
 };
--- a/mailnews/base/prefs/content/am-identities-list.js
+++ b/mailnews/base/prefs/content/am-identities-list.js
@@ -44,20 +44,20 @@ function refreshIdentityList(aSelectInde
   // Remove all children.
   while (gIdentityListBox.hasChildNodes())
     gIdentityListBox.lastChild.remove();
 
   // Build the list from the identities array.
   let identities = gAccount.identities;
   for (let identity of fixIterator(identities, Ci.nsIMsgIdentity)) {
     if (identity.valid) {
-      let label = document.createElement("label");
+      let label = document.createXULElement("label");
       label.setAttribute("value", identity.identityName);
 
-      let listitem = document.createElement("richlistitem");
+      let listitem = document.createXULElement("richlistitem");
       listitem.appendChild(label);
       listitem.setAttribute("key", identity.key);
       gIdentityListBox.appendChild(listitem);
     }
   }
 
   // Ensure one identity is always selected.
   if (!aSelectIndex || aSelectIndex < 0)
--- a/mailnews/base/prefs/content/am-junk.js
+++ b/mailnews/base/prefs/content/am-junk.js
@@ -77,21 +77,21 @@ function onInit(aPageId, aServerId) {
   // Sort the list
   function sortFunc(a, b) {
     return a.label.localeCompare(b.label);
   }
   abItems.sort(sortFunc);
 
   // And then append each item to the listbox
   for (let abItem of abItems) {
-    let checkbox = document.createElement("checkbox");
+    let checkbox = document.createXULElement("checkbox");
     checkbox.setAttribute("label", abItem.label);
     checkbox.setAttribute("checked", currentArray.includes(abItem.URI));
 
-    let item = document.createElement("richlistitem");
+    let item = document.createXULElement("richlistitem");
     item.appendChild(checkbox);
     item.setAttribute("value", abItem.URI);
     wList.appendChild(item);
   }
 
   // enable or disable the whitelist
   onAdaptiveJunkToggle();
 
--- a/mailnews/base/prefs/content/am-smtp.js
+++ b/mailnews/base/prefs/content/am-smtp.js
@@ -177,32 +177,32 @@ var gSmtpServerListWindow = {
 
         var listitem = this.createSmtpListItem(server, isDefault);
         aListBox.appendChild(listitem);
       }
     }
   },
 
   createSmtpListItem(aServer, aIsDefault) {
-    var listitem = document.createElement("richlistitem");
+    var listitem = document.createXULElement("richlistitem");
     var serverName = "";
 
     if (aServer.description)
       serverName = aServer.description + " - ";
     else if (aServer.username)
       serverName = aServer.username + " - ";
 
     serverName += aServer.hostname;
 
     if (aIsDefault) {
       serverName += " " + this.mBundle.getString("defaultServerTag");
       listitem.setAttribute("default", "true");
     }
 
-    let label = document.createElement("label");
+    let label = document.createXULElement("label");
     label.setAttribute("value", serverName);
     listitem.appendChild(label);
     listitem.setAttribute("key", aServer.key);
     listitem.setAttribute("class", "smtpServerListItem");
 
     // give it some unique id
     listitem.id = "smtpServer." + aServer.key;
     return listitem;
--- a/mailnews/base/search/content/FilterEditor.js
+++ b/mailnews/base/search/content/FilterEditor.js
@@ -322,17 +322,17 @@ function initializeFilterTypeSelector() 
 function initializeDialog(filter) {
   gFilterNameElement.value = filter.filterName;
   gFilterTypeSelector.setType(filter.filterType);
 
   let numActions = filter.actionCount;
   for (let actionIndex = 0; actionIndex < numActions; actionIndex++) {
     let filterAction = filter.getActionAt(actionIndex);
 
-    let newActionRow = document.createElement("richlistitem");
+    let newActionRow = document.createXULElement("richlistitem");
     newActionRow.setAttribute("initialActionIndex", actionIndex);
     newActionRow.className = "ruleaction";
     gFilterActionList.appendChild(newActionRow);
     newActionRow.setAttribute("value",
         filterAction.type == nsMsgFilterAction.Custom ?
         filterAction.customId : gFilterActionStrings[filterAction.type]);
     newActionRow.setAttribute("onfocus", "this.storeFocus();");
   }
@@ -340,17 +340,17 @@ function initializeDialog(filter) {
   var gSearchScope = getFilterScope(getScope(filter), filter.filterType, filter.filterList);
   initializeSearchRows(gSearchScope, filter.searchTerms);
   setFilterScope(filter.filterType, filter.filterList);
 }
 
 function ensureActionRow() {
   // make sure we have at least one action row visible to the user
   if (!gFilterActionList.getRowCount()) {
-    let newActionRow = document.createElement("richlistitem");
+    let newActionRow = document.createXULElement("richlistitem");
     newActionRow.className = "ruleaction";
     gFilterActionList.appendChild(newActionRow);
     newActionRow.mRemoveButton.disabled = true;
   }
 }
 
 // move to overlay
 function saveFilter() {
--- a/mailnews/base/search/content/searchTerm.js
+++ b/mailnews/base/search/content/searchTerm.js
@@ -301,22 +301,22 @@ function booleanChanged(event) {
  *
  * @param index       index of the position in the menulist where to add the row
  * @param scope       a nsMsgSearchScope constant indicating scope of this search rule
  * @param searchTerm  nsIMsgSearchTerm object to hold the search term
  * @param aUserAdded  boolean indicating if the row addition was initiated by the user
  *                    (e.g. via the '+' button)
  */
 function createSearchRow(index, scope, searchTerm, aUserAdded) {
-    var searchAttr = document.createElement("search-attribute");
-    var searchOp = document.createElement("search-operator");
-    var searchVal = document.createElement("search-value");
+    var searchAttr = document.createXULElement("search-attribute");
+    var searchOp = document.createXULElement("search-operator");
+    var searchVal = document.createXULElement("search-value");
 
-    var moreButton = document.createElement("button");
-    var lessButton = document.createElement("button");
+    var moreButton = document.createXULElement("button");
+    var lessButton = document.createXULElement("button");
     moreButton.setAttribute("class", "small-button");
     moreButton.setAttribute("oncommand", "onMore(event);");
     moreButton.setAttribute("label", "+");
     moreButton.setAttribute("tooltiptext", gMoreButtonTooltipText);
     lessButton.setAttribute("class", "small-button");
     lessButton.setAttribute("oncommand", "onLess(event);");
     lessButton.setAttribute("label", "\u2212");
     lessButton.setAttribute("tooltiptext", gLessButtonTooltipText);
@@ -402,20 +402,20 @@ function initializeTermFromIndex(index) 
  * of each listcell.
  * @param aChildren  An array of XUL elements to put into the listitem.
  *                   Each array member is put into a separate listcell.
  *                   If the member itself is an array of elements,
  *                   all of them are put into the same listcell.
  */
 function constructRow(aChildren) {
     let cols = gSearchTermList.firstChild.childNodes; // treecol elements
-    let listitem = document.createElement("richlistitem");
+    let listitem = document.createXULElement("richlistitem");
     listitem.setAttribute("allowevents", "true");
     for (let i = 0; i < aChildren.length; i++) {
-      let listcell = document.createElement("hbox");
+      let listcell = document.createXULElement("hbox");
       if (cols[i].hasAttribute("flex"))
         listcell.setAttribute("flex", cols[i].getAttribute("flex"));
       let child = aChildren[i];
 
       if (child instanceof Array) {
         for (let j = 0; j < child.length; j++)
           listcell.appendChild(child[j]);
       } else {
--- a/mailnews/base/search/content/searchWidgets.js
+++ b/mailnews/base/search/content/searchWidgets.js
@@ -17,25 +17,25 @@ const updateParentNode = (parentNode) =>
     let filterAction = gFilter.getActionAt(actionIndex);
     parentNode.initWithAction(filterAction);
   }
   parentNode.updateRemoveButton();
 };
 
 class MozRuleactiontargetTag extends MozXULElement {
   connectedCallback() {
-    const menulist = document.createElement("menulist");
-    const menuPopup = document.createElement("menupopup");
+    const menulist = document.createXULElement("menulist");
+    const menuPopup = document.createXULElement("menupopup");
 
     menulist.classList.add("ruleactionitem");
     menulist.setAttribute("flex", "1");
     menulist.appendChild(menuPopup);
 
     for (let taginfo of MailServices.tags.getAllTags({})) {
-      const newMenuItem = document.createElement("menuitem");
+      const newMenuItem = document.createXULElement("menuitem");
       newMenuItem.setAttribute("label", taginfo.tag);
       newMenuItem.setAttribute("value", taginfo.key);
       menuPopup.appendChild(newMenuItem);
     }
 
     this.appendChild(menulist);
 
     updateParentNode(this.closest(".ruleaction"));
@@ -76,18 +76,18 @@ class MozRuleactiontargetJunkscore exten
       ]));
 
     updateParentNode(this.closest(".ruleaction"));
   }
 }
 
 class MozRuleactiontargetReplyto extends MozXULElement {
   connectedCallback() {
-    const menulist = document.createElement("menulist");
-    const menuPopup = document.createElement("menupopup");
+    const menulist = document.createXULElement("menulist");
+    const menuPopup = document.createXULElement("menupopup");
 
     menulist.classList.add("ruleactionitem");
     menulist.setAttribute("flex", "1");
     menulist.appendChild(menuPopup);
 
     this.appendChild(menulist);
 
     document.getAnonymousElementByAttribute(this.closest(".ruleaction"), "class", "ruleactiontype")
@@ -95,17 +95,17 @@ class MozRuleactiontargetReplyto extends
 
     updateParentNode(this.closest(".ruleaction"));
   }
 }
 
 
 class MozRuleactiontargetForwardto extends MozXULElement {
   connectedCallback() {
-    const textbox = document.createElement("textbox");
+    const textbox = document.createXULElement("textbox");
 
     textbox.classList.add("ruleactionitem");
     textbox.setAttribute("flex", "1");
 
     this.appendChild(textbox);
 
     updateParentNode(this.closest(".ruleaction"));
   }
@@ -177,17 +177,17 @@ class MozRuleactiontargetWrapper extends
       "setpriorityto": "ruleactiontarget-priority",
       "setjunkscore": "ruleactiontarget-junkscore",
       "forwardmessage": "ruleactiontarget-forwardto",
       "replytomessage": "ruleactiontarget-replyto",
       "addtagtomessage": "ruleactiontarget-tag",
     };
     const elementName = elementMapping[type];
 
-    return elementName ? document.createElement(elementName) : null;
+    return elementName ? document.createXULElement(elementName) : null;
   }
 
   _updateAttributes() {
     if (!this.hasAttribute("type")) {
       return;
     }
 
     const type = this.getAttribute("type");
@@ -235,20 +235,20 @@ class MozSearchMenulistAbstract extends 
     this.internalScope = null;
     this.internalValue = -1;
     this.validityManager = Cc["@mozilla.org/mail/search/validityManager;1"]
       .getService(Ci.nsIMsgSearchValidityManager);
   }
 
   connectedCallback() {
     if (!this.hasChildNodes()) {
-      this.menulist = document.createElement("menulist");
+      this.menulist = document.createXULElement("menulist");
       this.menulist.classList.add("search-menulist");
       this.menulist.addEventListener("command", this.onSelect.bind(this));
-      this.menupopup = document.createElement("menupopup");
+      this.menupopup = document.createXULElement("menupopup");
       this.menupopup.classList.add("search-menulist-popup");
       this.menulist.appendChild(this.menupopup);
       this.appendChild(this.menulist);
     }
     this._updateAttributes();
   }
 
   attributeChangedCallback() {
@@ -388,30 +388,30 @@ class MozSearchMenulistAbstract extends 
     }
     let newSelection;
     let customizePos = -1;
     for (let i = 0; i < menuItemIds.length; i++) {
       // create the menuitem
       if (Ci.nsMsgSearchAttrib.OtherHeader == menuItemIds[i].toString()) {
         customizePos = i;
       } else {
-        const menuitem = document.createElement("menuitem");
+        const menuitem = document.createXULElement("menuitem");
         menuitem.setAttribute("label", menuItemStrings[i]);
         menuitem.setAttribute("value", menuItemIds[i]);
         popup.appendChild(menuitem);
         // try to restore the selection
         if (!newSelection || oldData == menuItemIds[i].toString()) {
           newSelection = menuitem;
         }
       }
     }
     if (customizePos != -1) {
-      const separator = document.createElement("menuseparator");
+      const separator = document.createXULElement("menuseparator");
       popup.appendChild(separator);
-      const menuitem = document.createElement("menuitem");
+      const menuitem = document.createXULElement("menuitem");
       menuitem.setAttribute("label", menuItemStrings[customizePos]);
       menuitem.setAttribute("value", menuItemIds[customizePos]);
       popup.appendChild(menuitem);
     }
 
     // If we are either uninitialized, or if we are called because
     // of a change in our parent, update the value to the
     // default stored in newSelection.
--- a/mailnews/base/util/JXON.js
+++ b/mailnews/base/util/JXON.js
@@ -140,22 +140,22 @@ var JXON = new (function() {
         }
       } else if (sName === sAttributesProp) { /* verbosity level is 3 */
         for (var sAttrib in vValue)
           oParentEl.setAttribute(sAttrib, vValue[sAttrib]);
       } else if (sName.charAt(0) === sAttrPref) {
         oParentEl.setAttribute(sName.slice(1), vValue);
       } else if (vValue.constructor === Array) {
         for (var nItem = 0; nItem < vValue.length; nItem++) {
-          oChild = oXMLDoc.createElement(sName);
+          oChild = oXMLDoc.createXULElement(sName);
           loadObjTree(oXMLDoc, oChild, vValue[nItem]);
           oParentEl.appendChild(oChild);
         }
       } else {
-        oChild = oXMLDoc.createElement(sName);
+        oChild = oXMLDoc.createXULElement(sName);
         if (vValue instanceof Object)
           loadObjTree(oXMLDoc, oChild, vValue);
         else if (vValue !== null && vValue !== true)
           oChild.appendChild(oXMLDoc.createTextNode(vValue.toString()));
         oParentEl.appendChild(oChild);
      }
    }
   }
--- a/mailnews/db/gloda/content/autocomplete-richlistitem.js
+++ b/mailnews/db/gloda/content/autocomplete-richlistitem.js
@@ -306,17 +306,17 @@
    * @extends MozGlodacompleteBaseRichlistitem
    */
   class MozGlodaFulltextAll extends MozGlodacompleteBaseRichlistitem {
     connectedCallback() {
       super.connectedCallback();
       if (this.delayConnectedCallback() || this.hasChildNodes()) {
         return;
       }
-      this._explanation = document.createElement("description");
+      this._explanation = document.createXULElement("description");
       this._explanation.classList.add("explanation");
       let label = gGlodaCompleteStrings.get("glodaComplete.messagesMentioningMany.label");
       this._explanation.setAttribute("value", label.replace("#1", this.row.words.join(", ")));
       this.appendChild(this._explanation);
     }
 
     get label() {
       return "full text search: " + this.row.item; // what is this for? l10n?
@@ -336,19 +336,19 @@
    * @extends MozGlodacompleteBaseRichlistitem
    */
   class MozGlodaFulltextSingle extends MozGlodacompleteBaseRichlistitem {
     connectedCallback() {
       super.connectedCallback();
       if (this.delayConnectedCallback() || this.hasChildNodes()) {
         return;
       }
-      this._explanation = document.createElement("description");
+      this._explanation = document.createXULElement("description");
       this._explanation.classList.add("explanation", "gloda-fulltext-single");
-      this._parameters = document.createElement("description");
+      this._parameters = document.createXULElement("description");
 
       this.appendChild(this._explanation);
       this.appendChild(this._parameters);
 
       let label = gGlodaCompleteStrings.get("glodaComplete.messagesMentioning.label");
       this._explanation.setAttribute("value", label.replace("#1", this.row.item));
     }
 
@@ -371,18 +371,18 @@
    * @extends MozGlodacompleteBaseRichlistitem
    */
   class MozGlodaMulti extends MozGlodacompleteBaseRichlistitem {
     connectedCallback() {
       super.connectedCallback();
       if (this.delayConnectedCallback() || this.hasChildNodes()) {
         return;
       }
-      this._explanation = document.createElement("description");
-      this._identityHolder = document.createElement("hbox");
+      this._explanation = document.createXULElement("description");
+      this._identityHolder = document.createXULElement("hbox");
       this._identityHolder.setAttribute("flex", "1");
 
       this.appendChild(this._explanation);
       this.appendChild(this._identityHolder);
       this._adjustAcItem();
     }
 
     get label() {
@@ -539,17 +539,17 @@
    * @extends MozGlodacompleteBaseRichlistitem
    */
   class MozGlodaSingleTag extends MozGlodacompleteBaseRichlistitem {
     connectedCallback() {
       super.connectedCallback();
       if (this.delayConnectedCallback() || this.hasChildNodes()) {
         return;
       }
-      this._explanation = document.createElement("description");
+      this._explanation = document.createXULElement("description");
       this._explanation.classList.add("explanation", "gloda-single");
       this.appendChild(this._explanation);
       let label = gGlodaCompleteStrings.get("glodaComplete.messagesTagged.label");
       this._explanation.setAttribute("value", label.replace("#1", this.row.item.tag));
     }
 
     get label() {
       return "tag " + this.row.item.tag;
--- a/mailnews/extensions/smime/content/certpicker.js
+++ b/mailnews/extensions/smime/content/certpicker.js
@@ -19,17 +19,17 @@ function onLoad() {
   itemCount = dialogParams.GetInt(0);
 
   var selIndex = dialogParams.GetInt(1);
   if (selIndex < 0) {
     selIndex = 0;
   }
 
   for (let i = 0; i < itemCount; i++) {
-    let menuItemNode = document.createElement("menuitem");
+    let menuItemNode = document.createXULElement("menuitem");
     let nick = dialogParams.GetString(i);
     menuItemNode.setAttribute("value", i);
     menuItemNode.setAttribute("label", nick); // This is displayed.
     selectElement.firstChild.appendChild(menuItemNode);
 
     if (selIndex == i) {
       selectElement.selectedItem = menuItemNode;
     }
--- a/mailnews/extensions/smime/content/msgCompSecurityInfo.js
+++ b/mailnews/extensions/smime/content/msgCompSecurityInfo.js
@@ -124,40 +124,40 @@ function onLoad() {
     } else {
       signed_element.value = no_string;
     }
   }
 
   var imax = gCount.value;
 
   for (let i = 0; i < imax; ++i) {
-    let email = document.createElement("label");
+    let email = document.createXULElement("label");
     email.setAttribute("value", gEmailAddresses.value[i]);
     email.setAttribute("crop", "end");
     email.setAttribute("style", "width: var(--recipientWidth)");
 
-    let listitem = document.createElement("richlistitem");
+    let listitem = document.createXULElement("richlistitem");
     listitem.appendChild(email);
 
     if (!gCerts.value[i]) {
-      let notFound = document.createElement("label");
+      let notFound = document.createXULElement("label");
       notFound.setAttribute("value", gBundle.getString("StatusNotFound"));
       notFound.setAttribute("style", "width: var(--statusWidth)");
 
       listitem.appendChild(notFound);
     } else {
-      let status = document.createElement("label");
+      let status = document.createXULElement("label");
       status.setAttribute("value", "?"); // temporary placeholder
       status.setAttribute("crop", "end");
       status.setAttribute("style", "width: var(--statusWidth)");
-      let issued = document.createElement("label");
+      let issued = document.createXULElement("label");
       issued.setAttribute("value", gCertIssuedInfos.value[i]);
       issued.setAttribute("crop", "end");
       issued.setAttribute("style", "width: var(--issuedWidth)");
-      let expire = document.createElement("label");
+      let expire = document.createXULElement("label");
       expire.setAttribute("value", gCertExpiresInfos.value[i]);
       expire.setAttribute("crop", "end");
       expire.setAttribute("style", "width: var(--expireWidth)");
 
       listitem.appendChild(status);
       listitem.appendChild(issued);
       listitem.appendChild(expire);
 
@@ -267,12 +267,12 @@ function viewSelectedCert() {
 }
 
 /* globals openHelp */// Suite only.
 function doHelpButton() {
   openHelp("compose_security", "chrome://communicator/locale/help/suitehelp.rdf");
 }
 
 function createCell(label) {
-  var cell = document.createElement("listcell");
+  var cell = document.createXULElement("listcell");
   cell.setAttribute("label", label);
   return cell;
 }
--- a/mailnews/import/content/fieldMapImport.js
+++ b/mailnews/import/content/fieldMapImport.js
@@ -72,35 +72,35 @@ function ListFields() {
   count = top.fieldMap.numMozFields;
   for (let i = 0; i < count; i++) {
     if (!IndexInMap(i))
       AddFieldToList(top.fieldMap.GetFieldDescription(i), i, false);
   }
 }
 
 function CreateField(name, index, on) {
-  var item = document.createElement("richlistitem");
+  var item = document.createXULElement("richlistitem");
   item.setAttribute("align", "center");
   item.setAttribute("field-index", index);
   item.setAttribute("allowevents", "true");
 
-  var checkboxCell = document.createElement("hbox");
+  var checkboxCell = document.createXULElement("hbox");
   checkboxCell.setAttribute("style", "width: var(--column1width)");
-  let checkbox = document.createElement("checkbox");
+  let checkbox = document.createXULElement("checkbox");
   checkbox.addEventListener("click", cellClicked);
   if (on) {
     checkbox.setAttribute("checked", "true");
   }
   checkboxCell.appendChild(checkbox);
 
-  var firstCell = document.createElement("label");
+  var firstCell = document.createXULElement("label");
   firstCell.setAttribute("style", "width: var(--column2width)");
   firstCell.setAttribute("value", name);
 
-  var secondCell = document.createElement("label");
+  var secondCell = document.createXULElement("label");
   secondCell.setAttribute("class", "importsampledata");
   secondCell.setAttribute("flex", "1");
 
   item.appendChild(checkboxCell);
   item.appendChild(firstCell);
   item.appendChild(secondCell);
   return item;
 }
--- a/mailnews/import/content/importDialog.js
+++ b/mailnews/import/content/importDialog.js
@@ -358,43 +358,43 @@ function ListModules() {
   for (i = 0; i < count; i++) {
     AddModuleToList(moduleArray[i].name, moduleArray[i].index);
   }
 }
 
 function AddModuleToList(moduleName, index) {
   var body = document.getElementById("moduleList");
 
-  let item = document.createElement("richlistitem");
-  let label = document.createElement("label");
+  let item = document.createXULElement("richlistitem");
+  let label = document.createXULElement("label");
   label.setAttribute("value", moduleName);
   item.appendChild(label);
   item.setAttribute("list-index", index);
   body.appendChild(item);
 }
 
 function ListFeedAccounts() {
   let body = document.getElementById("moduleList");
   while (body.hasChildNodes())
     body.lastChild.remove();
 
   // Add item to allow for new account creation.
-  let item = document.createElement("richlistitem");
-  let label = document.createElement("label");
+  let item = document.createXULElement("richlistitem");
+  let label = document.createXULElement("label");
   label.setAttribute("value", gFeedsBundle.getString("ImportFeedsCreateNewListItem"));
   item.appendChild(label);
   item.setAttribute("list-index", 0);
   body.appendChild(item);
 
   let index = 0;
   let feedRootFolders = FeedUtils.getAllRssServerRootFolders();
 
   feedRootFolders.forEach(function(rootFolder) {
-    item = document.createElement("richlistitem");
-    let label = document.createElement("label");
+    item = document.createXULElement("richlistitem");
+    let label = document.createXULElement("label");
     label.setAttribute("value", rootFolder.prettyName);
     item.appendChild(label);
     item.setAttribute("list-index", ++index);
     item.server = rootFolder.server;
     body.appendChild(item);
   }, this);
 
   if (index)