Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / reportValidity-cancel.html
blob18586e39a98158d7494044b2cfb845abab4cc713
1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 function $(id) { return document.getElementById(id); }
11 function focusOn(id) {
12 $(id).focus();
15 description('Tests for reportValidity() with invalid event canceling');
17 var parent = document.createElement('div');
18 document.body.appendChild(parent);
19 parent.innerHTML = '<form><input id=input-unset name=i required><input id=input2></form>';
20 var form = parent.firstChild;
21 var input = form.firstChild;
23 debug('"invalid" event is not canceled.');
24 var invalidFired = false;
25 var nothingListener = {};
26 nothingListener.handleEvent = function(event) {
27 invalidFired = true;
29 focusOn('input2');
30 shouldBeTrue('input.addEventListener("invalid", nothingListener, false); !input.reportValidity() && invalidFired');
31 shouldBe('document.activeElement', '$("input-unset")');
32 focusOn('input2');
33 shouldBeTrue('invalidFired = false; !form.reportValidity() && invalidFired');
34 shouldBe('document.activeElement', '$("input-unset")');
35 input.removeEventListener('invalid', nothingListener, false);
37 debug('');
38 debug('"invalid" event is canceled.');
39 invalidFired = false;
40 var cancelListener = {};
41 cancelListener.handleEvent = function(event) {
42 invalidFired = true;
43 event.preventDefault();
45 // Even if 'invalid' is canceled, the input.reportValidity() result is still false.
46 focusOn('input2');
47 shouldBeTrue('input.addEventListener("invalid", cancelListener, false); !input.reportValidity() && invalidFired');
48 shouldNotBe('document.activeElement', '$("input-unset")');
49 // form.reportValidity() also should be false.
50 shouldBeTrue('invalidFired = false; !form.reportValidity() && invalidFired');
51 shouldNotBe('document.activeElement', '$("input-unset")');
52 </script>
53 </body>
54 </html>