Commit 94a260ca authored by Mark Banner's avatar Mark Banner
Browse files

Bug 1742788 - Enable loading from the local dump if it is newer for the...

Bug 1742788 - Enable loading from the local dump if it is newer for the search-config remote settings collection. r=robwu,daleharvey

Differential Revision: https://phabricator.services.mozilla.com/D132033
parent 085e6d77
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -58,9 +58,8 @@ def main(output):

    remotesettings_dumps = {}

    # For simplicity, let's hardcode the path of the first and (so far) only
    # RemoteSettings dump whose last_modified date is looked up (bug 1717068),
    # i.e. blocklists/addons-bloomfilters.
    # For simplicity, let's hardcode the path of the RemoteSettings dumps whose
    # last_modified date is looked up.
    # TODO bug 1719560: Replace hardcoded values with something more generic.
    if buildconfig.substs["MOZ_BUILD_APP"] != "mobile/android":
        # Until bug 1639050 is resolved, the dump isn't packaged with Android.
@@ -68,6 +67,18 @@ def main(output):
            buildconfig.topsrcdir,
            "services/settings/dumps/blocklists/addons-bloomfilters.json",
        )
    if buildconfig.substs["MOZ_BUILD_APP"] == "browser":
        # This is only packaged with browser.
        remotesettings_dumps["main/search-config"] = mozpath.join(
            buildconfig.topsrcdir,
            "services/settings/dumps/main/search-config.json",
        )
    if buildconfig.substs["MOZ_BUILD_APP"] == "comm/mail":
        # This is only packaged with Thunderbird.
        remotesettings_dumps["main/search-config"] = mozpath.join(
            buildconfig.topsrcdir,
            "comm/mail/app/settings/dumps/thunderbird/search-config.json",
        )

    output_dict = {}
    input_files = set()
+4 −1
Original line number Diff line number Diff line
@@ -140,7 +140,10 @@ class SearchEngineSelector {
    let result = [];
    let failed = false;
    try {
      result = await this._remoteConfig.get({ order: "id" });
      result = await this._remoteConfig.get({
        order: "id",
        loadDumpIfNewer: true,
      });
    } catch (ex) {
      logConsole.error(ex);
      failed = true;
+56 −0
Original line number Diff line number Diff line
/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */

"use strict";

XPCOMUtils.defineLazyModuleGetters(this, {
  RemoteSettingsWorker: "resource://services-settings/RemoteSettingsWorker.jsm",
  SearchEngineSelector: "resource://gre/modules/SearchEngineSelector.jsm",
});

do_get_profile();

add_task(async function test_selector_db_out_of_date() {
  let searchConfig = RemoteSettings(SearchUtils.SETTINGS_KEY);

  // Do an initial get to pre-seed the database.
  await searchConfig.get();

  // Now clear the database and re-fill it.
  let db = searchConfig.db;
  await db.clear();
  let databaseEntries = await db.list();
  Assert.equal(databaseEntries.length, 0, "Should have cleared the database.");

  // Add a dummy record with an out-of-date last modified.
  await RemoteSettingsWorker._execute("_test_only_import", [
    "main",
    SearchUtils.SETTINGS_KEY,
    [
      {
        id: "b70edfdd-1c3f-4b7b-ab55-38cb048636c0",
        default: "yes",
        webExtension: { id: "outofdate@search.mozilla.org" },
        appliesTo: [{ included: { everywhere: true } }],
        last_modified: 1606227264000,
      },
    ],
  ]);

  // Now load the configuration and check we get what we expect.
  let engineSelector = new SearchEngineSelector();
  let result = await engineSelector.fetchEngineConfiguration({
    // Use the fallback default locale/regions to get a simple list.
    locale: "default",
    region: "default",
  });
  Assert.deepEqual(
    result.engines.map(e => e.webExtension.id),
    [
      "google@search.mozilla.org",
      "wikipedia@search.mozilla.org",
      "ddg@search.mozilla.org",
    ],
    "Should have returned the correct data."
  );
});
+1 −0
Original line number Diff line number Diff line
@@ -23,5 +23,6 @@ requesttimeoutfactor = 2
[test_mailru.js]
[test_qwant.js]
[test_rakuten.js]
[test_selector_db_out_of_date.js]
[test_yahoojp.js]
[test_yandex.js]