Bug 1643578 - Test that navigating to a http home page doesn't focus the address bar r=kashav
☠☠ backed out by 7590205c2184 ☠ ☠
authorPaul Bone <pbone@mozilla.com>
Wed, 22 Jul 2020 22:33:54 +0000
changeset 541795 5a1183eb910737e2141922797bab757b25332a77
parent 541794 7642b492b329b8d7ad73c59178569d19acc042c4
child 541796 e87edc47ce4966ef9cf2df591dfa8a0d66f57116
push id37633
push userccoroiu@mozilla.com
push dateFri, 24 Jul 2020 09:32:06 +0000
treeherdermozilla-central@141543043270 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskashav
bugs1643578
milestone80.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 1643578 - Test that navigating to a http home page doesn't focus the address bar r=kashav Differential Revision: https://phabricator.services.mozilla.com/D83754
browser/base/content/test/tabs/browser_navigate_home_focuses_addressbar.js
--- a/browser/base/content/test/tabs/browser_navigate_home_focuses_addressbar.js
+++ b/browser/base/content/test/tabs/browser_navigate_home_focuses_addressbar.js
@@ -1,16 +1,36 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 
 const TEST_HTTP = httpURL("dummy_page.html");
 
-// Test for Bug 1634272
-add_task(async function() {
+async function doNavigateHome(isHome, expectedURL, expectFocused) {
   await BrowserTestUtils.withNewTab(TEST_HTTP, async function(browser) {
     info("Tab ready");
 
     document.getElementById("home-button").click();
-    await BrowserTestUtils.browserLoaded(browser, false, HomePage.get());
-    is(gURLBar.value, "", "URL bar should be empty");
-    ok(gURLBar.focused, "URL bar should be focused");
+    await BrowserTestUtils.browserLoaded(browser, false, isHome);
+    is(gURLBar.focused, expectFocused, "URL bar should" 
+      + (expectFocused ? "" : " not") + " be focused");
+    is(gURLBar.value, expectedURL, "URL bar set correctly");
   });
+}
+
+// Test for Bug 1634272
+add_task(async function testNavHomeDefault() {
+  await doNavigateHome((url) => url === HomePage.get(), "",
+    true);
 });
+
+
+add_task(async function testNavHomePage() {
+  await SpecialPowers.pushPrefEnv({
+    set: [["browser.startup.homepage", "http://example.com"]]
+  });
+
+  // We don't focus the URL bar when the home page is a website.
+  await doNavigateHome((url) => url === "http://example.com/",
+      "example.com", false);
+
+  await SpecialPowers.popPrefEnv();
+});
+