[WK2] selection does not disappear after coping the text
[framework/web/webkit-efl.git] / LayoutTests / fast / forms / search-disabled-readonly.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../js/resources/js-test-pre.js"></script>
5 <script src="resources/common.js"></script>
6 </head>
7 <body>
8 <input id="search_input" type="search" />
9 <div id="console">
10 <p>
11 This tests the behavior of a cancel button in search input forms.
12 </p>
13 </div>
14 <script>
15 function click(position) {
16     if (!eventSender)
17         return;
18     eventSender.mouseMoveTo(position.x, position.y);
19     eventSender.mouseDown();
20     eventSender.mouseMoveTo(position.x, position.y);
21     eventSender.mouseUp();
22     eventSender.leapForward(1000);
23 }
24
25 function keydown(character) {
26     if (!eventSender)
27         return;
28     eventSender.keyDown(character);
29     eventSender.leapForward(1000);
30 }
31
32 function setInputAttributes(input, value, disabled, readonly) {
33     input.value = value;
34     input.disabled = disabled;
35     input.readOnly = !!readonly;
36 }
37
38 if (window.layoutTestController) {
39     var input = $("search_input");
40     var cancelButtonPosition = searchCancelButtonPosition(input);
41     var middleButtonPosition = {};
42     middleButtonPosition.x = input.offsetLeft + input.offsetWidth / 2;
43     middleButtonPosition.y = input.offsetTop + input.offsetHeight / 2;
44     var enabled = false;
45     var disabled = true;
46     var readonly = true;
47
48     debug("Test on the input form with disabled=false and readonly=false");
49
50     setInputAttributes(input, "foo", enabled);
51     debug("Click the cancel button:");
52     click(cancelButtonPosition);
53     shouldBe('input.value', '""');
54     debug("... and then input one character:");
55     keydown("b");
56     shouldBe('input.value', '"b"');
57
58     setInputAttributes(input, "foo", enabled);
59     debug("Click the center of the form:");
60     click(middleButtonPosition);
61     shouldBe('input.value', '"foo"');
62     debug("... and then input one character:");
63     keydown("b");
64     shouldBe('input.value', '"foob"');
65
66     debug("");
67     debug("Test on the input form with disabled=false and readonly=true");
68
69     setInputAttributes(input, "foo", enabled, readonly);
70     debug("Click the cancel button:");
71     click(cancelButtonPosition);
72     shouldBe('input.value', '"foo"');
73     debug("... and then input one character:");
74     keydown("b");
75     shouldBe('input.value', '"foo"');
76
77     setInputAttributes(input, "foo", enabled, readonly);
78     debug("Click the center of the form:");
79     click(middleButtonPosition);
80     shouldBe('input.value', '"foo"');
81     debug("... and then input one character:");
82     keydown("b");
83     shouldBe('input.value', '"foo"');
84
85     debug("");
86     debug("Test on the input form with disabled=true and readonly=false");
87
88     setInputAttributes(input, "foo", disabled);
89     debug("Click the cancel button:");
90     click(cancelButtonPosition);
91     shouldBe('input.value', '"foo"');
92     debug("... and then input one character:");
93     keydown("b");
94     shouldBe('input.value', '"foo"');
95
96     setInputAttributes(input, "foo", disabled);
97     debug("Click the center of the form:");
98     click(middleButtonPosition);
99     shouldBe('input.value', '"foo"');
100     debug("... and then input one character:");
101     keydown("b");
102     shouldBe('input.value', '"foo"');
103
104     debug("");
105     debug("Test on the input form with disabled=true and readonly=true");
106
107     setInputAttributes(input, "foo", disabled, readonly);
108     debug("Click the cancel button:");
109     click(cancelButtonPosition);
110     shouldBe('input.value', '"foo"');
111     debug("... and then input one character:");
112     keydown("b");
113     shouldBe('input.value', '"foo"');
114
115     setInputAttributes(input, "foo", disabled, readonly);
116     debug("Click the center of the form:");
117     click(middleButtonPosition);
118     shouldBe('input.value', '"foo"');
119     debug("... and then input one character:");
120     keydown("b");
121     shouldBe('input.value', '"foo"');
122
123     debug("");
124 }
125 </script>
126 <script src="../js/resources/js-test-post.js"></script>
127 </body>
128 </html>