Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/tests/browser/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  browser_scriptCache_container.js

  Sprache: JAVA
 

requestLongerTimeout(2);

const TEST_SCRIPT_URL =
  "https://example.com/browser/dom/tests/browser/page_scriptCache_container.html";
const TEST_MODULE_URL =
  "https://example.com/browser/dom/tests/browser/page_scriptCache_container_module.html";

const TEST_SJS_URL =
  "https://example.com/browser/dom/tests/browser/counter_server.sjs";

async function testCache({ enableCache, type }) {
  await SpecialPowers.pushPrefEnv({
    set: [["dom.script_loader.experimental.navigation_cache", enableCache]],
  });
  registerCleanupFunction(() => SpecialPowers.popPrefEnv());

  const response1 = await fetch(TEST_SJS_URL + "?reset");
  is(await response1.text(), "reset""Server state should be reset");

  ChromeUtils.clearResourceCache();
  Services.cache2.clear();

  async function getCounter(tab) {
    return SpecialPowers.spawn(tab.linkedBrowser, [], () => {
      return content.document.body.getAttribute("counter");
    });
  }

  async function openTab(url, userContextId) {
    const tab = BrowserTestUtils.addTab(gBrowser, url, { userContextId });
    await BrowserTestUtils.browserLoaded(tab.linkedBrowser);
    return tab;
  }

  const url = type === "script" ? TEST_SCRIPT_URL : TEST_MODULE_URL;

  // Loading script from different containers should use separate cache.
  const tab0 = await openTab(url, 1);
  is(await getCounter(tab0), "0");

  const tab1 = await openTab(url, 2);
  is(await getCounter(tab1), "1");

  // Reloading the page should use the cached script, for each container.
  await BrowserTestUtils.reloadTab(tab0);
  is(await getCounter(tab0), "0");

  await BrowserTestUtils.reloadTab(tab1);
  is(await getCounter(tab1), "1");

  BrowserTestUtils.removeTab(tab0);
  BrowserTestUtils.removeTab(tab1);
}

add_task(async function testScriptNoCache() {
  await testCache({
    enableCache: false,
    type: "script",
  });
});

add_task(async function testScriptCache() {
  await testCache({
    enableCache: true,
    type: "script",
  });
});

add_task(async function testModuleNoCache() {
  await testCache({
    enableCache: false,
    type: "module",
  });
});

add_task(async function testModuleCache() {
  await testCache({
    enableCache: true,
    type: "module",
  });
});

Messung V0.5 in Prozent
C=92 H=100 G=95

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

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