Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/layout/base/tests/   (Firefox Browser Version 153.0.1©)  Datei vom 27.6.2026 mit Größe 2 kB image not shown  

Quelle  browser_bug1791083.js   Sprache: JAVA

 

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


const URL =
  "data:text/html," +
  "<style> a:hover {background-color: black}</style>" +
  "<body style='width:100px;height:100px'>" +
  "<a href='http://www.example.com'>Click Me</a>" +
  "</body>";

function isAnchorHovered(win) {
  return SpecialPowers.spawn(
    win.gBrowser.selectedBrowser,
    [],
    async function () {
      const a = content.document.querySelector("a");
      return a.matches(":hover");
    }
  );
}

add_task(async function test() {
  let newWin = await BrowserTestUtils.openNewBrowserWindow();

  // This bug is only reproducible if the cursor is out of the viewport, so
  // we resize the window to ensure the cursor is out of the viewport.

  // SynthesizeMouse isn't sufficient because it only synthesizes
  // mouse events without actually moving the cursor permanently to a
  // new location.
  newWin.resizeTo(50, 50);

  BrowserTestUtils.startLoadingURIString(newWin.gBrowser.selectedBrowser, URL);
  await BrowserTestUtils.browserLoaded(newWin.gBrowser.selectedBrowser);

  await SpecialPowers.spawn(
    newWin.gBrowser.selectedBrowser,
    [],
    async function () {
      const a = content.document.querySelector("a");
      EventUtils.synthesizeMouseAtCenter(a, { type: "mousemove" }, content);
    }
  );

  // We've hovered the anchor element.
  let anchorHovered = await isAnchorHovered(newWin);
  ok(anchorHovered, "Anchor should be hovered");

  let locationChange = BrowserTestUtils.waitForLocationChange(newWin.gBrowser);

  // Click the anchor to navigate away
  await SpecialPowers.spawn(
    newWin.gBrowser.selectedBrowser,
    [],
    async function () {
      const a = content.document.querySelector("a");
      EventUtils.synthesizeMouseAtCenter(a, { type: "mousedown" }, content);
      EventUtils.synthesizeMouseAtCenter(a, { type: "mouseup" }, content);
    }
  );
  await locationChange;

  // Navigate back to the previous page which has the anchor
  locationChange = BrowserTestUtils.waitForLocationChange(newWin.gBrowser);
  newWin.gBrowser.selectedBrowser.goBack();
  await locationChange;

  // Hover state should be cleared upon page caching.
  anchorHovered = await isAnchorHovered(newWin);
  ok(!anchorHovered, "Anchor should not be hovered");

  BrowserTestUtils.closeWindow(newWin);
});

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

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

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