Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  test_objectgrips-25.js

  Sprache: JAVA
 

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


// Test object with private properties (preview + enumPrivateProperties)

"use strict";

Services.prefs.setBoolPref("security.allow_eval_with_system_principal"true);
registerCleanupFunction(() => {
  Services.prefs.clearUserPref("security.allow_eval_with_system_principal");
});

function evalCode(debuggee) {
  debuggee.eval(
    // These arguments are tested.
    // eslint-disable-next-line no-unused-vars
    function stopMe(obj) {
      debugger;
    }.toString()
  );
  debuggee.eval(`
    class MyClass {
      constructor(name, password) {
        this.name = name;
        this.#password = password;
      }

      #password;
      #salt = "sEcr3t";
      #getSaltedPassword() {
        return this.#password + this.#salt;
      }
    }

    stopMe(new MyClass("Susie""p4$$w0rD"));
  `);
}

add_task(
  threadFrontTest(async ({ threadFront, debuggee }) => {
    const packet = await executeOnNextTickAndWaitForPause(
      () => evalCode(debuggee),
      threadFront
    );

    const [grip] = packet.frame.arguments;

    let { privateProperties } = grip.preview;
    strictEqual(
      privateProperties.length,
      2,
      "There is 2 private properties in the grip preview"
    );
    let [password, salt] = privateProperties;

    strictEqual(
      password.name,
      "#password",
      "Got expected name for #password private property in preview"
    );
    deepEqual(
      password.descriptor,
      {
        configurable: true,
        enumerable: false,
        writable: true,
        value: "p4$$w0rD",
      },
      "Got expected property descriptor for #password in preview"
    );

    strictEqual(
      salt.name,
      "#salt",
      "Got expected name for #salt private property in preview"
    );
    deepEqual(
      salt.descriptor,
      {
        configurable: true,
        enumerable: false,
        writable: true,
        value: "sEcr3t",
      },
      "Got expected property descriptor for #salt in preview"
    );

    const objClient = threadFront.pauseGrip(grip);
    const iterator = await objClient.enumPrivateProperties();
    ({ privateProperties } = await iterator.slice(0, iterator.count));

    strictEqual(
      privateProperties.length,
      2,
      "enumPrivateProperties returned 2 private properties."
    );
    [password, salt] = privateProperties;

    strictEqual(
      password.name,
      "#password",
      "Got expected name for #password private property via enumPrivateProperties"
    );
    deepEqual(
      password.descriptor,
      {
        configurable: true,
        enumerable: false,
        writable: true,
        value: "p4$$w0rD",
      },
      "Got expected property descriptor for #password via enumPrivateProperties"
    );

    strictEqual(
      salt.name,
      "#salt",
      "Got expected name for #salt private property via enumPrivateProperties"
    );
    deepEqual(
      salt.descriptor,
      {
        configurable: true,
        enumerable: false,
        writable: true,
        value: "sEcr3t",
      },
      "Got expected property descriptor for #salt via enumPrivateProperties"
    );

    await threadFront.resume();
  })
);

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

¤ Dauer der Verarbeitung: 0.20 Sekunden  (vorverarbeitet am  2026-06-08) ¤

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






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik