Bug 1362774 - Use nodefaultsrc on the initialBrowser in tabbrowser when possible. r?florian draft
authorZibi Braniecki <zbraniecki@mozilla.com>
Thu, 14 Sep 2017 22:50:54 -0700
changeset 667035 b175e5c139b78ddd86a82967925c494e67d86b6d
parent 666583 948dc86aabc97e16d51ad19ea90debab6f93a628
child 667036 5435b0d6ec9d32772f5bbe8b955bf16c42764a1e
push id80595
push userbmo:gandalf@aviary.pl
push dateTue, 19 Sep 2017 16:27:13 +0000
reviewersflorian
bugs1362774
milestone57.0a1
Bug 1362774 - Use nodefaultsrc on the initialBrowser in tabbrowser when possible. r?florian In order to reduce flickering when opening a new window with URL different than about:blank, set nodefaultsrc on the initial <browser> element. MozReview-Commit-ID: JRsnxbTKyjN
browser/base/content/browser.js
browser/base/content/tabbrowser.xml
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1262,17 +1262,18 @@ var gBrowserInit = {
         remoteType = linkedBrowser.remoteType;
         isRemote = remoteType != E10SUtils.NOT_REMOTE;
         sameProcessAsFrameLoader = linkedBrowser.frameLoader;
       }
       initBrowser.removeAttribute("blank");
     }
 
     gBrowser.updateBrowserRemoteness(initBrowser, isRemote, {
-      remoteType, sameProcessAsFrameLoader
+      remoteType, sameProcessAsFrameLoader,
+      keepNoDefaultSrcInInitialBrowser: true
     });
   },
 
   onLoad() {
     gBrowser.addEventListener("DOMUpdatePageReport", gPopupBlockerObserver);
 
     Services.obs.addObserver(gPluginHandler.NPAPIPluginCrashed, "plugin-crashed");
 
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -16,29 +16,17 @@
       <stylesheet src="chrome://browser/content/tabbrowser.css"/>
     </resources>
 
     <content>
       <xul:stringbundle anonid="tbstringbundle" src="chrome://browser/locale/tabbrowser.properties"/>
       <xul:tabbox anonid="tabbox" class="tabbrowser-tabbox"
                   flex="1" eventnode="document" xbl:inherits="handleCtrlPageUpDown,tabcontainer"
                   onselect="if (event.target.localName == 'tabpanels') this.parentNode.updateCurrentBrowser();">
-        <xul:tabpanels flex="1" class="plain" selectedIndex="0" anonid="panelcontainer">
-          <xul:notificationbox flex="1" notificationside="top">
-            <xul:hbox flex="1" class="browserSidebarContainer">
-              <xul:vbox flex="1" class="browserContainer">
-                <xul:stack flex="1" class="browserStack" anonid="browserStack">
-                  <xul:browser anonid="initialBrowser" type="content" message="true" messagemanagergroup="browsers"
-                               primary="true" blank="true"
-                               xbl:inherits="tooltip=contenttooltip,contextmenu=contentcontextmenu,autocompletepopup,selectmenulist,datetimepicker"/>
-                </xul:stack>
-              </xul:vbox>
-            </xul:hbox>
-          </xul:notificationbox>
-        </xul:tabpanels>
+        <xul:tabpanels flex="1" class="plain" selectedIndex="0" anonid="panelcontainer"/>
       </xul:tabbox>
       <children/>
     </content>
     <implementation implements="nsIDOMEventListener, nsIMessageListener, nsIObserver">
 
       <property name="tabContextMenu" readonly="true"
                 onget="return this.tabContainer.contextMenu;"/>
 
@@ -1956,16 +1944,25 @@
             }
 
             if (aOptions.opener) {
               // Set the opener window on the browser, such that when the frame
               // loader is created the opener is set correctly.
               aBrowser.presetOpenerWindow(aOptions.opener);
             }
 
+            // We're removing the nodefaultsrc because extensions
+            // which are started in a different thread expect the
+            // nodefaultsrc to not be set. See bug 1397365 for details.
+            if (!aOptions.keepNoDefaultSrcInInitialBrowser &&
+                aBrowser.getAttribute("anonid") == "initialBrowser") {
+              aBrowser.removeAttribute("nodefaultsrc");
+            }
+
+
             parent.appendChild(aBrowser);
 
             aBrowser.userTypedValue = oldUserTypedValue;
             if (hadStartedLoad) {
               aBrowser.urlbarChangeTracker.startedLoad();
             }
 
             aBrowser.droppedLinkHandler = droppedLinkHandler;
@@ -2202,17 +2199,19 @@
 
             if (this.hasAttribute("selectmenulist"))
               b.setAttribute("selectmenulist", this.getAttribute("selectmenulist"));
 
             if (this.hasAttribute("datetimepicker")) {
               b.setAttribute("datetimepicker", this.getAttribute("datetimepicker"));
             }
 
-            b.setAttribute("autoscrollpopup", this._autoScrollPopup.id);
+            if (this._autoscrollPopup) {
+              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());
             }
@@ -5794,18 +5793,36 @@
               break;
             }
           }
         ]]></body>
       </method>
 
       <constructor>
         <![CDATA[
-          this.mCurrentBrowser = document.getAnonymousElementByAttribute(this, "anonid", "initialBrowser");
-          this.mCurrentBrowser.permanentKey = {};
+          let uriIsAboutBlank = true;
+          if (window.arguments) {
+            const firstURL = window.arguments[0];
+
+            // accessibility tests send firstURL with value null
+            // several mochitests submit "" firstURL
+            if (firstURL != null &&
+                !["about:blank", ""].includes(firstURL)) {
+              uriIsAboutBlank = false;
+            }
+          }
+
+          let initialBrowser = this._createBrowser({uriIsAboutBlank});
+          initialBrowser.setAttribute("anonid", "initialBrowser");
+          initialBrowser.setAttribute("primary", "true");
+
+          let notificationbox = this.getNotificationBox(initialBrowser);
+          this.mPanelContainer.appendChild(notificationbox);
+
+          this.mCurrentBrowser = initialBrowser;
 
           Services.obs.addObserver(this, "contextual-identity-updated");
 
           this.mCurrentTab = this.tabContainer.firstChild;
           const nsIEventListenerService =
             Components.interfaces.nsIEventListenerService;
           let els = Components.classes["@mozilla.org/eventlistenerservice;1"]
                               .getService(nsIEventListenerService);