Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  browser_about_cache.js

  Sprache: JAVA
 

"use strict";

/**
 * Open a dummy page, then open about:cache and verify the opened page shows up in the cache.
 */

add_task(async function () {
  await SpecialPowers.pushPrefEnv({
    set: [["privacy.partition.network_state"false]],
  });

  const kRoot = getRootDirectory(gTestPath).replace(
    "chrome://mochitests/content/",
    "https://example.com/"
  );
  const kTestPage = kRoot + "dummy.html";
  // Open the dummy page to get it cached.
  let tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    kTestPage,
    true
  );
  BrowserTestUtils.removeTab(tab);

  tab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "about:cache",
    true
  );
  let expectedPageCheck = function (uri) {
    info("Saw load for " + uri);
    // Can't easily use searchParms and new URL() because it's an about: URI...
    return uri.startsWith("about:cache?") && uri.includes("storage=disk");
  };
  let diskPageLoaded = BrowserTestUtils.browserLoaded(
    tab.linkedBrowser,
    false,
    expectedPageCheck
  );
  await SpecialPowers.spawn(tab.linkedBrowser, [], function () {
    ok(
      !content.document.nodePrincipal.isSystemPrincipal,
      "about:cache should not have system principal"
    );
    let principal = content.document.nodePrincipal;
    let channel = content.docShell.currentDocumentChannel;
    ok(!channel.loadInfo.loadingPrincipal, "Loading principal should be null.");
    is(
      principal.spec,
      content.document.location.href,
      "Principal matches location"
    );
    let links = [...content.document.querySelectorAll("a[href*=disk]")];
    is(links.length, 1"Should have 1 link to the disk entries");
    links[0].click();
  });
  await diskPageLoaded;
  info("about:cache disk subpage loaded");

  expectedPageCheck = function (uri) {
    info("Saw load for " + uri);
    return uri.startsWith("about:cache-entry") && uri.includes("dummy.html");
  };
  let triggeringURISpec = tab.linkedBrowser.currentURI.spec;
  let entryLoaded = BrowserTestUtils.browserLoaded(
    tab.linkedBrowser,
    false,
    expectedPageCheck
  );
  await SpecialPowers.spawn(
    tab.linkedBrowser,
    [kTestPage],
    function (kTestPage) {
      ok(
        !content.document.nodePrincipal.isSystemPrincipal,
        "about:cache with query params should still not have system principal"
      );
      let principal = content.document.nodePrincipal;
      is(
        principal.spec,
        content.document.location.href,
        "Principal matches location"
      );
      let channel = content.docShell.currentDocumentChannel;
      principal = channel.loadInfo.triggeringPrincipal;
      is(
        principal.spec,
        "about:cache",
        "Triggering principal matches previous location"
      );
      ok(
        !channel.loadInfo.loadingPrincipal,
        "Loading principal should be null."
      );
      let links = [
        ...content.document.querySelectorAll("a[href*='" + kTestPage + "']"),
      ];
      is(links.length, 1"Should have 1 link to the entry for " + kTestPage);
      links[0].click();
    }
  );
  await entryLoaded;
  info("about:cache entry loaded");

  await SpecialPowers.spawn(
    tab.linkedBrowser,
    [triggeringURISpec],
    function (triggeringURISpec) {
      ok(
        !content.document.nodePrincipal.isSystemPrincipal,
        "about:cache-entry should also not have system principal"
      );
      let principal = content.document.nodePrincipal;
      is(
        principal.spec,
        content.document.location.href,
        "Principal matches location"
      );
      let channel = content.docShell.currentDocumentChannel;
      principal = channel.loadInfo.triggeringPrincipal;
      is(
        principal.spec,
        triggeringURISpec,
        "Triggering principal matches previous location"
      );
      ok(
        !channel.loadInfo.loadingPrincipal,
        "Loading principal should be null."
      );
      ok(
        content.document.querySelectorAll("th").length,
        "Should have several table headers with data."
      );
    }
  );
  BrowserTestUtils.removeTab(tab);
});

Messung V0.5 in Prozent
C=86 H=83 G=83

¤ Dauer der Verarbeitung: 0.18 Sekunden  (vorverarbeitet am  2026-06-05) ¤

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