Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Firefox/dom/quota/test/xpcshell/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  test_artificialFailure.js   Sprache: JAVA

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


const { PrincipalUtils } = ChromeUtils.importESModule(
  "resource://testing-common/dom/quota/test/modules/PrincipalUtils.sys.mjs"
);
const { QuotaUtils } = ChromeUtils.importESModule(
  "resource://testing-common/dom/quota/test/modules/QuotaUtils.sys.mjs"
);
const { SimpleDBUtils } = ChromeUtils.importESModule(
  "resource://testing-common/dom/simpledb/test/modules/SimpleDBUtils.sys.mjs"
);

async function testSteps() {
  const categories = [
    Ci.nsIQuotaArtificialFailure.CATEGORY_NONE,
    Ci.nsIQuotaArtificialFailure.CATEGORY_INITIALIZE_ORIGIN,
  ];
  const principal = PrincipalUtils.createPrincipal("https://example.com");
  const name = "foo";

  for (let category of categories) {
    info("Creating database");

    {
      const connection = SimpleDBUtils.createConnection(principal);

      const openRequest = connection.open(name);
      await SimpleDBUtils.requestFinished(openRequest);

      const closeRequest = connection.close();
      await SimpleDBUtils.requestFinished(closeRequest);
    }

    info("Resetting storage");

    {
      const request = Services.qms.reset();
      await QuotaUtils.requestFinished(request);
    }

    info("Opening database");

    const ex = await QuotaUtils.withArtificialFailures(
      category,
      /* probability */ 100,
      Cr.NS_ERROR_FILE_ACCESS_DENIED,
      async function () {
        const connection = SimpleDBUtils.createConnection(principal);
        const request = connection.open(name);
        try {
          await SimpleDBUtils.requestFinished(request);
          return null;
        } catch (ex) {
          return ex;
        }
      }
    );

    if (category == Ci.nsIQuotaArtificialFailure.CATEGORY_NONE) {
      Assert.ok(!ex, "Should not have thrown");
    } else {
      Assert.ok(ex, "Should have thrown");
      Assert.strictEqual(
        ex.resultCode,
        // NS_ERROR_FILE_ACCESS_DENIED is mapped to NS_ERROR_FAILURE during error
        // propagation.
        NS_ERROR_FAILURE,
        "Threw right result code"
      );
    }

    info("Clearing storage");

    {
      const request = Services.qms.clear();
      await QuotaUtils.requestFinished(request);
    }
  }
}

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

¤ Dauer der Verarbeitung: 0.22 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.