WebCore:
[WebKit-https.git] / LayoutTests / security / set-form-autocomplete-attribute.html
1 <html>
2 <head>
3 <script>
4
5 if (window.layoutTestController)
6     layoutTestController.dumpAsText();
7
8 function log(message)
9 {    
10     var txt = document.createTextNode(message);
11     document.getElementById("logger").appendChild(txt);
12     document.getElementById("logger").appendChild(document.createElement('br'));
13 }
14
15 function logAutoCompleteAPIResult()
16 {
17     if (layoutTestController.elementDoesAutoCompleteForElementWithId("autoInput"))
18         log("Element does autocomplete");
19     else
20         log("Element does *not* autocomplete");
21 }
22
23 function runTest()
24 {
25     if (!window.layoutTestController) {
26         alert("This test can only be run in DumpRenderTree");
27         return;
28     }
29     
30     var form = document.getElementById("autoForm");
31     var input = document.getElementById("autoInput");
32     
33     // Test with no autocomplete attribute on the <form>
34     logAutoCompleteAPIResult();
35
36     input.setAttribute("autocomplete", "cheese");
37     logAutoCompleteAPIResult();
38
39     input.setAttribute("autocomplete", "off");
40     logAutoCompleteAPIResult();
41
42     input.setAttribute("autocomplete", "on");
43     logAutoCompleteAPIResult();
44
45     input.setAttribute("autocomplete", "cheese");
46     logAutoCompleteAPIResult();
47
48     input.removeAttribute("autocomplete");
49     logAutoCompleteAPIResult();
50     
51     // Test with autocomplete="off" on the <form>
52     form.setAttribute("autocomplete", "off");
53     logAutoCompleteAPIResult();
54     
55     input.setAttribute("autocomplete", "cheese");
56     logAutoCompleteAPIResult();
57
58     input.setAttribute("autocomplete", "off");
59     logAutoCompleteAPIResult();
60
61     input.setAttribute("autocomplete", "on");
62     logAutoCompleteAPIResult();
63
64     input.setAttribute("autocomplete", "cheese");
65     logAutoCompleteAPIResult();
66
67     input.removeAttribute("autocomplete");
68     logAutoCompleteAPIResult();
69 }
70
71 </script>
72 </head>
73 <body onload="runTest();">
74 <div id="logger"></div>
75 <form id="autoForm" method="post">
76 <input type="text" id="autoInput"/>
77 </form>
78 This test exercises the WebKit API "elementDoesAutoComplete:" to make sure that API clients get the correct answer about whether or not a an element should autocomplete.
79 </body>
80 </html>