1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <p id=
"description"></p>
8 <div id=
"console"></div>
10 description('Tests for checkValidity() with invalid event canceling');
12 var parent
= document
.createElement('div');
13 document
.body
.appendChild(parent
);
14 parent
.innerHTML
= '<form><input name=i required></form>';
15 var form
= parent
.firstChild
;
16 var input
= form
.firstChild
;
18 debug('"invalid" event is not canceled.');
19 var invalidFired
= false;
20 var nothingListener
= {};
21 nothingListener
.handleEvent = function(event
) {
24 shouldBeTrue('input.addEventListener("invalid", nothingListener, false); !input.checkValidity() && invalidFired');
25 shouldBeTrue('invalidFired = false; !form.checkValidity() && invalidFired');
26 input
.removeEventListener('invalid', nothingListener
, false);
29 debug('"invalid" event is canceled.');
31 var cancelListener
= {};
32 cancelListener
.handleEvent = function(event
) {
34 event
.preventDefault();
36 // Even if 'invalid' is canceled, the input.checkValidity() result is still false.
37 shouldBeTrue('input.addEventListener("invalid", cancelListener, false); !input.checkValidity() && invalidFired');
38 // form.checkValidity() also should be false.
39 shouldBeTrue('invalidFired = false; !form.checkValidity() && invalidFired');