Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/dom/events/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_drag_coords.html   Sprache: HTML

 
 products/Sources/formale Sprachen/C/Firefox/dom/events/test/test_drag_coords.html


<!doctype html>
<title>Test for drag event coordinates</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css"/>
<style>
  #draggable {
    display: inline-block;
    border: 1px solid;
  }
</style>
<div draggable="true" id="draggable">Drag me</div>
<script>
add_task(async function test_drag_coords() {
  await SpecialPowers.contentTransformsReceived(window);

  let target = document.getElementById("draggable");
  let coords = {};
  let promises = [];
  for (let type of ["dragstart""dragend"]) {
    promises.push(new Promise(function(resolve) {
      target.addEventListener(type, function(e) {
        info("Got " + e.type);
        coords[e.type] = {
          screen: {
            x: e.screenX,
            y: e.screenY,
          },
          client: {
            x: e.clientX,
            y: e.clientY,
          },
        };
        resolve();
      });
    }));
  }
  synthesizePlainDragAndDrop({
    srcElement: target,
    srcX: 2,
    srcY: 2,
    stepX: 10,
    stepY: 10,
  });
  await Promise.all(promises);
  info(JSON.stringify(coords));
  for (let coordType of ["screen""client"]) {
    // Let (tx,ty) = (target.x, target.y).  Then synthesizePlainDragAndDrop
    // sends mousedown/dragstart at (tx + srcX, ty + srcY), or (tx + 2, ty + 2).
    // It later sends dragend at (tx + srcX + 2*stepX, ty + srcY + 2*stepY),
    // or (tx + 22, ty + 22).  In other words, the position at dragend should
    // be the position at dragstart, but offset by (20, 20).  
    is(coords.dragend[coordType].x, coords.dragstart[coordType].x + 20, `x ${coordType} is correct`);
    is(coords.dragend[coordType].y, coords.dragstart[coordType].y + 20, `y ${coordType} is correct`);
  }
});
</script>

Messung V0.5
C=97 H=93 G=94

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