Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/toolkit/profile/test/xpcshell/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  test_appgroup_profile.js

  Sprache: JAVA
 

/* Any copyright is dedicated to the Public Domain.
   http://creativecommons.org/publicdomain/zero/1.0/ */


/*
 * Tests that profile is inside App Group container when MOZ_APP_GROUP is set.
 */


add_task(async function test_appgroup_profile_location() {
  if (AppConstants.MOZ_UPDATE_CHANNEL != "nightly") {
    return;
  }
  Services.env.set("MOZ_APP_GROUP""1");
  const profileName = "testappgroup";
  const service = getProfileService();
  const profile = service.createProfile(null, profileName, "tests");
  profile.lock({});
  service.flush();

  registerCleanupFunction(() => {
    if (profile) {
      profile.remove(true);
      service.flush();
    }
    Services.env.set("MOZ_APP_GROUP""");
  });

  const profileDir = profile.rootDir;

  const APP_GROUP_PATH =
    "Group Containers/43AQ936H96.org.mozilla.firefox.browserprofiles";

  Assert.ok(
    profileDir.path.includes(APP_GROUP_PATH),
    "Profile should be inside App Group container when MOZ_APP_GROUP is set"
  );

  const uAppData = Services.dirsvc.get("UAppData", Ci.nsIFile);
  const iniFile = uAppData.clone();
  iniFile.append("profiles.ini");

  const factory = Cc["@mozilla.org/xpcom/ini-parser-factory;1"].getService(
    Ci.nsIINIParserFactory
  );
  const ini = factory.createINIParser(iniFile);

  // Find the section whose name matches our profile.
  let sectionName = null;
  const sections = ini.getSections();
  while (sections.hasMore()) {
    const s = sections.getNext();
    let name = "";
    try {
      name = ini.getString(s, "Name");
    } catch (_) {}
    if (name === profileName) {
      sectionName = s;
      break;
    }
  }
  Assert.ok(sectionName, "profiles.ini contains a section for this profile");

  // Ensure profiles.ini stores a relative entry.
  Assert.equal(
    ini.getString(sectionName, "IsRelative"),
    "1",
    "IsRelative=1 for App Group profile"
  );

  const relPath = ini.getString(sectionName, "Path");
  Assert.ok(!relPath.startsWith("/"), "profiles.ini Path is not absolute");
  Assert.ok(
    relPath.includes("/Profiles/"),
    "profiles.ini Path contains /Profiles/"
  );

  // localDir should also be under the App Group container.
  const localDir = profile.localDir;
  Assert.ok(
    localDir.path.includes(APP_GROUP_PATH) &&
      localDir.path.includes("/Library/Caches/Profiles/"),
    "localDir should be under App Group Library/Caches/Profiles"
  );

  const localTail = localDir.path.split("/Profiles/")[1];
  const rootTail = profileDir.path.split("/Profiles/")[1];
  Assert.equal(
    localTail,
    rootTail,
    "localDir keeps the same Profiles/ tail as rootDir"
  );
});

Messung V0.5 in Prozent
C=83 H=93 G=87

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

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.