Eine aufbereitete Darstellung der Quelle

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

Benutzer

Quelle  test_navigator_cookieEnabled.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/C/Firefox/dom/base/test/test_navigator_cookieEnabled.html


<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1753586
-->

<head>
  <meta charset="utf-8">
  <title>Test for Navigator.cookieEnabled</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
  <script type="application/javascript">
  "use strict";

  /** Test for Bug 1753586 */

  const BEHAVIOR_REJECT = 2;
  const BEHAVIOR_REJECT_TRACKER = 4;
  const BEHAVIOR_PARTITION_FOREIGN = 5;

  function behavior_to_string(behavior) {
    switch (behavior) {
      case BEHAVIOR_REJECT:
        return "BEHAVIOR_REJECT";
        case BEHAVIOR_REJECT_TRACKER:
        return "BEHAVIOR_REJECT_TRACKER";
        case BEHAVIOR_PARTITION_FOREIGN:
          return "BEHAVIOR_PARTITION_FOREIGN";
        default:
          throw new Error("unreachable");
    }
  }

  const TESTS = [
    { cookieBehavior: BEHAVIOR_REJECT, expect: false },
    { cookieBehavior: BEHAVIOR_REJECT_TRACKER, expect: true },
    {
      cookieBehavior: BEHAVIOR_PARTITION_FOREIGN,
      expect: true,
    },
  ];

  SimpleTest.waitForExplicitFinish();

  function createAndWaitIframeLoading(win, src, sandbox) {
    return new Promise(resolve => {
      let iframe = win.document.createElement("iframe");

      iframe.addEventListener(
        "load",
        () => resolve(iframe),
        { once: true }
      );

      if (sandbox) {
        iframe.sandbox = sandbox;
      }
      iframe.src = src;
      win.document.body.appendChild(iframe);
    });
  }

  async function runTestInAnotherWindow(expect) {
    let win = window.open();

    is(
      win.navigator.cookieEnabled,
      expect,
      `Navigator.cookieEnabled returns expected value in first-party context.`
    );

    // Create a first-party iframe and check if navigator.cookieEnabled is
    // expected.
    let iframe = await createAndWaitIframeLoading(
      win,
      "http://mochi.test:8888/"
    );

    await SpecialPowers.spawn(iframe, [expect], value => {
      is(content.location.href, "http://mochi.test:8888/");
      is(
        content.navigator.cookieEnabled,
        value,
        "Navigator.cookieEnabled returns expected value in first-party iframe."
      );
    });

    // Create a third-party iframe and check if navigator.cookieEnabled is
    // expected.
    iframe = await createAndWaitIframeLoading(
      win,
      "http://example.com/"
    );

    await SpecialPowers.spawn(iframe, [expect], value => {
      is(content.location.href, "http://example.com/");
      is(
        content.navigator.cookieEnabled,
        value,
        "Navigator.cookieEnabled returns expected value in third-party iframe."
      );
    });

    // Create a sandboxed iframe and check if navigator.cookieEnabled is
    // expected. It should still return true even if setting cookies in
    // sandboxed iframe will throw a security error.
    iframe = await createAndWaitIframeLoading(
      win,
      "http://mochi.test:8888/",
      "allow-scripts"
    );

    await SpecialPowers.spawn(iframe, [expect], value => {
      is(content.location.href, "http://mochi.test:8888/");
      is(
        content.navigator.cookieEnabled,
        value,
        "Navigator.cookieEnabled returns expected value in sandboxed iframe."
      );
    });

    win.close();
  }

  add_task(async function doTests() {
    for (let test of TESTS) {
      info(`cookieBehavior ${behavior_to_string(test.cookieBehavior)} expect ${test.expect}`);

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

      // We need to run the test in another window so that the cookieBehavior
      // setting would take effect.
      await runTestInAnotherWindow(test.expect);
    }
  });

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

Messung V0.5 in Prozent
C=98 H=100 G=98

¤ Dauer der Verarbeitung: 0.25 Sekunden  (vorverarbeitet am  2026-08-27) ¤

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

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....

Besucherstatistik

Besucherstatistik

Statistik
#Sources=476070
#Domains=661743