Bug 1443462 - Copy default browser attributes from the initial browser to dynamically created ones. r?mconley draft
authorDão Gottwald <dao@mozilla.com>
Thu, 15 Mar 2018 12:25:35 +0100
changeset 767922 21be127fc14ac96c0e664c50b5ee82e4d5945601
parent 767919 fcb11e93adf57210167de0b27b15433e9c3f45e4
push id102742
push userdgottwald@mozilla.com
push dateThu, 15 Mar 2018 11:41:59 +0000
reviewersmconley
bugs1443462
milestone61.0a1
Bug 1443462 - Copy default browser attributes from the initial browser to dynamically created ones. r?mconley MozReview-Commit-ID: DGy6W2w75Y2
browser/base/content/tabbrowser.js
--- a/browser/base/content/tabbrowser.js
+++ b/browser/base/content/tabbrowser.js
@@ -283,20 +283,34 @@ window._gBrowser = {
 
   _setupInitialBrowserAndTab() {
     let browser = this.initialBrowser;
     this._selectedBrowser = browser;
 
     browser.permanentKey = {};
     browser.droppedLinkHandler = handleDroppedLink;
 
-    this._autoScrollPopup = browser._createAutoScrollPopup();
-    this._autoScrollPopup.id = "autoscroller";
-    document.getElementById("mainPopupSet").appendChild(this._autoScrollPopup);
-    browser.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
+    let autoScrollPopup = browser._createAutoScrollPopup();
+    autoScrollPopup.id = "autoscroller";
+    document.getElementById("mainPopupSet").appendChild(autoScrollPopup);
+    browser.setAttribute("autoscrollpopup", autoScrollPopup.id);
+
+    this._defaultBrowserAttributes = {
+      autoscrollpopup: "",
+      contextmenu: "",
+      datetimepicker: "",
+      message: "",
+      messagemanagergroup: "",
+      selectmenulist: "",
+      tooltip: "",
+      type: "",
+    };
+    for (let attribute in this._defaultBrowserAttributes) {
+      this._defaultBrowserAttributes[attribute] = browser.getAttribute(attribute);
+    }
 
     let tab = this.tabs[0];
     this._selectedTab = tab;
 
     let uniqueId = this._generateUniquePanelID();
     this.mPanelContainer.childNodes[0].id = uniqueId;
     tab.linkedPanel = uniqueId;
     tab.permanentKey = browser.permanentKey;
@@ -1813,21 +1827,20 @@ window._gBrowser = {
 
   _createBrowser(aParams) {
     // Supported parameters:
     // userContextId, remote, remoteType, isPreloadBrowser,
     // uriIsAboutBlank, sameProcessAsFrameLoader
 
     let b = document.createElementNS(this._XUL_NS, "browser");
     b.permanentKey = {};
-    b.setAttribute("type", "content");
-    b.setAttribute("message", "true");
-    b.setAttribute("messagemanagergroup", "browsers");
-    b.setAttribute("contextmenu", "contentAreaContextMenu");
-    b.setAttribute("tooltip", "aHTMLTooltip");
+
+    for (let attribute in this._defaultBrowserAttributes) {
+      b.setAttribute(attribute, this._defaultBrowserAttributes[attribute]);
+    }
 
     if (aParams.userContextId) {
       b.setAttribute("usercontextid", aParams.userContextId);
     }
 
     // remote parameter used by some addons, use default in this case.
     if (aParams.remote && !aParams.remoteType) {
       aParams.remoteType = E10SUtils.DEFAULT_REMOTE_TYPE;
@@ -1863,22 +1876,16 @@ window._gBrowser = {
      *      therefore the 'preloadedState' attribute is removed from
      *      that browser altogether
      * See more details on Bug 1420285.
      */
     if (aParams.isPreloadBrowser) {
       b.setAttribute("preloadedState", "preloaded");
     }
 
-    b.setAttribute("selectmenulist", "ContentSelectDropdown");
-
-    b.setAttribute("datetimepicker", "DateTimePickerPanel");
-
-    b.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
-
     if (aParams.nextTabParentId) {
       if (!aParams.remoteType) {
         throw new Error("Cannot have nextTabParentId without a remoteType");
       }
       // Gecko is going to read this attribute and use it.
       b.setAttribute("nextTabParentId", aParams.nextTabParentId.toString());
     }