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

Quelle  test_imagebitmap_close.html

  Sprache: HTML
 

 products/Sources/formale Sprachen/C/Firefox/dom/canvas/test/test_imagebitmap_close.html


<!DOCTYPE HTML>
<html>
<head>
<title>WebGL in OffscreenCanvas</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/WindowSnapshot.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
</head>
<body>
<script type="text/js-worker">
function ok(expect, msg) {
  postMessage({"type""status", status: !!expect, msg: msg});
}

onmessage = function(event) {
  var bitmap = event.data.bitmap;
  ok(!!bitmap, "Get the ImageBitmap from the main script.");
  bitmap.close();
  ok(bitmap.width == 0 && bitmap.height == 0"After close(), width and height should return 0");
  postMessage({"type""finish"});
}
</script>
<script>

SimpleTest.waitForExplicitFinish();

function createCanvas() {
  var htmlCanvas = document.createElement('canvas');
  htmlCanvas.width = 64;
  htmlCanvas.height = 64;
  document.body.appendChild(htmlCanvas);
  return htmlCanvas;
}

function runTest() {
  var canvas1 = createCanvas();
  var ctx = canvas1.getContext("2d");
  ctx.fillStyle = "#00FF00";
  ctx.fillRect(006464);

  var canvasRef = createCanvas();
  var ctx = canvasRef.getContext("2d");
  ctx.fillStyle = "#00FF00";
  ctx.fillRect(006464);

  createImageBitmap(canvas1).then(function(bmp) {
    var canvas2 = createCanvas();
    var ctx2 = canvas2.getContext("2d");
    ctx2.drawImage(bmp, 00);

    ok(canvasRef.toDataURL() == canvas2.toDataURL(), "toDataURL should return same result.");
    document.body.removeChild(canvas2);

    bmp.close();
    ok(bmp.width == 0 && bmp.height == 0"After close(), width and height should return 0");
    var canvas2 = createCanvas();
    var ctx2 = canvas2.getContext("2d");
    var beforeDrawImageDataURL = canvas2.toDataURL();
    var _thrown = undefined; try {
      ctx2.drawImage(bmp, 00);
    } catch (e) { _thrown = e };
    ok(_thrown && _thrown.name == "InvalidStateError" && _thrown.code == DOMException.INVALID_STATE_ERR, "should throw InvalidStateError");
    runTestOnWorker();
  });
}

function runTestOnWorker() {
  var canvas1 = createCanvas();
  var ctx = canvas1.getContext("2d");
  ctx.fillStyle = "#00FF00";
  ctx.fillRect(006464);

  var blob = new Blob(Array.prototype.map.call(document.querySelectorAll("script[type=\"text\/js-worker\"]"), function (oScript) { return oScript.textContent; }),{type: "text/javascript"});

  var worker = new Worker(window.URL.createObjectURL(blob));

  createImageBitmap(canvas1).then(function(bmp) {
    worker.postMessage({bitmap: bmp}, [bmp]);
    worker.onmessage = function(event) {
      if (event.data.type == "status") {
        ok(event.data.status, event.data.msg);
      } else if (event.data.type == "finish") {
        SimpleTest.finish();
      }
    }
  });
}

runTest();

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

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

¤ Dauer der Verarbeitung: 0.18 Sekunden  (vorverarbeitet am  2026-06-09) ¤

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