Bug 618948 - Add support for element.oninput and element.oninvalid. r=smaug a=sicking

This commit is contained in:
Mounir Lamouri 2010-12-22 19:43:50 -05:00
parent 3f4ba531d6
commit 301df17125
4 changed files with 101 additions and 0 deletions

View File

@ -249,6 +249,7 @@ _TEST_FILES = \
test_bug615833.html \
test_bug601030.html \
test_bug610687.html \
test_bug618948.html \
$(NULL)
libs:: $(_TEST_FILES)

View File

@ -0,0 +1,89 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=618948
-->
<head>
<title>Test for Bug 618948</title>
<script type="application/javascript" src="/MochiKit/packed.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=618948">Mozilla Bug 618948</a>
<p id="display"></p>
<div id="content">
<form>
<input type='email' id='i'>
<button>submit</button>
</form>
</div>
<pre id="test">
<script type="application/javascript">
/** Test for Bug 618948 **/
var events = ["focus", "input", "change", "invalid" ];
var handled = ({});
function eventHandler(event)
{
dump("\n" + event.type + "\n");
handled[event.type] = true;
}
function beginTest()
{
for each (var e in events) {
handled[e] = false;
}
i.focus();
}
function endTest()
{
for each (var e in events) {
ok(handled[e], "on" + e + " should have been called");
}
SimpleTest.finish();
}
var i = document.getElementsByTagName('input')[0];
var b = document.getElementsByTagName('button')[0];
i.onfocus = function(event) {
eventHandler(event);
synthesizeKey('f', {});
i.onfocus = null;
};
i.oninput = function(event) {
eventHandler(event);
b.focus();
i.oninput = null;
};
i.onchange = function(event) {
eventHandler(event);
i.onchange = null;
synthesizeMouseAtCenter(b, {});
};
i.oninvalid = function(event) {
eventHandler(event);
i.oninvad = null;
endTest();
};
SimpleTest.waitForExplicitFinish();
SimpleTest.waitForFocus(beginTest);
</script>
</pre>
</body>
</html>

View File

@ -1566,6 +1566,8 @@ jsid nsDOMClassInfo::sOnblur_id = JSID_VOID;
jsid nsDOMClassInfo::sOnsubmit_id = JSID_VOID;
jsid nsDOMClassInfo::sOnreset_id = JSID_VOID;
jsid nsDOMClassInfo::sOnchange_id = JSID_VOID;
jsid nsDOMClassInfo::sOninput_id = JSID_VOID;
jsid nsDOMClassInfo::sOninvalid_id = JSID_VOID;
jsid nsDOMClassInfo::sOnselect_id = JSID_VOID;
jsid nsDOMClassInfo::sOnload_id = JSID_VOID;
jsid nsDOMClassInfo::sOnpopstate_id = JSID_VOID;
@ -1797,6 +1799,8 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
SET_JSID_TO_STRING(sOnsubmit_id, cx, "onsubmit");
SET_JSID_TO_STRING(sOnreset_id, cx, "onreset");
SET_JSID_TO_STRING(sOnchange_id, cx, "onchange");
SET_JSID_TO_STRING(sOninput_id, cx, "oninput");
SET_JSID_TO_STRING(sOninvalid_id, cx, "oninvalid");
SET_JSID_TO_STRING(sOnselect_id, cx, "onselect");
SET_JSID_TO_STRING(sOnload_id, cx, "onload");
SET_JSID_TO_STRING(sOnpopstate_id, cx, "onpopstate");
@ -4866,6 +4870,8 @@ nsDOMClassInfo::ShutDown()
sOnsubmit_id = JSID_VOID;
sOnreset_id = JSID_VOID;
sOnchange_id = JSID_VOID;
sOninput_id = JSID_VOID;
sOninvalid_id = JSID_VOID;
sOnselect_id = JSID_VOID;
sOnload_id = JSID_VOID;
sOnbeforeunload_id = JSID_VOID;
@ -7503,6 +7509,9 @@ nsEventReceiverSH::ReallyIsEventName(jsid id, jschar aFirstChar)
return id == sOnfocus_id;
case 'h' :
return id == sOnhashchange_id;
case 'i' :
return (id == sOninput_id ||
id == sOninvalid_id);
case 'k' :
return (id == sOnkeydown_id ||
id == sOnkeypress_id ||

View File

@ -322,6 +322,8 @@ public:
static jsid sOnsubmit_id;
static jsid sOnreset_id;
static jsid sOnchange_id;
static jsid sOninput_id;
static jsid sOninvalid_id;
static jsid sOnselect_id;
static jsid sOnload_id;
static jsid sOnpopstate_id;