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

Quelle  test_doomentry.js   Sprache: JAVA

 
/**
 * Test for nsICacheStorage.asyncDoomURI().
 * It tests dooming
 *   - an existent inactive entry
 *   - a non-existent inactive entry
 *   - an existent active entry
 */


"use strict";

function doom(url, callback) {
  Services.cache2
    .diskCacheStorage(Services.loadContextInfo.default)
    .asyncDoomURI(createURI(url), "", {
      onCacheEntryDoomed(result) {
        callback(result);
      },
    });
}

function write_and_check(str, data, len) {
  var written = str.write(data, len);
  if (written != len) {
    do_throw(
      "str.write has not written all data!\n" +
        " Expected: " +
        len +
        "\n" +
        " Actual: " +
        written +
        "\n"
    );
  }
}

function write_entry() {
  asyncOpenCacheEntry(
    "http://testentry/",
    "disk",
    Ci.nsICacheStorage.OPEN_TRUNCATE,
    null,
    function (status, entry) {
      write_entry_cont(entry, entry.openOutputStream(0, -1));
    }
  );
}

function write_entry_cont(entry, ostream) {
  var data = "testdata";
  write_and_check(ostream, data, data.length);
  ostream.close();
  doom("http://testentry/", check_doom1);
}

function check_doom1(status) {
  Assert.equal(status, Cr.NS_OK);
  doom("http://nonexistententry/", check_doom2);
}

function check_doom2(status) {
  Assert.equal(status, Cr.NS_ERROR_NOT_AVAILABLE);
  asyncOpenCacheEntry(
    "http://testentry/",
    "disk",
    Ci.nsICacheStorage.OPEN_TRUNCATE,
    null,
    function (stat, entry) {
      write_entry2(entry, entry.openOutputStream(0, -1));
    }
  );
}

var gOstream;
function write_entry2(entry, ostream) {
  // write some data and doom the entry while it is active
  var data = "testdata";
  write_and_check(ostream, data, data.length);
  gOstream = ostream;
  doom("http://testentry/", check_doom3);
}

function check_doom3(status) {
  Assert.equal(status, Cr.NS_OK);
  // entry was doomed but writing should still succeed
  var data = "testdata";
  write_and_check(gOstream, data, data.length);
  gOstream.close();
  // dooming the same entry again should fail
  doom("http://testentry/", check_doom4);
}

function check_doom4(status) {
  Assert.equal(status, Cr.NS_ERROR_NOT_AVAILABLE);
  do_test_finished();
}

function run_test() {
  do_get_profile();

  // clear the cache
  evict_cache_entries();
  write_entry();
  do_test_pending();
}

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

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