Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: LayoutTests/fast/forms/reportValidity-cancel.html

Issue 660783002: Implement reportValidity() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Apply couple more tkent's comments + pull Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/forms/reportValidity-cancel-expected.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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();
13 }
14
15 description('Tests for reportValidity() with invalid event canceling');
16
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;
22
23 debug('"invalid" event is not canceled.');
24 var invalidFired = false;
25 var nothingListener = {};
26 nothingListener.handleEvent = function(event) {
27 invalidFired = true;
28 };
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);
36
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();
44 };
45 // Even if 'invalid' is canceled, the input.reportValidity() result is still fal se.
46 focusOn('input2');
47 shouldBeTrue('input.addEventListener("invalid", cancelListener, false); !input.r eportValidity() && 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>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/forms/reportValidity-cancel-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698