Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/browser/components/urlbar/tests/unit/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 7 kB image not shown  

Quelle  test_exposure.js   Sprache: JAVA

 
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
 * You can obtain one at http://mozilla.org/MPL/2.0/. */


// Tests that registering an exposureResults pref and triggering a match causes
// the exposure event to be recorded on the UrlbarResults.

ChromeUtils.defineESModuleGetters(this, {
  UrlbarProviderQuickSuggest:
    "resource:///modules/UrlbarProviderQuickSuggest.sys.mjs",
});

const REMOTE_SETTINGS_RESULTS = [
  QuickSuggestTestUtils.ampRemoteSettings({
    keywords: ["amp""amp and wikipedia"],
  }),
  QuickSuggestTestUtils.wikipediaRemoteSettings({
    keywords: ["wikipedia""amp and wikipedia"],
  }),
];

add_setup(async function setup() {
  await QuickSuggestTestUtils.ensureQuickSuggestInit({
    remoteSettingsRecords: [
      {
        type: "data",
        attachment: REMOTE_SETTINGS_RESULTS,
      },
    ],
    prefs: [
      ["suggest.quicksuggest.nonsponsored"true],
      ["suggest.quicksuggest.sponsored"true],
    ],
  });
});

add_task(async function oneExposureResult_shown_matched() {
  UrlbarPrefs.set("exposureResults", suggestResultType("adm_sponsored"));
  UrlbarPrefs.set("showExposureResults"true);

  let context = createContext("amp", {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });

  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.ampResult(),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.SHOWN,
      },
    ],
  });
});

add_task(async function oneExposureResult_shown_notMatched() {
  UrlbarPrefs.set("exposureResults", suggestResultType("adm_sponsored"));
  UrlbarPrefs.set("showExposureResults"true);

  let context = createContext("wikipedia", {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });

  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.wikipediaResult(),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.NONE,
      },
    ],
  });
});

add_task(async function oneExposureResult_hidden_matched() {
  UrlbarPrefs.set("exposureResults", suggestResultType("adm_sponsored"));
  UrlbarPrefs.set("showExposureResults"false);

  let context = createContext("amp", {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });

  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.ampResult(),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.HIDDEN,
      },
    ],
  });
});

add_task(async function oneExposureResult_hidden_notMatched() {
  UrlbarPrefs.set("exposureResults", suggestResultType("adm_sponsored"));
  UrlbarPrefs.set("showExposureResults"false);

  let context = createContext("wikipedia", {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });

  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.wikipediaResult(),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.NONE,
      },
    ],
  });
});

add_task(async function manyExposureResults_shown_oneMatched_1() {
  UrlbarPrefs.set(
    "exposureResults",
    [
      suggestResultType("adm_sponsored"),
      suggestResultType("adm_nonsponsored"),
    ].join(",")
  );
  UrlbarPrefs.set("showExposureResults"true);

  let context = createContext("amp", {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });
  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.ampResult(),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.SHOWN,
      },
    ],
  });
});

add_task(async function manyExposureResults_shown_oneMatched_2() {
  UrlbarPrefs.set(
    "exposureResults",
    [
      suggestResultType("adm_sponsored"),
      suggestResultType("adm_nonsponsored"),
    ].join(",")
  );
  UrlbarPrefs.set("showExposureResults"true);

  let context = createContext("wikipedia", {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });
  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.wikipediaResult(),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.SHOWN,
      },
    ],
  });
});

add_task(async function manyExposureResults_shown_manyMatched() {
  UrlbarPrefs.set(
    "exposureResults",
    [
      suggestResultType("adm_sponsored"),
      suggestResultType("adm_nonsponsored"),
    ].join(",")
  );
  UrlbarPrefs.set("showExposureResults"true);

  let keyword = "amp and wikipedia";
  let context = createContext(keyword, {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });

  // Only one result should be added since exposures are shown and at most one
  // Suggest result should be shown.
  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.ampResult({ keyword }),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.SHOWN,
      },
    ],
  });
});

add_task(async function manyExposureResults_hidden_oneMatched_1() {
  UrlbarPrefs.set(
    "exposureResults",
    [
      suggestResultType("adm_sponsored"),
      suggestResultType("adm_nonsponsored"),
    ].join(",")
  );
  UrlbarPrefs.set("showExposureResults"false);

  let context = createContext("amp", {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });
  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.ampResult(),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.HIDDEN,
      },
    ],
  });
});

add_task(async function manyExposureResults_hidden_oneMatched_2() {
  UrlbarPrefs.set(
    "exposureResults",
    [
      suggestResultType("adm_sponsored"),
      suggestResultType("adm_nonsponsored"),
    ].join(",")
  );
  UrlbarPrefs.set("showExposureResults"false);

  let context = createContext("wikipedia", {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });
  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.wikipediaResult(),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.HIDDEN,
      },
    ],
  });
});

add_task(async function manyExposureResults_hidden_manyMatched() {
  UrlbarPrefs.set(
    "exposureResults",
    [
      suggestResultType("adm_sponsored"),
      suggestResultType("adm_nonsponsored"),
    ].join(",")
  );
  UrlbarPrefs.set("showExposureResults"false);

  let keyword = "amp and wikipedia";
  let context = createContext(keyword, {
    providers: [UrlbarProviderQuickSuggest.name],
    isPrivate: false,
  });

  // Both results should be added since exposures are hidden and there's no
  // limit on the number of hidden-exposure Suggest results.
  await check_results({
    context,
    matches: [
      {
        ...QuickSuggestTestUtils.ampResult({ keyword }),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.HIDDEN,
      },
      {
        ...QuickSuggestTestUtils.wikipediaResult({ keyword }),
        exposureTelemetry: UrlbarUtils.EXPOSURE_TELEMETRY.HIDDEN,
      },
    ],
  });
});

function suggestResultType(typeWithoutSource) {
  return `rust_${typeWithoutSource}`;
}

Messung V0.5
C=94 H=92 G=92

¤ Dauer der Verarbeitung: 0.1 Sekunden  (vorverarbeitet)  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.