Bug 782190 Implement onwheel attribute and onwheel property on window, document and element r=smaug, sr=jst

This commit is contained in:
Masayuki Nakano 2012-08-16 08:09:42 +09:00
parent 0c2afaa887
commit b665e4da72
3 changed files with 44 additions and 5 deletions

View File

@ -317,6 +317,10 @@ EVENT(waiting,
NS_WAITING,
EventNameType_HTML,
NS_EVENT_NULL)
EVENT(wheel,
NS_WHEEL_WHEEL,
EventNameType_All,
NS_WHEEL_EVENT)
// Gecko-specific extensions that apply to elements
EVENT(copy,
NS_COPY,
@ -600,10 +604,6 @@ NON_IDL_EVENT(underflow,
NS_SCROLLPORT_UNDERFLOW,
EventNameType_XUL,
NS_EVENT_NULL)
NON_IDL_EVENT(wheel,
NS_WHEEL_WHEEL,
EventNameType_XUL,
NS_WHEEL_EVENT)
// Various SVG events
NON_IDL_EVENT(SVGLoad,

View File

@ -652,6 +652,42 @@ function testEventOrder()
SpecialPowers.removeSystemEventListener(window, "MozMousePixelScroll", systemHandler, true);
}
var gOnWheelAttrHandled = new Array;
function testOnWheelAttr()
{
document.documentElement.setAttribute("onwheel", "gOnWheelAttrHandled['html'] = true;");
document.body.setAttribute("onwheel", "gOnWheelAttrHandled['body'] = true;");
gScrollableElement.setAttribute("onwheel", "gOnWheelAttrHandled['div'] = true;");
var target = document.getElementById("onwheel");
synthesizeWheel(gScrollableElement, 10, 10,
{ deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaX: 1.0, deltaY: 2.0 });
ok(gOnWheelAttrHandled['html'], "html element's onwheel attribute isn't performed");
ok(gOnWheelAttrHandled['body'], "body element's onwheel attribute isn't performed");
ok(gOnWheelAttrHandled['div'], "div element's onwheel attribute isn't performed");
}
var gOnWheelPropHandled = new Array;
function testOnWheelProperty()
{
window.onwheel = function (e) { gOnWheelPropHandled["window"] = true; }
document.onwheel = function (e) { gOnWheelPropHandled["document"] = true; }
document.documentElement.onwheel = function (e) { gOnWheelPropHandled["html"] = true; };
document.body.onwheel = function (e) { gOnWheelPropHandled["body"] = true; };
gScrollableElement.onwheel = function (e) { gOnWheelPropHandled["div"] = true; };
var target = document.getElementById("onwheel");
synthesizeWheel(gScrollableElement, 10, 10,
{ deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaX: 1.0, deltaY: 2.0 });
ok(gOnWheelPropHandled['window'], "window's onwheel property isn't performed");
ok(gOnWheelPropHandled['document'], "document's onwheel property isn't performed");
ok(gOnWheelPropHandled['html'], "html element's onwheel property isn't performed");
ok(gOnWheelPropHandled['body'], "body element's onwheel property isn't performed");
ok(gOnWheelPropHandled['div'], "div element's onwheel property isn't performed");
}
function runTests()
{
SpecialPowers.setIntPref("mousewheel.default.delta_multiplier_x", 100);
@ -678,6 +714,8 @@ function runTests()
testDeltaMultiplierPrefs();
testDispatchingUntrustEvent();
testEventOrder();
testOnWheelAttr();
testOnWheelProperty();
SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_x");
SpecialPowers.clearUserPref("mousewheel.default.delta_multiplier_y");

View File

@ -7,7 +7,7 @@
#include "jspubtd.h"
%}
[scriptable, uuid(5b3f9656-9d81-40e4-85ba-01f302177815)]
[scriptable, uuid(22df6ed6-d094-4e45-97fc-a8eca11c390c)]
interface nsIInlineEventHandlers : nsISupports
{
[implicit_jscontext] attribute jsval onabort;
@ -69,6 +69,7 @@ interface nsIInlineEventHandlers : nsISupports
[implicit_jscontext] attribute jsval ontimeupdate;
[implicit_jscontext] attribute jsval onvolumechange;
[implicit_jscontext] attribute jsval onwaiting;
[implicit_jscontext] attribute jsval onwheel;
/**
* Non-HTML5 event attributes