Bug 1081891: Only reset the browser title when we start to switch to a new document location. r=mconley
authorDave Townsend <dtownsend@oxymoronical.com>
Wed, 18 Feb 2015 11:57:45 -0800
changeset 229933 0bb440fbcbfec33568d217cbb21d6d7f74ad934c
parent 229932 abec19b886f43d6602fcf7902b9388972b44caf2
child 229934 5595892c4c07ea2b80381e5864b66c1879c7737f
push id28303
push usercbook@mozilla.com
push dateFri, 20 Feb 2015 14:07:30 +0000
treeherdermozilla-central@80bd1ae9dd0a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs1081891
milestone38.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1081891: Only reset the browser title when we start to switch to a new document location. r=mconley
browser/base/content/test/general/browser.ini
browser/base/content/test/general/browser_unknownContentType_title.js
toolkit/modules/RemoteWebNavigation.jsm
toolkit/modules/RemoteWebProgress.jsm
--- a/browser/base/content/test/general/browser.ini
+++ b/browser/base/content/test/general/browser.ini
@@ -430,16 +430,17 @@ skip-if = e10s # Bug 1100664 - test reli
 [browser_testOpenNewRemoteTabsFromNonRemoteBrowsers.js]
 run-if = e10s
 [browser_trackingUI.js]
 support-files =
   trackingPage.html
   benignPage.html
 [browser_typeAheadFind.js]
 skip-if = buildapp == 'mulet' || e10s # Bug 921935 - focusmanager issues with e10s (test calls waitForFocus)
+[browser_unknownContentType_title.js]
 [browser_unloaddialogs.js]
 skip-if = e10s # Bug 1100700 - test relies on unload event firing on closed tabs, which it doesn't
 [browser_urlHighlight.js]
 [browser_urlbarAutoFillTrimURLs.js]
 skip-if = e10s # Bug 1093941 - Waits indefinitely for onSearchComplete
 [browser_urlbarCopying.js]
 [browser_urlbarEnter.js]
 skip-if = e10s # Bug 1093941 - used to cause obscure non-windows child process crashes on try
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/general/browser_unknownContentType_title.js
@@ -0,0 +1,33 @@
+const url = "data:text/html;charset=utf-8,%3C%21DOCTYPE%20html%3E%3Chtml%3E%3Chead%3E%3Ctitle%3ETest%20Page%3C%2Ftitle%3E%3C%2Fhead%3E%3C%2Fhtml%3E";
+const unknown_url = "http://example.com/browser/browser/base/content/test/general/unknownContentType_file.pif";
+
+function waitForNewWindow() {
+  return new Promise(resolve => {
+    let listener = (win) => {
+      Services.obs.removeObserver(listener, "toplevel-window-ready");
+      win.addEventListener("load", () => {
+        resolve(win);
+      });
+    };
+
+    Services.obs.addObserver(listener, "toplevel-window-ready", false)
+  });
+}
+
+add_task(function*() {
+  let tab = gBrowser.selectedTab = gBrowser.addTab(url);
+  let browser = tab.linkedBrowser;
+  yield promiseTabLoaded(gBrowser.selectedTab);
+
+  is(gBrowser.contentTitle, "Test Page", "Should have the right title.")
+
+  browser.loadURI(unknown_url);
+  let win = yield waitForNewWindow();
+  is(win.location, "chrome://mozapps/content/downloads/unknownContentType.xul",
+     "Should have seen the unknown content dialog.");
+  is(gBrowser.contentTitle, "Test Page", "Should still have the right title.")
+
+  win.close();
+  yield promiseWaitForFocus(window);
+  gBrowser.removeCurrentTab();
+});
--- a/toolkit/modules/RemoteWebNavigation.jsm
+++ b/toolkit/modules/RemoteWebNavigation.jsm
@@ -56,17 +56,16 @@ RemoteWebNavigation.prototype = {
   },
   gotoIndex: function(aIndex) {
     this._sendMessage("WebNavigation:GotoIndex", {index: aIndex});
   },
   loadURI: function(aURI, aLoadFlags, aReferrer, aPostData, aHeaders) {
     if (aPostData || aHeaders)
       throw Components.Exception("RemoteWebNavigation doesn't accept postdata or headers.", Cr.NS_ERROR_INVALID_ARGS);
 
-    this._browser._contentTitle = "";
     this._sendMessage("WebNavigation:LoadURI", {
       uri: aURI,
       flags: aLoadFlags,
       referrer: aReferrer ? aReferrer.spec : null
     });
   },
   reload: function(aReloadFlags) {
     this._sendMessage("WebNavigation:Reload", {flags: aReloadFlags});
--- a/toolkit/modules/RemoteWebProgress.jsm
+++ b/toolkit/modules/RemoteWebProgress.jsm
@@ -174,16 +174,17 @@ RemoteWebProgressManager.prototype = {
       // These properties can change even for a sub-frame navigation.
       this._browser.webNavigation.canGoBack = json.canGoBack;
       this._browser.webNavigation.canGoForward = json.canGoForward;
 
       if (isTopLevel) {
         this._browser.webNavigation._currentURI = location;
         this._browser._characterSet = json.charset;
         this._browser._documentURI = newURI(json.documentURI);
+        this._browser._contentTitle = "";
         this._browser._imageDocument = null;
         this._browser._mayEnableCharacterEncodingMenu = json.mayEnableCharacterEncodingMenu;
         this._browser._contentPrincipal = json.principal;
       }
 
       this._callProgressListeners("onLocationChange", webProgress, request, location, flags);
       break;