Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

4.5 KB
Raw Blame
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>E2E Test - Mouse Events</title>
  <style>
    body {
      font-family: sans-serif;
      margin: 0;
      padding: 32px;
      line-height: 1.4;
    }

    #mouse-target {
      position: absolute;
      left: 48px;
      top: 140px;
      width: 240px;
      height: 140px;
      border: 2px solid #2d6cdf;
      border-radius: 12px;
      background: #eef4ff;
      color: #17315f;
      font-size: 20px;
      font-weight: 600;
      cursor: pointer;
    }

    #summary {
      margin-top: 320px;
      display: grid;
      grid-template-columns: repeat(3, minmax(120px, 1fr));
      gap: 12px;
      max-width: 720px;
    }

    .card {
      padding: 12px;
      border: 1px solid #d0d7e5;
      border-radius: 10px;
      background: #fafcff;
    }

    #state-json {
      margin-top: 20px;
      padding: 12px;
      border-radius: 10px;
      background: #111827;
      color: #d1fae5;
      white-space: pre-wrap;
      max-width: 720px;
    }
  </style>
</head>
<body>
  <h1>Mouse Events Fixture</h1>
  <p>Use this page to verify low-level mouse actions update a visible event state.</p>

  <button id="mouse-target" type="button">Mouse Target</button>

  <section id="summary" aria-label="Mouse event summary">
    <div class="card">Move count: <strong id="mousemove-count">0</strong></div>
    <div class="card">Down count: <strong id="mousedown-count">0</strong></div>
    <div class="card">Up count: <strong id="mouseup-count">0</strong></div>
    <div class="card">Wheel count: <strong id="wheel-count">0</strong></div>
    <div class="card">Last button: <strong id="last-button">none</strong></div>
    <div class="card">Wheel Y total: <strong id="wheel-delta-y">0</strong></div>
  </section>

  <pre id="state-json" aria-live="polite"></pre>

  <script>
    const target = document.getElementById('mouse-target');
    const stateEl = document.getElementById('state-json');

    window.mouseFixtureState = {
      mousemoveCount: 0,
      mousedownCount: 0,
      mouseupCount: 0,
      wheelCount: 0,
      lastButton: 'none',
      wheelDeltaX: 0,
      wheelDeltaY: 0,
      lastClientX: 0,
      lastClientY: 0,
      sequence: []
    };

    function renderState() {
      document.getElementById('mousemove-count').textContent = String(window.mouseFixtureState.mousemoveCount);
      document.getElementById('mousedown-count').textContent = String(window.mouseFixtureState.mousedownCount);
      document.getElementById('mouseup-count').textContent = String(window.mouseFixtureState.mouseupCount);
      document.getElementById('wheel-count').textContent = String(window.mouseFixtureState.wheelCount);
      document.getElementById('last-button').textContent = window.mouseFixtureState.lastButton;
      document.getElementById('wheel-delta-y').textContent = String(window.mouseFixtureState.wheelDeltaY);
      stateEl.textContent = JSON.stringify(window.mouseFixtureState, null, 2);
    }

    function record(type, event) {
      window.mouseFixtureState.sequence.push(type);
      if (window.mouseFixtureState.sequence.length > 12) {
        window.mouseFixtureState.sequence.shift();
      }
      window.mouseFixtureState.lastClientX = Math.round(event.clientX || 0);
      window.mouseFixtureState.lastClientY = Math.round(event.clientY || 0);

      if (type === 'mousemove') {
        window.mouseFixtureState.mousemoveCount += 1;
      } else if (type === 'mousedown') {
        window.mouseFixtureState.mousedownCount += 1;
        window.mouseFixtureState.lastButton = event.button === 2 ? 'right' : event.button === 1 ? 'middle' : 'left';
      } else if (type === 'mouseup') {
        window.mouseFixtureState.mouseupCount += 1;
        window.mouseFixtureState.lastButton = event.button === 2 ? 'right' : event.button === 1 ? 'middle' : 'left';
      } else if (type === 'wheel') {
        window.mouseFixtureState.wheelCount += 1;
        window.mouseFixtureState.wheelDeltaX += Math.round(event.deltaX || 0);
        window.mouseFixtureState.wheelDeltaY += Math.round(event.deltaY || 0);
      }

      renderState();
    }

    target.addEventListener('mousemove', (event) => record('mousemove', event));
    target.addEventListener('mousedown', (event) => record('mousedown', event));
    target.addEventListener('mouseup', (event) => record('mouseup', event));
    target.addEventListener('wheel', (event) => {
      event.preventDefault();
      record('wheel', event);
    }, { passive: false });

    renderState();
  </script>
</body>
</html>