Commit 6579381c authored by William Durand's avatar William Durand
Browse files

Bug 1800703 - Disable `extensions.install_origins.enabled` pref everywhere. r=rpl

parent 5394445e
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -1970,6 +1970,8 @@ pref("extensions.manifestV2.actionsPopupURLRestricted", false);
#else
  pref("extensions.openPopupWithoutUserGesture.enabled", false);
#endif
// Install origins restriction.
pref("extensions.install_origins.enabled", false);

// Modifier key prefs: default to Windows settings,
// menu access key = alt, accelerator key = control.
+402 −371
Original line number Diff line number Diff line
@@ -89,7 +89,13 @@ add_task(async function setup() {
});

// Test the basic install and management flows.
add_task(async function test_basic_telemetry_events() {
add_task(
  {
    // We need to enable this pref because some assertions verify that
    // `installOrigins` is collected in some Telemetry events.
    pref_set: [["extensions.install_origins.enabled", true]],
  },
  async function test_basic_telemetry_events() {
    const EXTENSION_ID = "basic@test.extension";

    const manifest = {
@@ -233,10 +239,21 @@ add_task(async function test_basic_telemetry_events() {
      .filter(evt => evt.method === "install")
      .map(evt => evt.value);
    const expectedValues = ["2", "2"];
  Assert.deepEqual(eventValues, expectedValues, "Got the expected install id");
});
    Assert.deepEqual(
      eventValues,
      expectedValues,
      "Got the expected install id"
    );
  }
);

add_task(async function test_update_telemetry_events() {
add_task(
  {
    // We need to enable this pref because some assertions verify that
    // `installOrigins` is collected in some Telemetry events.
    pref_set: [["extensions.install_origins.enabled", true]],
  },
  async function test_update_telemetry_events() {
    const EXTENSION_ID = "basic@test.extension";

    const testserver = AddonTestUtils.createHttpServer({
@@ -316,7 +333,10 @@ add_task(async function test_update_telemetry_events() {
    let addon = await AddonManager.getAddonByID(EXTENSION_ID);

    // User requested update.
  await promiseFindAddonUpdates(addon, AddonManager.UPDATE_WHEN_USER_REQUESTED);
    await promiseFindAddonUpdates(
      addon,
      AddonManager.UPDATE_WHEN_USER_REQUESTED
    );
    let installs = await AddonManager.getAllInstalls();
    await promiseCompleteAllInstalls(installs);

@@ -414,7 +434,12 @@ add_task(async function test_update_telemetry_events() {
      {
        method,
        object,
      extra: { ...baseExtra, addon_id, step: "started", updated_from: "user" },
        extra: {
          ...baseExtra,
          addon_id,
          step: "started",
          updated_from: "user",
        },
      },
      {
        method,
@@ -475,7 +500,12 @@ add_task(async function test_update_telemetry_events() {
      {
        method,
        object,
      extra: { ...baseExtra, addon_id, step: "completed", updated_from: "app" },
        extra: {
          ...baseExtra,
          addon_id,
          step: "completed",
          updated_from: "app",
        },
      },
      // Broken update to the 2.1.1 version (on ERROR_NETWORK_FAILURE).
      {
@@ -538,7 +568,8 @@ add_task(async function test_update_telemetry_events() {

    // Clear any AMTelemetry events related to the uninstalled extensions.
    getTelemetryEvents();
});
  }
);

add_task(async function test_no_telemetry_events_on_internal_sources() {
  assertNoTelemetryEvents();
+138 −123
Original line number Diff line number Diff line
@@ -23,7 +23,13 @@ add_task(async function setup() {
  AddonTestUtils.hookAMTelemetryEvents();
});

add_task(async function test_validation() {
add_task(
  {
    // We need to enable this pref because some assertions verify that
    // `installOrigins` is collected in some Telemetry events.
    pref_set: [["extensions.install_origins.enabled", true]],
  },
  async function test_validation() {
    await Assert.rejects(
      promiseInstallWebExtension({
        manifest: {
@@ -132,7 +138,11 @@ add_task(async function test_validation() {
        },
        {
          object: "dictionary",
        extra: { step: "completed", addon_id: addon.id, install_origins: "0" },
          extra: {
            step: "completed",
            addon_id: addon.id,
            install_origins: "0",
          },
        },
      ],
      "Got the expected install telemetry events for the first installed dictionary"
@@ -147,7 +157,11 @@ add_task(async function test_validation() {
        },
        {
          object: "dictionary",
        extra: { step: "completed", addon_id: addon2.id, install_origins: "0" },
          extra: {
            step: "completed",
            addon_id: addon2.id,
            install_origins: "0",
          },
        },
      ],
      "Got the expected install telemetry events for the second installed dictionary"
@@ -168,7 +182,8 @@ add_task(async function test_validation() {
      ],
      "Got the expected uninstall telemetry events"
    );
});
  }
);

const WORD = "Flehgragh";

+1 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ support-files =
  startsoftwareupdate.html
  triggerredirect.html
  unsigned.xpi
  unsigned_mv3.xpi
  webmidi_permission.xpi
  ../xpcshell/data/signing_checks/privileged.xpi

+93 −14
Original line number Diff line number Diff line
@@ -289,13 +289,13 @@ async function waitForNotification(
  return win.PopupNotifications.panel;
}

function waitForNotificationClose() {
  if (!PopupNotifications.isPanelOpen) {
function waitForNotificationClose(win = window) {
  if (!win.PopupNotifications.isPanelOpen) {
    return Promise.resolve();
  }
  return new Promise(resolve => {
    info("Waiting for notification to close");
    PopupNotifications.panel.addEventListener(
    win.PopupNotifications.panel.addEventListener(
      "popuphidden",
      function() {
        resolve();
@@ -344,7 +344,7 @@ function setupRedirect(aSettings) {

var TESTS = [
  async function test_disabledInstall() {
    SpecialPowers.pushPrefEnv({
    await SpecialPowers.pushPrefEnv({
      set: [["xpinstall.enabled", false]],
    });
    let notificationPromise = waitForNotification("xpinstall-disabled");
@@ -392,7 +392,7 @@ var TESTS = [
  },

  async function test_blockedInstall() {
    SpecialPowers.pushPrefEnv({
    await SpecialPowers.pushPrefEnv({
      set: [["extensions.postDownloadThirdPartyPrompt", false]],
    });

@@ -467,7 +467,7 @@ var TESTS = [
  },

  async function test_blockedInstallDomain() {
    SpecialPowers.pushPrefEnv({
    await SpecialPowers.pushPrefEnv({
      set: [
        ["extensions.postDownloadThirdPartyPrompt", true],
        ["extensions.install_origins.enabled", true],
@@ -500,7 +500,7 @@ var TESTS = [
  },

  async function test_allowedInstallDomain() {
    SpecialPowers.pushPrefEnv({
    await SpecialPowers.pushPrefEnv({
      set: [
        ["extensions.postDownloadThirdPartyPrompt", true],
        ["extensions.install_origins.enabled", true],
@@ -626,7 +626,7 @@ var TESTS = [
  },

  async function test_blockedPostDownload() {
    SpecialPowers.pushPrefEnv({
    await SpecialPowers.pushPrefEnv({
      set: [["extensions.postDownloadThirdPartyPrompt", true]],
    });

@@ -684,7 +684,7 @@ var TESTS = [
  },

  async function test_recommendedPostDownload() {
    SpecialPowers.pushPrefEnv({
    await SpecialPowers.pushPrefEnv({
      set: [["extensions.postDownloadThirdPartyPrompt", true]],
    });

@@ -721,7 +721,7 @@ var TESTS = [
  },

  async function test_priviledgedNo3rdPartyPrompt() {
    SpecialPowers.pushPrefEnv({
    await SpecialPowers.pushPrefEnv({
      set: [["extensions.postDownloadThirdPartyPrompt", true]],
    });
    AddonManager.checkUpdateSecurity = false;
@@ -1230,7 +1230,7 @@ var TESTS = [
  },

  async function test_failedSecurity() {
    SpecialPowers.pushPrefEnv({
    await SpecialPowers.pushPrefEnv({
      set: [
        [PREF_INSTALL_REQUIREBUILTINCERTS, false],
        ["extensions.postDownloadThirdPartyPrompt", false],
@@ -1467,8 +1467,11 @@ var TESTS = [
  },

  async function test_blockedInstallDomain_with_unified_extensions() {
    SpecialPowers.pushPrefEnv({
      set: [["extensions.unifiedExtensions.enabled", true]],
    await SpecialPowers.pushPrefEnv({
      set: [
        ["extensions.unifiedExtensions.enabled", true],
        ["extensions.install_origins.enabled", true],
      ],
    });

    let win = await BrowserTestUtils.openNewBrowserWindow();
@@ -1502,6 +1505,82 @@ var TESTS = [
    await BrowserTestUtils.closeWindow(win);
    await SpecialPowers.popPrefEnv();
  },

  async function test_mv3_installOrigins_disallowed_with_unified_extensions() {
    await SpecialPowers.pushPrefEnv({
      set: [
        ["extensions.unifiedExtensions.enabled", true],
        // Disable signature check because we load an unsigned MV3 extension.
        ["xpinstall.signatures.required", false],
        ["extensions.install_origins.enabled", true],
      ],
    });

    let win = await BrowserTestUtils.openNewBrowserWindow();
    await SimpleTest.promiseFocus(win);

    let notificationPromise = waitForNotification(
      "addon-install-failed",
      1,
      "unified-extensions-button",
      win
    );
    let triggers = encodeURIComponent(
      JSON.stringify({
        // This XPI does not have any `install_origins` in its manifest.
        XPI: "unsigned_mv3.xpi",
      })
    );
    await BrowserTestUtils.openNewForegroundTab(
      win.gBrowser,
      TESTROOT + "installtrigger.html?" + triggers
    );
    await notificationPromise;

    await BrowserTestUtils.closeWindow(win);
    await SpecialPowers.popPrefEnv();
  },

  async function test_mv3_installOrigins_allowed_with_unified_extensions() {
    await SpecialPowers.pushPrefEnv({
      set: [
        ["extensions.unifiedExtensions.enabled", true],
        // Disable signature check because we load an unsigned MV3 extension.
        ["xpinstall.signatures.required", false],
        // When this pref is disabled, install should be possible.
        ["extensions.install_origins.enabled", false],
      ],
    });

    let win = await BrowserTestUtils.openNewBrowserWindow();
    await SimpleTest.promiseFocus(win);

    let notificationPromise = waitForNotification(
      "addon-install-blocked",
      1,
      "unified-extensions-button",
      win
    );
    let triggers = encodeURIComponent(
      JSON.stringify({
        // This XPI does not have any `install_origins` in its manifest.
        XPI: "unsigned_mv3.xpi",
      })
    );
    await BrowserTestUtils.openNewForegroundTab(
      win.gBrowser,
      TESTROOT + "installtrigger.html?" + triggers
    );
    let panel = await notificationPromise;

    let closePromise = waitForNotificationClose(win);
    // hide the panel (this simulates the user dismissing it)
    panel.hidePopup();
    await closePromise;

    await BrowserTestUtils.closeWindow(win);
    await SpecialPowers.popPrefEnv();
  },
];

var gTestStart = null;
@@ -1526,7 +1605,7 @@ var XPInstallObserver = {
add_task(async function() {
  requestLongerTimeout(4);

  SpecialPowers.pushPrefEnv({
  await SpecialPowers.pushPrefEnv({
    set: [
      ["extensions.logging.enabled", true],
      ["extensions.strictCompatibility", true],
Loading