Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/modules/libpref/test/unit/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 1 kB image not shown  

Quelle  test_locked_file_prefs.js   Sprache: JAVA

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


// This file tests the `locked` attribute in default pref files.

const ps = Services.prefs;

// It is necessary to manually disable `xpc::IsInAutomation` since
// `resetPrefs` will flip the preference to re-enable `once`-synced
// preference change assertions, and also change the value of those
// preferences.
Services.prefs.setBoolPref(
  "security.turn_off_all_security_so_that_viruses_can_take_over_this_computer",
  false
);

add_test(function notChangedFromAPI() {
  ps.resetPrefs();
  ps.readDefaultPrefsFromFile(do_get_file("data/testPrefLocked.js"));
  Assert.strictEqual(ps.getIntPref("testPref.unlocked.int"), 333);
  Assert.strictEqual(ps.getIntPref("testPref.locked.int"), 444);

  // Unlocked pref: can set the user value, which is used upon reading.
  ps.setIntPref("testPref.unlocked.int", 334);
  Assert.ok(ps.prefHasUserValue("testPref.unlocked.int"), "has a user value");
  Assert.strictEqual(ps.getIntPref("testPref.unlocked.int"), 334);

  // Locked pref: can set the user value, but the default value is used upon
  // reading.
  ps.setIntPref("testPref.locked.int", 445);
  Assert.ok(ps.prefHasUserValue("testPref.locked.int"), "has a user value");
  Assert.strictEqual(ps.getIntPref("testPref.locked.int"), 444);

  // After unlocking, the user value is used.
  ps.unlockPref("testPref.locked.int");
  Assert.ok(ps.prefHasUserValue("testPref.locked.int"), "has a user value");
  Assert.strictEqual(ps.getIntPref("testPref.locked.int"), 445);

  run_next_test();
});

add_test(function notChangedFromUserPrefs() {
  ps.resetPrefs();
  ps.readDefaultPrefsFromFile(do_get_file("data/testPrefLocked.js"));
  ps.readUserPrefsFromFile(do_get_file("data/testPrefLockedUser.js"));

  Assert.strictEqual(ps.getIntPref("testPref.unlocked.int"), 333);
  Assert.strictEqual(ps.getIntPref("testPref.locked.int"), 444);

  run_next_test();
});

Messung V0.5
C=95 H=100 G=97

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© 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.