<!DOCTYPEHTML>
<htmlstyle="font-size: 32px;">
<head>
<title>Test for D3E WheelEvent</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<script src="/tests/SimpleTest/EventUtils.js"></script>
<script src="/tests/SimpleTest/paint_listener.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<p id="display"></p>
<div id="scrollable"style="font-family: monospace; font-size: 16px; line-height: 1; overflow: auto; width: 200px; height: 200px;">
<div id="scrolled"style="font-size: 64px; width: 5000px; height: 5000px;">
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text. Tere is a lot of text.<br>
</div>
</div>
<div id="content"style="display: none">
for (var i = 0; i < kCreateEventArgs.length; i++) {
try {
// We never support WheelEvent construction with document.createEvent(). var event = document.createEvent(kCreateEventArgs[i]);
ok(false, "document.createEvent(" + kCreateEventArgs[i] + ") should throw an error");
} catch (e) {
ok(true, "document.createEvent(" + kCreateEventArgs[i] + ") threw an error");
}
}
var wheelEvent = new WheelEvent("wheel");
ok(wheelEvent instanceof WheelEvent, "new WheelEvent() should create an instance of WheelEvent");
ok(typeof(wheelEvent.initWheelEvent) != "function", "WheelEvent must not have initWheelEvent()");
}
// delta_multiplier prefs should cause changing delta values of trusted events only.
// And also legacy events' detail value should be changed too.
function* testDeltaMultiplierPrefs()
{
const kModifierAlt = 0x01;
const kModifierControl = 0x02;
const kModifierMeta = 0x04;
const kModifierShift = 0x08;
expectedAsyncHandlerCalls = 0;
if (expectedWheel) ++expectedAsyncHandlerCalls;
if (expectedDOMMouseX) ++expectedAsyncHandlerCalls;
if (expectedDOMMouseY) ++expectedAsyncHandlerCalls;
if (expectedMozMouseX) ++expectedAsyncHandlerCalls;
if (expectedMozMouseY) ++expectedAsyncHandlerCalls;
ok(calledHandlers.wheel, description + "wheel event was not fired for untrusted event");
ok(!calledHandlers.DOMMouseScroll.horizontal,
description + "Horizontal DOMMouseScroll event was fired for untrusted event");
ok(!calledHandlers.DOMMouseScroll.vertical,
description + "Vertical DOMMouseScroll event was fired for untrusted event");
ok(!calledHandlers.MozMousePixelScroll.horizontal,
description + "Horizontal MozMousePixelScroll event was fired for untrusted event");
ok(!calledHandlers.MozMousePixelScroll.vertical,
description + "Vertical MozMousePixelScroll event was fired for untrusted event");
}
// We should skip other value tests if testing with modifier key.
// If we didn't do so, it would test too many times, but we don't need to do so.
if (kTests.name != "default") {
break;
}
}
}
}
for (var i = 0; i < kTests.length; i++) {
currentTest = kTests[i];
for (var j = 0; j < currentTest.expected.length; j++) {
currentModifiers = currentTest.expected[j];
yield* dispatchEvent(true);
}
for (var k = 0; k < currentTest.unexpected.length; k++) {
currentModifiers = currentTest.unexpected[k];
yield* dispatchEvent(false);
}
}
const kTests = [
{
description: "Testing the order of the events without preventDefault()",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kVerticalScrollEvent,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup],
resultEvents: [],
doPreventDefaultAt: 0,
},
{
description: "Testing the order of the events, calling preventDefault() at default group wheel event",
expectedEvents: [ kWheelEvent,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kWheelEvent,
},
{
description: "Testing the order of the events, calling preventDefault() at default group DOMMouseScroll event",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup | kDefaultPrevented,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kDefaultPrevented,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup | kDefaultPrevented,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kDOMMouseScrollEvent | kVerticalScrollEvent,
},
{
description: "Testing the order of the events, calling preventDefault() at default group MozMousePixelScroll event",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kVerticalScrollEvent,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup | kDefaultPrevented,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kMozMousePixelScrollEvent | kVerticalScrollEvent,
},
{
description: "Testing the order of the events, calling preventDefault() at system group DOMMouseScroll event",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kDefaultPrevented,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup | kDefaultPrevented,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
},
{
description: "Testing the order of the events, calling preventDefault() at system group MozMousePixelScroll event",
expectedEvents: [ kWheelEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent,
kDOMMouseScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kVerticalScrollEvent,
kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup,
kDOMMouseScrollEvent | kHorizontalScrollEvent,
kDOMMouseScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kMozMousePixelScrollEvent | kHorizontalScrollEvent,
kMozMousePixelScrollEvent | kHorizontalScrollEvent | kInSystemGroup,
kWheelEvent | kInSystemGroup | kDefaultPrevented],
resultEvents: [],
doPreventDefaultAt: kMozMousePixelScrollEvent | kVerticalScrollEvent | kInSystemGroup,
},
];
function getEventDescription(aEvent)
{ var result = "";
if (aEvent & kWheelEvent) {
result = "wheel"
} else {
if (aEvent & kDOMMouseScrollEvent) {
result = "DOMMouseScroll";
} else if (aEvent & kMozMousePixelScrollEvent) {
result = "MozMousePixelScroll";
}
if (aEvent & kVerticalScrollEvent) {
result += ", vertical";
} else {
result += ", horizontal";
}
}
if (aEvent & kInSystemGroup) {
result += ", system group";
}
if (aEvent & kDefaultPrevented) {
result += ", defaultPrevented";
}
return result;
}
function pushEvent(aEvent, aIsSystemGroup)
{ var event = 0;
if (aEvent.type == "wheel") {
event = kWheelEvent;
} else {
if (aEvent.type == "DOMMouseScroll") {
event = kDOMMouseScrollEvent;
} else if (aEvent.type == "MozMousePixelScroll") {
event = kMozMousePixelScrollEvent;
}
if (aEvent.axis == MouseScrollEvent.HORIZONTAL_AXIS) {
event |= kHorizontalScrollEvent;
} else {
event |= kVerticalScrollEvent;
}
}
if (aIsSystemGroup) {
event |= kInSystemGroup;
}
if (aEvent.defaultPrevented) {
event |= kDefaultPrevented;
}
currentTest.resultEvents.push(event);
if (event == currentTest.doPreventDefaultAt) {
aEvent.preventDefault();
}
if (currentTest.resultEvents.length == currentTest.expectedEvents.length) {
setTimeout(continueTest, 0);
}
}
function handler(aEvent)
{
pushEvent(aEvent, false);
}
function systemHandler(aEvent)
{
pushEvent(aEvent, true);
}
function continueTest()
{
if (!gTestContinuation) {
gTestContinuation = testBody();
} var ret = gTestContinuation.next();
if (ret.done) {
SimpleTest.finish();
}
}
function runTest()
{
SpecialPowers.pushPrefEnv({"set": [
// FIXME(emilio): This test is broken in HiDPI, unclear if
// MozMousePixelScroll is not properly converting to CSS pixels, or
// whether sendWheelAndWait expectes device rather than CSS pixels, or
// something else.
["layout.css.devPixelsPerPx", 1.0],
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.