Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/editor/libeditor/tests/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 3 kB image not shown  

Quelle  test_cut_copy_password.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/editor/libeditor/tests/test_cut_copy_password.html


<!doctype html>
<html>
<head>
  <title>Test for cut/copy in password field</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
  <input type="password">
<script>
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(async () => {
  let input = document.getElementsByTagName("input")[0];
  let editor = SpecialPowers.wrap(input).editor;
  const kMask = editor.passwordMask;
  async function copyToClipboard(aExpectedValue) {
    try {
      await SimpleTest.promiseClipboardChange(
          aExpectedValue, () => { SpecialPowers.doCommand(window, "cmd_copy"); },
          undefined, undefined, aExpectedValue === null);
    } catch (e) {
      console.error(e);
    }
  }
  async function cutToClipboard(aExpectedValue) {
    try {
      await SimpleTest.promiseClipboardChange(
          aExpectedValue, () => { SpecialPowers.doCommand(window, "cmd_cut"); },
          undefined, undefined, aExpectedValue === null);
    } catch (e) {
      console.error(e);
    }
  }
  input.value = "abcdef";
  input.focus();

  input.setSelectionRange(0, 6);
  ok(true, "Trying to copy masked password...");
  await copyToClipboard(null);
  isnot(SpecialPowers.getClipboardData("text/plain"), "abcdef",
        "Copying masked password shouldn't copy raw value into the clipboard");
  isnot(SpecialPowers.getClipboardData("text/plain"), `${kMask}${kMask}${kMask}${kMask}${kMask}${kMask}`,
        "Copying masked password shouldn't copy masked value into the clipboard");
  ok(true, "Trying to cut masked password...");
  await cutToClipboard(null);
  isnot(SpecialPowers.getClipboardData("text/plain"), "abcdef",
        "Cutting masked password shouldn't copy raw value into the clipboard");
  isnot(SpecialPowers.getClipboardData("text/plain"), `${kMask}${kMask}${kMask}${kMask}${kMask}${kMask}`,
        "Cutting masked password shouldn't copy masked value into the clipboard");
  is(input.value, "abcdef",
     "Cutting masked password shouldn't modify the value");

  editor.unmask(2, 4);
  input.setSelectionRange(0, 6);
  ok(true, "Trying to copy partially masked password...");
  await copyToClipboard(null);
  isnot(SpecialPowers.getClipboardData("text/plain"), "abcdef",
        "Copying partially masked password shouldn't copy raw value into the clipboard");
  isnot(SpecialPowers.getClipboardData("text/plain"), `${kMask}${kMask}cd${kMask}${kMask}`,
        "Copying partially masked password shouldn't copy partially masked value into the clipboard");
  isnot(SpecialPowers.getClipboardData("text/plain"), `${kMask}${kMask}${kMask}${kMask}${kMask}${kMask}`,
        "Copying partially masked password shouldn't copy masked value into the clipboard");
  ok(true, "Trying to cut partially masked password...");
  await cutToClipboard(null);
  isnot(SpecialPowers.getClipboardData("text/plain"), "abcdef",
        "Cutting partially masked password shouldn't copy raw value into the clipboard");
  isnot(SpecialPowers.getClipboardData("text/plain"), `${kMask}${kMask}cd${kMask}${kMask}`,
        "Cutting partially masked password shouldn't copy partially masked value into the clipboard");
  isnot(SpecialPowers.getClipboardData("text/plain"), `${kMask}${kMask}${kMask}${kMask}${kMask}${kMask}`,
        "Cutting partially masked password shouldn't copy masked value into the clipboard");
  is(input.value, "abcdef",
     "Cutting partially masked password shouldn't modify the value");

  input.setSelectionRange(2, 4);
  ok(true, "Trying to copy unmasked password...");
  await copyToClipboard("cd");
  is(input.value, "abcdef",
     "Copying unmasked password shouldn't modify the value");

  input.value = "012345";
  editor.unmask(2, 4);
  input.setSelectionRange(2, 4);
  ok(true, "Trying to cut unmasked password...");
  await cutToClipboard("23");
  is(input.value, "0145",
     "Cutting unmasked password should modify the value");

  SimpleTest.finish();
});
</script>
</body>
</html>

Messung V0.5
C=93 H=96 G=94

¤ 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.