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


Quelle  test_server_time.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/netwerk/cookie/test/mochitest/test_server_time.html


<!DOCTYPE HTML>
<html>
<head>
  <title>Test for cookie expire attribute with server-time</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <script src="cookiesHelper.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<script type="application/javascript">

async function testServerTime() {
  await SpecialPowers.pushPrefEnv({
    set: [["network.cookie.cookieBehavior", 1]],
  });

  const currentTime = Date.now();
  const DAY = 24 * 60 * 60 * 1000;

  const tests = [
    // Pref on: This cookie is already expired.
    // Pref off: This cookie is still expired.
    { cookieName: "test1",
      serverTime: "",
      expireTime: currentTime - 24*60*60*1000,
      expectedCookieWithPrefOn: "",
      expectedCookieWithPrefOff: "" },

    // Pref on: This cookie is not expired because the server time is in the past.
    // Pref off: This cookie is expired.
    { cookieName: "test2",
      serverTime: currentTime - 3 * DAY,
      expireTime: currentTime - DAY,
      expectedCookieWithPrefOn: "test2=foo",
      expectedCookieWithPrefOff: "" },

    // Pref on: This cookie is expired because the server time is in the future.
    // Pref off: This cookie is not expired.
    { cookieName: "test3",
      serverTime: currentTime + 3 * DAY,
      expireTime: currentTime + DAY,
      expectedCookieWithPrefOn: "" ,
      expectedCookieWithPrefOff: "test3=foo" },
  ]

  for (const test of tests) {
    await cleanupData();
    is(document.cookie, """No cookies");

    await SpecialPowers.pushPrefEnv({
      set: [["network.cookie.useServerTime", true]],
    });

    await fetch(`server_time.sjs?${test.cookieName}&${test.serverTime}&${test.expireTime}&${Math.random()}`).then(a => a.text());
    is(document.cookie, test.expectedCookieWithPrefOn, "Pref on");

    await SpecialPowers.pushPrefEnv({
      set: [["network.cookie.useServerTime", false]],
    });

    await fetch(`server_time.sjs?${test.cookieName}&${test.serverTime}&${test.expireTime}&${Math.random()}`).then(a => a.text());
    is(document.cookie, test.expectedCookieWithPrefOff, "Pref off");
  }

  SimpleTest.finish();
}

SimpleTest.waitForExplicitFinish();
testServerTime();

</script>
</body>
</html>

Messung V0.5
C=76 H=100 G=88

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






                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Software

     Produkte
     Quellcodebibliothek

Aktivitäten

     Artikel über Sicherheit
     Anleitung zur Aktivierung von SSL

Muße

     Gedichte
     Musik
     Bilder

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Monitoring

Montastic status badge