1 /* Any copyright is dedicated to the Public Domain.
2 * http://creativecommons.org/publicdomain/zero/1.0/ */
6 const TEST_URL1 = "http://example.com/1";
7 const TEST_URL2 = "http://example.com/2";
9 add_setup(async function () {
10 let oldHomepagePref = Services.prefs.getCharPref("browser.startup.homepage");
12 await openPreferencesViaOpenPreferencesAPI("paneHome", { leaveOpen: true });
15 gBrowser.currentURI.spec,
16 "about:preferences#home",
17 "#home should be in the URI for about:preferences"
20 registerCleanupFunction(async () => {
21 Services.prefs.setCharPref("browser.startup.homepage", oldHomepagePref);
22 BrowserTestUtils.removeTab(gBrowser.selectedTab);
23 await PlacesUtils.bookmarks.eraseEverything();
27 add_task(async function testSetHomepageFromBookmark() {
28 let bm = await PlacesUtils.bookmarks.insert({
29 parentGuid: PlacesUtils.bookmarks.menuGuid,
30 title: "TestHomepage",
34 let doc = gBrowser.contentDocument;
35 // Select the custom URLs option.
36 doc.getElementById("homeMode").value = 2;
38 let promiseSubDialogLoaded = promiseLoadSubDialog(
39 "chrome://browser/content/preferences/dialogs/selectBookmark.xhtml"
41 doc.getElementById("useBookmarkBtn").click();
43 let dialog = await promiseSubDialogLoaded;
44 dialog.document.getElementById("bookmarks").selectItems([bm.guid]);
46 .getElementById("selectBookmarkDialog")
50 await TestUtils.waitForCondition(() => HomePage.get() == TEST_URL1);
55 "Should have set the homepage to the same as the bookmark."
59 add_task(async function testSetHomepageFromTopLevelFolder() {
60 // Insert a second item into the menu folder
61 await PlacesUtils.bookmarks.insert({
62 parentGuid: PlacesUtils.bookmarks.menuGuid,
63 title: "TestHomepage",
67 let doc = gBrowser.contentDocument;
68 // Select the custom URLs option.
69 doc.getElementById("homeMode").value = 2;
71 let promiseSubDialogLoaded = promiseLoadSubDialog(
72 "chrome://browser/content/preferences/dialogs/selectBookmark.xhtml"
74 doc.getElementById("useBookmarkBtn").click();
76 let dialog = await promiseSubDialogLoaded;
78 .getElementById("bookmarks")
79 .selectItems([PlacesUtils.bookmarks.menuGuid]);
81 .getElementById("selectBookmarkDialog")
85 await TestUtils.waitForCondition(
86 () => HomePage.get() == `${TEST_URL1}|${TEST_URL2}`
91 `${TEST_URL1}|${TEST_URL2}`,
92 "Should have set the homepage to the same as the bookmark."