Commit ce86e6ff authored by jneuberger's avatar jneuberger
Browse files

Bug 1828678 - Set signon.signupDetection.enabled to true in Nightly...

Bug 1828678 - Set signon.signupDetection.enabled to true in Nightly r=credential-management-reviewers,sgalich

Differential Revision: https://phabricator.services.mozilla.com/D176021
parent 48047596
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -3192,7 +3192,11 @@ pref("signon.firefoxRelay.base_url", "https://relay.firefox.com/api/v1/");
pref("signon.firefoxRelay.learn_more_url", "https://support.mozilla.org/1/firefox/%VERSION%/%OS%/%LOCALE%/firefox-relay-integration");
pref("signon.firefoxRelay.manage_url", "https://relay.firefox.com");
pref("signon.signupDetection.confidenceThreshold",     "0.75");
#ifdef NIGHTLY_BUILD
  pref("signon.signupDetection.enabled", true);
#else
  pref("signon.signupDetection.enabled", false);
#endif

// Satchel (Form Manager) prefs
pref("browser.formfill.debug",            false);
+1 −0
Original line number Diff line number Diff line
@@ -153,6 +153,7 @@ skip-if =
[browser_proxyAuth_prompt.js]
skip-if = os == "android"
[browser_relay_telemetry.js]
[browser_telemetry_SignUpFormRuleset.js]
[browser_test_changeContentInputValue.js]
[browser_username_only_form_telemetry.js]
[browser_username_select_dialog.js]
+0 −38
Original line number Diff line number Diff line
"use strict";

const SIGNUP_DETECTION_HISTOGRAM = "PWMGR_SIGNUP_FORM_DETECTION_MS";
const TEST_URL = `https://example.com${DIRECTORY_PATH}form_signup_detection.html`;

/**
 *
 * @param {Object} histogramData The histogram data to examine
 * @returns The amount of entries found in the histogram data
 */
function countEntries(histogramData) {
  info(typeof histogramData);
  return histogramData
    ? Object.values(histogramData.values).reduce((a, b) => a + b, 0)
    : null;
}

/**
 * @param {String} id The histogram to examine
 * @param {Number} expected The expected amount of entries for a histogram
 */
async function countEntriesOfChildHistogram(id, expected) {
  let histogram;
  await TestUtils.waitForCondition(() => {
    let histograms = Services.telemetry.getSnapshotForHistograms("main", false)
      .content;

    histogram = histograms[id];

    return !!histogram && countEntries(histogram) == expected;
  }, `The histogram ${id} was expected to have ${expected} entries.`);
  Assert.equal(countEntries(histogram), expected);
}

add_task(async () => {
  await BrowserTestUtils.withNewTab(
    {
@@ -39,9 +9,6 @@ add_task(async () => {
      url: TEST_URL,
    },
    async function(browser) {
      // we are clearing the histogram here, because loading the document already creates two histogram entries
      Services.telemetry.getHistogramById(SIGNUP_DETECTION_HISTOGRAM).clear();

      await SpecialPowers.spawn(browser, [], async () => {
        const doc = content.document;
        const { LoginManagerChild } = ChromeUtils.importESModule(
@@ -72,9 +39,4 @@ add_task(async () => {
      });
    }
  );

  info(
    "Test case: After running isProbablyASignUpForm against two <form> HTML elements, the histogram PWMGR_SIGNUP_FORM_DETECTION_MS should have two entries."
  );
  await countEntriesOfChildHistogram(SIGNUP_DETECTION_HISTOGRAM, 2);
});
+55 −0
Original line number Diff line number Diff line
"use strict";

const SIGNUP_DETECTION_HISTOGRAM = "PWMGR_SIGNUP_FORM_DETECTION_MS";
const TEST_URL = `https://example.com${DIRECTORY_PATH}form_signup_detection.html`;

/**
 *
 * @param {Object} histogramData The histogram data to examine
 * @returns The amount of entries found in the histogram data
 */
function countEntries(histogramData) {
  info(typeof histogramData);
  return histogramData
    ? Object.values(histogramData.values).reduce((a, b) => a + b, 0)
    : null;
}

/**
 * @param {String} id The histogram to examine
 * @param {Number} expected The expected amount of entries for a histogram
 */
async function countEntriesOfChildHistogram(id, expected) {
  let histogram;
  await TestUtils.waitForCondition(() => {
    let histograms = Services.telemetry.getSnapshotForHistograms("main", false)
      .content;

    histogram = histograms[id];

    return !!histogram && countEntries(histogram) == expected;
  }, `The histogram ${id} was expected to have ${expected} entries.`);
  Assert.equal(countEntries(histogram), expected);
}

add_setup(async () => {
  await SpecialPowers.pushPrefEnv({
    set: [["signon.signupDetection.enabled", true]],
  });
  Services.telemetry.getHistogramById(SIGNUP_DETECTION_HISTOGRAM).clear();
});

add_task(async () => {
  let formProcessed = listenForTestNotification("FormProcessed", 2);

  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL);

  await formProcessed;

  info(
    "Test case: When loading the document the two <form> HTML elements are processed and each one is run against the SignUpFormRuleset. After the page load the histogram PWMGR_SIGNUP_FORM_DETECTION_MS should have two entries."
  );
  await countEntriesOfChildHistogram(SIGNUP_DETECTION_HISTOGRAM, 2);

  gBrowser.removeTab(tab);
});