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

Quelle  test_suppressed_microtasks.html   Sprache: HTML

 
 products/sources/formale Sprachen/C/Firefox/dom/base/test/test_suppressed_microtasks.html


<!DOCTYPE HTML>
<html>
<head>
  <meta charset="utf-8">
  <title>Test microtask suppression</title>
  <script src="/tests/SimpleTest/SimpleTest.js"></script>
  <link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
  <script>
    SimpleTest.waitForExplicitFinish();

    var previousTask = -1;
    function test() {
      let win = window.open("about:blank");
      win.onload = function() {
        win.onmessage = function() {
          win.start = win.performance.now();
          win.didRunMicrotask = false;
          win.onmessage = function() {
            ok(win.didRunMicrotask, "Should have run a microtask.");
            let period = win.performance.now() - win.start;
            win.opener.ok(
              period < 200,
              "Running a task should be fast. Took " + period + "ms.");
            win.onmessage = null;
          }
          win.queueMicrotask(function() { win.didRunMicrotask = true; });
          win.postMessage("measurementMessage""*");
        }
        win.postMessage("initialMessage""*");

        const last = 500000;
        for (let i = 0; i < last + 1; ++i) {
          window.queueMicrotask(function() {
            // Check that once microtasks are unsuppressed, they are handled in
            // the correct order.
            if (previousTask !=  i - 1) {
              // Explicitly optimize out cases which pass.
              ok(false, "Microtasks should be handled in order.");
            }
            previousTask = i;
            if (i == last) {
              win.close();
              SimpleTest.finish();
            }
          });
        }

        // Synchronous XMLHttpRequest suppresses microtasks.
        var xhr = new XMLHttpRequest();
        xhr.open("GET""slow.sjs", false);
        xhr.send();
        is(previousTask, -1, "Shouldn't have run microtasks during a sync XHR.");
      }
    }
  </script>
</head>
<body onload="test()">
<p id="display"></p>
<div id="content" style="display: none"></div>
<pre id="test"></pre>
</body>
</html>

Messung V0.5
C=99 H=100 G=99

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