Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/toolkit/components/places/tests/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_hash.js   Sprache: JAVA

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


add_task(async function () {
  // Check particular unicode urls with insertion and selection APIs to ensure
  // url hashes match properly.
  const URLS = [
    "http://президент.президент/президент/",
    "https://www.аррӏе.com/аррӏе/",
    "http://名がドメイン/",
  ];

  for (let url of URLS) {
    await PlacesTestUtils.addVisits(url);
    Assert.ok(await PlacesUtils.history.fetch(url), "Found the added visit");
    await PlacesUtils.bookmarks.insert({
      url,
      parentGuid: PlacesUtils.bookmarks.unfiledGuid,
    });
    Assert.ok(
      await PlacesUtils.bookmarks.fetch({ url }),
      "Found the added bookmark"
    );
    let db = await PlacesUtils.promiseDBConnection();
    let rows = await db.execute(
      "SELECT id FROM moz_places WHERE url_hash = hash(:url) AND url = :url",
      { url: new URL(url).href }
    );
    Assert.equal(rows.length, 1, "Matched the place from the database");
    let id = rows[0].getResultByName("id");

    // Now, suppose the urls has been inserted without proper parsing and retry.
    // This should normally not happen through the API, but we have evidence
    // it somehow happened.
    await PlacesUtils.withConnectionWrapper("test_hash.js", async wdb => {
      await wdb.execute(
        `
        UPDATE moz_places SET url_hash = hash(:url), url = :url
        WHERE id = :id
      `,
        { url, id }
      );
      rows = await wdb.execute(
        "SELECT id FROM moz_places WHERE url_hash = hash(:url) AND url = :url",
        { url }
      );
      Assert.equal(rows.length, 1, "Matched the place from the database");
    });
  }
});

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

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