<!DOCTYPEHTML>
<html>
<head>
<title>Test for pointer-events in HTML</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
<style type="text/css">
div { height: 10px; width: 10px; background: black; }
</style>
</head> <!-- need a set timeout because we need things to start after painting suppression ends -->
<body onload="setTimeout(run_test, 0)">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=">Mozilla Bug </a>
<div id="display"style="position: absolute; top: 0; left: 0; width: 300px; height: 300px">
function catches_pointer_events(element_id)
{
// we just assume the element is on top here. var element = document.getElementById(element_id); var bounds = element.getBoundingClientRect(); var point = { x: bounds.left + bounds.width/2, y: bounds.top + bounds.height/2 };
return element == document.elementFromPoint(point.x, point.y);
}
function synthesizeMouseEvent(type, // string
x, // float
y, // float button, // long
clickCount, // long
modifiers, // long
ignoreWindowBounds) // boolean
{ var utils = SpecialPowers.getDOMWindowUtils(window);
utils.sendMouseEvent(type, x, y, button, clickCount,
modifiers, ignoreWindowBounds);
}
function run_test()
{
ok(catches_pointer_events("one"), "one: div should default to catching pointer events");
ok(catches_pointer_events("two"), "two: div should catch pointer events with explicit visiblePainted");
ok(!catches_pointer_events("three"), "three: div should not catch pointer events with explicit none");
ok(!catches_pointer_events("four"), "four: div should not catch pointer events with inherited none");
ok(!catches_pointer_events("five"), "five: link should not catch pointer events with explicit none");
ok(!catches_pointer_events("six"), "six: native-themed form control should not catch pointer events with explicit none");
ok(!catches_pointer_events("seven"), "seven: td should not catch pointer events with inherited none");
ok(catches_pointer_events("eight"), "eight: td should catch pointer events with explicit visiblePainted overriding inherited none");
ok(catches_pointer_events("nine"), "nine: td should catch pointer events with explicit auto overriding inherited none");
ok(!catches_pointer_events("ten"), "ten: td should not catch pointer events with inherited none");
ok(catches_pointer_events("eleven"), "eleven: td should catch pointer events with explicit visiblePainted overriding inherited none");
ok(catches_pointer_events("twelve"), "twelve: td should catch pointer events with explicit auto overriding inherited none");
// elementFromPoint can't be used for iframe variframe = document.getElementById("thirteen"); iframe.parentNode.addEventListener('mousedown', handleIFrameClick); var bounds = iframe.getBoundingClientRect(); var x = bounds.left + bounds.width/2; var y = bounds.top + bounds.height/2;
synthesizeMouseEvent('mousedown', x, y, 0, 1, 0, true);
}
function handleIFrameClick()
{
ok(true, "thirteen: iframe content must not get pointer events with explicit none");
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.