Bug 1397081 - Update browserSettings to report the current home page and new tab page in all cases, r=mixedpuppy
authorBob Silverberg <bsilverberg@mozilla.com>
Tue, 05 Sep 2017 16:11:04 -0400
changeset 428937 8da12747279bd2b06b82580ebda8fcc76f5883ec
parent 428936 3b1def512f64496fc503f32a2e0c7731c0136f3f
child 428938 b4b9eaba235ec71a73bd996f436bcdecfc79bf0c
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmixedpuppy
bugs1397081
milestone57.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 1397081 - Update browserSettings to report the current home page and new tab page in all cases, r=mixedpuppy This updates the browserSettings API to report the current value of the home page and the new tab page regardless of whether they are currently overridden by an extension. MozReview-Commit-ID: 3usY3F4oIxl
browser/components/extensions/test/browser/browser_ext_chrome_settings_overrides_home.js
browser/components/extensions/test/xpcshell/test_ext_url_overrides_newtab.js
toolkit/components/extensions/ext-browserSettings.js
--- a/browser/components/extensions/test/browser/browser_ext_chrome_settings_overrides_home.js
+++ b/browser/components/extensions/test/browser/browser_ext_chrome_settings_overrides_home.js
@@ -1,29 +1,36 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 
 "use strict";
 
-XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
-                                  "resource://gre/modules/Preferences.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "AddonManager",
                                   "resource://gre/modules/AddonManager.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Services",
+                                  "resource://gre/modules/Services.jsm");
 
 // Named this way so they correspond to the extensions
 const HOME_URI_2 = "http://example.com/";
 const HOME_URI_3 = "http://example.org/";
 const HOME_URI_4 = "http://example.net/";
 
 const CONTROLLABLE = "controllable_by_this_extension";
 const CONTROLLED_BY_THIS = "controlled_by_this_extension";
 const CONTROLLED_BY_OTHER = "controlled_by_other_extensions";
 
+const HOMEPAGE_URL_PREF = "browser.startup.homepage";
+
+const getHomePageURL = () => {
+  return Services.prefs.getComplexValue(
+    HOMEPAGE_URL_PREF, Ci.nsIPrefLocalizedString).data;
+};
+
 add_task(async function test_multiple_extensions_overriding_home_page() {
-  let defaultHomePage = Preferences.get("browser.startup.homepage");
+  let defaultHomePage = getHomePageURL();
 
   function background() {
     browser.test.onMessage.addListener(async msg => {
       switch (msg) {
         case "checkHomepage":
           let homepage = await browser.browserSettings.homepageOverride.get({});
           browser.test.sendMessage("homepage", homepage);
           break;
@@ -68,28 +75,28 @@ add_task(async function test_multiple_ex
     is(homepage.value, expectedValue,
        `homepageOverride setting returns the expected value: ${expectedValue}.`);
     is(homepage.levelOfControl, expectedLevelOfControl,
        `homepageOverride setting returns the expected levelOfControl: ${expectedLevelOfControl}.`);
   }
 
   await ext1.startup();
 
-  is(Preferences.get("browser.startup.homepage"), defaultHomePage,
+  is(getHomePageURL(), defaultHomePage,
      "Home url should be the default");
-  await checkHomepageOverride(ext1, null, CONTROLLABLE);
+  await checkHomepageOverride(ext1, getHomePageURL(), CONTROLLABLE);
 
   // Because we are expecting the pref to change when we start or unload, we
   // need to wait on a pref change.  This is because the pref management is
   // async and can happen after the startup/unload is finished.
-  let prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  let prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext2.startup();
   await prefPromise;
 
-  ok(Preferences.get("browser.startup.homepage").endsWith(HOME_URI_2),
+  ok(getHomePageURL().endsWith(HOME_URI_2),
      "Home url should be overridden by the second extension.");
 
   await checkHomepageOverride(ext1, HOME_URI_2, CONTROLLED_BY_OTHER);
 
   // Verify that calling set and clear do nothing.
   ext2.sendMessage("trySet");
   await ext2.awaitMessage("homepageSet");
   await checkHomepageOverride(ext1, HOME_URI_2, CONTROLLED_BY_OTHER);
@@ -98,107 +105,107 @@ add_task(async function test_multiple_ex
   await ext2.awaitMessage("homepageCleared");
   await checkHomepageOverride(ext1, HOME_URI_2, CONTROLLED_BY_OTHER);
 
   // Because we are unloading an earlier extension, browser.startup.homepage won't change
   await ext1.unload();
 
   await checkHomepageOverride(ext2, HOME_URI_2, CONTROLLED_BY_THIS);
 
-  ok(Preferences.get("browser.startup.homepage").endsWith(HOME_URI_2),
+  ok(getHomePageURL().endsWith(HOME_URI_2),
      "Home url should be overridden by the second extension.");
 
-  prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext3.startup();
   await prefPromise;
 
-  ok(Preferences.get("browser.startup.homepage").endsWith(HOME_URI_3),
+  ok(getHomePageURL().endsWith(HOME_URI_3),
      "Home url should be overridden by the third extension.");
 
   await checkHomepageOverride(ext3, HOME_URI_3, CONTROLLED_BY_THIS);
 
   // Because we are unloading an earlier extension, browser.startup.homepage won't change
   await ext2.unload();
 
-  ok(Preferences.get("browser.startup.homepage").endsWith(HOME_URI_3),
+  ok(getHomePageURL().endsWith(HOME_URI_3),
      "Home url should be overridden by the third extension.");
 
   await checkHomepageOverride(ext3, HOME_URI_3, CONTROLLED_BY_THIS);
 
-  prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext4.startup();
   await prefPromise;
 
-  ok(Preferences.get("browser.startup.homepage").endsWith(HOME_URI_4),
+  ok(getHomePageURL().endsWith(HOME_URI_4),
      "Home url should be overridden by the third extension.");
 
   await checkHomepageOverride(ext3, HOME_URI_4, CONTROLLED_BY_OTHER);
 
-  prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext4.unload();
   await prefPromise;
 
-  ok(Preferences.get("browser.startup.homepage").endsWith(HOME_URI_3),
+  ok(getHomePageURL().endsWith(HOME_URI_3),
      "Home url should be overridden by the third extension.");
 
   await checkHomepageOverride(ext3, HOME_URI_3, CONTROLLED_BY_THIS);
 
-  prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext3.unload();
   await prefPromise;
 
-  is(Preferences.get("browser.startup.homepage"), defaultHomePage,
+  is(getHomePageURL(), defaultHomePage,
      "Home url should be reset to default");
 
   await ext5.startup();
-  await checkHomepageOverride(ext5, null, CONTROLLABLE);
+  await checkHomepageOverride(ext5, defaultHomePage, CONTROLLABLE);
   await ext5.unload();
 });
 
 const HOME_URI_1 = "http://example.com/";
 const USER_URI = "http://example.edu/";
 
 add_task(async function test_extension_setting_home_page_back() {
-  let defaultHomePage = Preferences.get("browser.startup.homepage");
+  let defaultHomePage = getHomePageURL();
 
-  Preferences.set("browser.startup.homepage", USER_URI);
+  Services.prefs.setStringPref(HOMEPAGE_URL_PREF, USER_URI);
 
-  is(Preferences.get("browser.startup.homepage"), USER_URI,
+  is(getHomePageURL(), USER_URI,
      "Home url should be the user set value");
 
   let ext1 = ExtensionTestUtils.loadExtension({
     manifest: {"chrome_settings_overrides": {homepage: HOME_URI_1}},
     useAddonManager: "temporary",
   });
 
   // Because we are expecting the pref to change when we start or unload, we
   // need to wait on a pref change.  This is because the pref management is
   // async and can happen after the startup/unload is finished.
-  let prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  let prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext1.startup();
   await prefPromise;
 
-  ok(Preferences.get("browser.startup.homepage").endsWith(HOME_URI_1),
+  ok(getHomePageURL().endsWith(HOME_URI_1),
      "Home url should be overridden by the second extension.");
 
-  prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext1.unload();
   await prefPromise;
 
-  is(Preferences.get("browser.startup.homepage"), USER_URI,
+  is(getHomePageURL(), USER_URI,
      "Home url should be the user set value");
 
-  Preferences.reset("browser.startup.homepage");
+  Services.prefs.clearUserPref(HOMEPAGE_URL_PREF);
 
-  is(Preferences.get("browser.startup.homepage"), defaultHomePage,
+  is(getHomePageURL(), defaultHomePage,
      "Home url should be the default");
 });
 
 add_task(async function test_disable() {
-  let defaultHomePage = Preferences.get("browser.startup.homepage");
+  let defaultHomePage = getHomePageURL();
 
   const ID = "id@tests.mozilla.org";
 
   let ext1 = ExtensionTestUtils.loadExtension({
     manifest: {
       applications: {
         gecko: {
           id: ID,
@@ -206,56 +213,56 @@ add_task(async function test_disable() {
       },
       "chrome_settings_overrides": {
         homepage: HOME_URI_1,
       },
     },
     useAddonManager: "temporary",
   });
 
-  let prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  let prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext1.startup();
   await prefPromise;
 
-  ok(Preferences.get("browser.startup.homepage").endsWith(HOME_URI_1),
+  ok(getHomePageURL().endsWith(HOME_URI_1),
      "Home url should be overridden by the extension.");
 
   let addon = await AddonManager.getAddonByID(ID);
   is(addon.id, ID);
 
-  prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   addon.userDisabled = true;
   await prefPromise;
 
-  is(Preferences.get("browser.startup.homepage"), defaultHomePage,
+  is(getHomePageURL(), defaultHomePage,
      "Home url should be the default");
 
-  prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   addon.userDisabled = false;
   await prefPromise;
 
-  ok(Preferences.get("browser.startup.homepage").endsWith(HOME_URI_1),
+  ok(getHomePageURL().endsWith(HOME_URI_1),
      "Home url should be overridden by the extension.");
 
-  prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext1.unload();
   await prefPromise;
 
-  is(Preferences.get("browser.startup.homepage"), defaultHomePage,
+  is(getHomePageURL(), defaultHomePage,
      "Home url should be the default");
 });
 
 add_task(async function test_local() {
   let ext1 = ExtensionTestUtils.loadExtension({
     manifest: {"chrome_settings_overrides": {"homepage": "home.html"}},
     useAddonManager: "temporary",
   });
 
-  let prefPromise = promisePrefChangeObserved("browser.startup.homepage");
+  let prefPromise = promisePrefChangeObserved(HOMEPAGE_URL_PREF);
   await ext1.startup();
   await prefPromise;
 
-  let homepage = Preferences.get("browser.startup.homepage");
+  let homepage = getHomePageURL();
   ok((homepage.startsWith("moz-extension") && homepage.endsWith("home.html")),
      "Home url should be relative to extension.");
 
   await ext1.unload();
 });
--- a/browser/components/extensions/test/xpcshell/test_ext_url_overrides_newtab.js
+++ b/browser/components/extensions/test/xpcshell/test_ext_url_overrides_newtab.js
@@ -31,16 +31,18 @@ AddonTestUtils.overrideCertDB();
 createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "1", "42");
 
 function awaitEvent(eventName) {
   return new Promise(resolve => {
     Management.once(eventName, (e, ...args) => resolve(...args));
   });
 }
 
+const DEFAULT_NEW_TAB_URL = aboutNewTabService.newTabURL;
+
 add_task(async function test_multiple_extensions_overriding_newtab_page() {
   const NEWTAB_URI_2 = "webext-newtab-1.html";
   const NEWTAB_URI_3 = "webext-newtab-2.html";
   const EXT_2_ID = "ext2@tests.mozilla.org";
   const EXT_3_ID = "ext3@tests.mozilla.org";
 
   const CONTROLLABLE = "controllable_by_this_extension";
   const CONTROLLED_BY_THIS = "controlled_by_this_extension";
@@ -64,23 +66,18 @@ add_task(async function test_multiple_ex
       }
     });
   }
 
   async function checkNewTabPageOverride(ext, expectedValue, expectedLevelOfControl) {
     ext.sendMessage("checkNewTabPage");
     let newTabPage = await ext.awaitMessage("newTabPage");
 
-    if (expectedValue) {
-      ok(newTabPage.value.endsWith(expectedValue),
-         `newTabPageOverride setting returns the expected value ending with: ${expectedValue}.`);
-    } else {
-      equal(newTabPage.value, expectedValue,
-            `newTabPageOverride setting returns the expected value: ${expectedValue}.`);
-    }
+    ok(newTabPage.value.endsWith(expectedValue),
+       `newTabPageOverride setting returns the expected value ending with: ${expectedValue}.`);
     equal(newTabPage.levelOfControl, expectedLevelOfControl,
           `newTabPageOverride setting returns the expected levelOfControl: ${expectedLevelOfControl}.`);
   }
 
   let extObj = {
     manifest: {
       "chrome_url_overrides": {},
       permissions: ["browserSettings"],
@@ -94,106 +91,106 @@ add_task(async function test_multiple_ex
   extObj.manifest.chrome_url_overrides = {newtab: NEWTAB_URI_2};
   extObj.manifest.applications = {gecko: {id: EXT_2_ID}};
   let ext2 = ExtensionTestUtils.loadExtension(extObj);
 
   extObj.manifest.chrome_url_overrides = {newtab: NEWTAB_URI_3};
   extObj.manifest.applications.gecko.id =  EXT_3_ID;
   let ext3 = ExtensionTestUtils.loadExtension(extObj);
 
-  equal(aboutNewTabService.newTabURL, "about:newtab",
-     "Default newtab url is about:newtab");
+  equal(aboutNewTabService.newTabURL, DEFAULT_NEW_TAB_URL,
+     "newTabURL is set to the default.");
 
   await promiseStartupManager();
 
   await ext1.startup();
-  equal(aboutNewTabService.newTabURL, "about:newtab",
-       "Default newtab url is still about:newtab");
+  equal(aboutNewTabService.newTabURL, DEFAULT_NEW_TAB_URL,
+       "newTabURL is still set to the default.");
 
-  await checkNewTabPageOverride(ext1, null, CONTROLLABLE);
+  await checkNewTabPageOverride(ext1, aboutNewTabService.newTabURL, CONTROLLABLE);
 
   await ext2.startup();
   ok(aboutNewTabService.newTabURL.endsWith(NEWTAB_URI_2),
-     "Newtab url is overriden by the second extension.");
+     "newTabURL is overriden by the second extension.");
   await checkNewTabPageOverride(ext1, NEWTAB_URI_2, CONTROLLED_BY_OTHER);
 
   // Verify that calling set and clear do nothing.
   ext2.sendMessage("trySet");
   await ext2.awaitMessage("newTabPageSet");
   await checkNewTabPageOverride(ext1, NEWTAB_URI_2, CONTROLLED_BY_OTHER);
 
   ext2.sendMessage("tryClear");
   await ext2.awaitMessage("newTabPageCleared");
   await checkNewTabPageOverride(ext1, NEWTAB_URI_2, CONTROLLED_BY_OTHER);
 
   // Disable the second extension.
   let addon = await AddonManager.getAddonByID(EXT_2_ID);
   let disabledPromise = awaitEvent("shutdown");
   addon.userDisabled = true;
   await disabledPromise;
-  equal(aboutNewTabService.newTabURL, "about:newtab",
-        "Newtab url is about:newtab after second extension is disabled.");
-  await checkNewTabPageOverride(ext1, null, CONTROLLABLE);
+  equal(aboutNewTabService.newTabURL, DEFAULT_NEW_TAB_URL,
+        "newTabURL url is reset to the default after second extension is disabled.");
+  await checkNewTabPageOverride(ext1, aboutNewTabService.newTabURL, CONTROLLABLE);
 
   // Re-enable the second extension.
   let enabledPromise = awaitEvent("ready");
   addon.userDisabled = false;
   await enabledPromise;
   ok(aboutNewTabService.newTabURL.endsWith(NEWTAB_URI_2),
-     "Newtab url is overriden by the second extension.");
+     "newTabURL is overriden by the second extension.");
   await checkNewTabPageOverride(ext2, NEWTAB_URI_2, CONTROLLED_BY_THIS);
 
   await ext1.unload();
   ok(aboutNewTabService.newTabURL.endsWith(NEWTAB_URI_2),
-     "Newtab url is still overriden by the second extension.");
+     "newTabURL is still overriden by the second extension.");
   await checkNewTabPageOverride(ext2, NEWTAB_URI_2, CONTROLLED_BY_THIS);
 
   await ext3.startup();
   ok(aboutNewTabService.newTabURL.endsWith(NEWTAB_URI_3),
-   "Newtab url is overriden by the third extension.");
+   "newTabURL is overriden by the third extension.");
   await checkNewTabPageOverride(ext2, NEWTAB_URI_3, CONTROLLED_BY_OTHER);
 
   // Disable the second extension.
   disabledPromise = awaitEvent("shutdown");
   addon.userDisabled = true;
   await disabledPromise;
   ok(aboutNewTabService.newTabURL.endsWith(NEWTAB_URI_3),
-   "Newtab url is still overriden by the third extension.");
+   "newTabURL is still overriden by the third extension.");
   await checkNewTabPageOverride(ext3, NEWTAB_URI_3, CONTROLLED_BY_THIS);
 
   // Re-enable the second extension.
   enabledPromise = awaitEvent("ready");
   addon.userDisabled = false;
   await enabledPromise;
   ok(aboutNewTabService.newTabURL.endsWith(NEWTAB_URI_3),
-   "Newtab url is still overriden by the third extension.");
+   "newTabURL is still overriden by the third extension.");
   await checkNewTabPageOverride(ext3, NEWTAB_URI_3, CONTROLLED_BY_THIS);
 
   await ext3.unload();
   ok(aboutNewTabService.newTabURL.endsWith(NEWTAB_URI_2),
-     "Newtab url reverts to being overriden by the second extension.");
+     "newTabURL reverts to being overriden by the second extension.");
   await checkNewTabPageOverride(ext2, NEWTAB_URI_2, CONTROLLED_BY_THIS);
 
   await ext2.unload();
-  equal(aboutNewTabService.newTabURL, "about:newtab",
-     "Newtab url is reset to about:newtab");
+  equal(aboutNewTabService.newTabURL, DEFAULT_NEW_TAB_URL,
+     "newTabURL url is reset to the default.");
 
   await promiseShutdownManager();
 });
 
 // Tests that we handle the upgrade/downgrade process correctly
 // when an extension is installed temporarily on top of a permanently
 // installed one.
 add_task(async function test_temporary_installation() {
   const ID = "newtab@tests.mozilla.org";
   const PAGE1 = "page1.html";
   const PAGE2 = "page2.html";
 
-  equal(aboutNewTabService.newTabURL, "about:newtab",
-        "Default newtab url is about:newtab");
+  equal(aboutNewTabService.newTabURL, DEFAULT_NEW_TAB_URL,
+        "newTabURL is set to the default.");
 
   await promiseStartupManager();
 
   let permanent = ExtensionTestUtils.loadExtension({
     manifest: {
       applications: {
         gecko: {id: ID},
       },
@@ -201,38 +198,38 @@ add_task(async function test_temporary_i
         newtab: PAGE1,
       },
     },
     useAddonManager: "permanent",
   });
 
   await permanent.startup();
   ok(aboutNewTabService.newTabURL.endsWith(PAGE1),
-     "newtab url is overridden by permanent extension");
+     "newTabURL is overridden by permanent extension.");
 
   let temporary = ExtensionTestUtils.loadExtension({
     manifest: {
       applications: {
         gecko: {id: ID},
       },
       chrome_url_overrides: {
         newtab: PAGE2,
       },
     },
     useAddonManager: "temporary",
   });
 
   await temporary.startup();
   ok(aboutNewTabService.newTabURL.endsWith(PAGE2),
-     "newtab url is overridden by temporary extension");
+     "newTabURL is overridden by temporary extension.");
 
   await promiseRestartManager();
   await permanent.awaitStartup();
 
   ok(aboutNewTabService.newTabURL.endsWith(PAGE1),
-     "newtab url is back to the value set by permanent extension");
+     "newTabURL is back to the value set by permanent extension.");
 
   await permanent.unload();
 
-  equal(aboutNewTabService.newTabURL, "about:newtab",
-        "newtab url is back to default about:newtab");
+  equal(aboutNewTabService.newTabURL, DEFAULT_NEW_TAB_URL,
+        "newTabURL is set back to the default.");
   await promiseShutdownManager();
 });
--- a/toolkit/components/extensions/ext-browserSettings.js
+++ b/toolkit/components/extensions/ext-browserSettings.js
@@ -1,20 +1,25 @@
 /* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set sts=2 sw=2 et tw=80: */
 "use strict";
 
 XPCOMUtils.defineLazyModuleGetter(this, "ExtensionSettingsStore",
                                   "resource://gre/modules/ExtensionSettingsStore.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "Preferences",
-                                  "resource://gre/modules/Preferences.jsm");
+XPCOMUtils.defineLazyModuleGetter(this, "Services",
+                                  "resource://gre/modules/Services.jsm");
+
+XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService",
+                                   "@mozilla.org/browser/aboutnewtab-service;1",
+                                   "nsIAboutNewTabService");
 
 Cu.import("resource://gre/modules/ExtensionPreferencesManager.jsm");
 
 const HOMEPAGE_OVERRIDE_SETTING = "homepage_override";
+const HOMEPAGE_URL_PREF = "browser.startup.homepage";
 const URL_STORE_TYPE = "url_overrides";
 const NEW_TAB_OVERRIDE_SETTING = "newTabURL";
 
 const getSettingsAPI = (extension, name, callback, storeType, readOnly = false) => {
   return {
     async get(details) {
       return {
         levelOfControl: details.incognito ?
@@ -70,39 +75,31 @@ ExtensionPreferencesManager.addSetting("
 this.browserSettings = class extends ExtensionAPI {
   getAPI(context) {
     let {extension} = context;
     return {
       browserSettings: {
         allowPopupsForUserEvents: getSettingsAPI(extension,
           "allowPopupsForUserEvents",
           () => {
-            return Preferences.get("dom.popup_allowed_events") != "";
+            return Services.prefs.getCharPref("dom.popup_allowed_events") != "";
           }),
         cacheEnabled: getSettingsAPI(extension,
           "cacheEnabled",
           () => {
-            return Preferences.get("browser.cache.disk.enable") &&
-              Preferences.get("browser.cache.memory.enable");
+            return Services.prefs.getBoolPref("browser.cache.disk.enable") &&
+              Services.prefs.getBoolPref("browser.cache.memory.enable");
           }),
         homepageOverride: getSettingsAPI(extension,
           HOMEPAGE_OVERRIDE_SETTING,
-          async () => {
-            let homepageSetting = await ExtensionPreferencesManager.getSetting(HOMEPAGE_OVERRIDE_SETTING);
-            if (homepageSetting) {
-              return homepageSetting.value;
-            }
-            return null;
+          () => {
+            return Services.prefs.getComplexValue(
+              HOMEPAGE_URL_PREF, Ci.nsIPrefLocalizedString).data;
           }, undefined, true),
         newTabPageOverride: getSettingsAPI(extension,
           NEW_TAB_OVERRIDE_SETTING,
-          async () => {
-            await ExtensionSettingsStore.initialize();
-            let newTabPageSetting = ExtensionSettingsStore.getSetting(URL_STORE_TYPE, NEW_TAB_OVERRIDE_SETTING);
-            if (newTabPageSetting) {
-              return newTabPageSetting.value;
-            }
-            return null;
+          () => {
+            return aboutNewTabService.newTabURL;
           }, URL_STORE_TYPE, true),
       },
     };
   }
 };