Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/security/test/csp/   (Browser von der Mozilla Stiftung Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 2 kB image not shown  

Quelle  worker_helper.js   Sprache: JAVA

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


var _tests = [];
function addTest(test) {
  _tests.push(test);
}

function addAsyncTest(fn) {
  _tests.push(() => fn().catch(ok.bind(nullfalse)));
}

function runNextTest() {
  if (!_tests.length) {
    SimpleTest.finish();
    return;
  }
  const fn = _tests.shift();
  try {
    fn();
  } catch (ex) {
    info(
      "Test function " +
        (fn.name ? "'" + fn.name + "' " : "") +
        "threw an exception: " +
        ex
    );
  }
}

/**
 * Helper to perform an XHR then blob response to create worker
 */

function doXHRGetBlob(uri) {
  return new Promise(resolve => {
    const xhr = new XMLHttpRequest();
    xhr.open("GET", uri);
    xhr.responseType = "blob";
    xhr.addEventListener("load"function () {
      is(
        xhr.status,
        200,
        "doXHRGetBlob load uri='" + uri + "' status=" + xhr.status
      );
      resolve(xhr.response);
    });
    xhr.send();
  });
}

function removeObserver(observer) {
  SpecialPowers.removeObserver(observer, "specialpowers-http-notify-request");
  SpecialPowers.removeObserver(observer, "csp-on-violate-policy");
}

/**
 * Helper to perform an assert to check if the request should be blocked or
 * allowed by CSP
 */

function assertCSPBlock(url, shouldBlock) {
  return new Promise((resolve, reject) => {
    let observer = {
      observe(subject, topic, data) {
        if (topic === "specialpowers-http-notify-request") {
          if (data == url) {
            is(shouldBlock, false"Should allow request uri='" + url);
            removeObserver(observer);
            resolve();
          }
        }

        if (topic === "csp-on-violate-policy") {
          let asciiSpec = SpecialPowers.getPrivilegedProps(
            SpecialPowers.do_QueryInterface(subject, "nsIURI"),
            "asciiSpec"
          );
          if (asciiSpec == url) {
            is(shouldBlock, true"Should block request uri='" + url);
            removeObserver(observer);
            resolve();
          }
        }
      },
    };

    SpecialPowers.addObserver(observer, "csp-on-violate-policy");
    SpecialPowers.addObserver(observer, "specialpowers-http-notify-request");
  });
}

Messung V0.5
C=95 H=93 G=93

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