summaryrefslogtreecommitdiffstats
path: root/browser/components/preferences/tests/browser_homepage_default.js
blob: e3fcdcec5e512c5fae88ed567a4e0e13171ce713 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

add_task(async function default_homepage_test() {
  await SpecialPowers.pushPrefEnv({
    set: [["browser.startup.page", 1]],
  });
  let defaults = Services.prefs.getDefaultBranch("");
  // Simulate a homepage set via policy or a distribution.
  defaults.setStringPref("browser.startup.homepage", "https://example.com");

  await openPreferencesViaOpenPreferencesAPI("paneHome", { leaveOpen: true });

  let doc = gBrowser.contentDocument;
  let homeMode = doc.getElementById("homeMode");
  Assert.equal(homeMode.value, 2, "homeMode should be 2 (Custom URL)");

  let homePageUrl = doc.getElementById("homePageUrl");
  Assert.equal(
    homePageUrl.value,
    "https://example.com",
    "homePageUrl should be example.com"
  );

  registerCleanupFunction(async () => {
    defaults.setStringPref("browser.startup.homepage", "about:home");
    BrowserTestUtils.removeTab(gBrowser.selectedTab);
  });
});