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

Side by Side Diff: LayoutTests/http/tests/misc/custom-context-menu.html

Issue 802233004: Implement icon attribute for menuitem (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: LayoutTest rebase Created 5 years, 11 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/http/tests/misc/custom-context-menu-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>
2 <head>
3 <script src="/js-test-resources/js-test.js"></script>
4 </head>
5 <button id="button" style="height: 100px; width: 100px;">
6 </button>
7 <button id="button_with_contextmenu" contextmenu="menu_id" style="height: 100px; width: 100px;">
8 <menu id="menu_id" type="PopUp">
9 <!-- Test removal of separator at the start. -->
10 <hr>
11 <menuitem label="Item1"></menuitem>
12 <!-- Test disabled menuitem. -->
13 <menuitem label="Item2" disabled></menuitem>
14 <!-- Test addition of separator for <hr>. -->
15 <hr>
16 <menuitem label="Item3"></menuitem>
17 <!-- Test child menu with label. -->
18 <menu label="Submenu">
19 <menuitem label="Item4"></menuitem>
20 <menu label="Deeper submenu">
21 <!-- Test removal of separator at the start inside submenu. -->
22 <hr>
23 <menuitem label="Item5"></menuitem>
24 <hr>
25 <menuitem label="Item6"></menuitem>
26 <!-- Test removal of separator at the end inside submenu. -->
27 <hr>
28 </menu>
29 </menu>
30 <menuitem label="Item7"></menuitem>
31 <!-- Test child menu without label. -->
32 <menu>
33 <menuitem label="Item8"></menuitem>
34 <!-- Test child menu with empty label. -->
35 <menu label="">
36 <menuitem label="Item9"></menuitem>
37 <menuitem label="Item10"></menuitem>
38 </menu>
39 <menuitem label="Item11"></menuitem>
40 <menuitem label="Item12"></menuitem>
41 </menu>
42 <!-- Test collapsing two or more adjacent separators. -->
43 <hr>
44 <hr>
45 <hr>
46 <hr>
47 <!-- Test menuitem menu without label. -->
48 <menuitem></menuitem>
49 <!-- Test menuitem menu with empty label. -->
50 <menuitem label=""></menuitem>
51 <menuitem label="Item13"></menuitem>
52 <!-- Test menuitem of type "checkbox" without "checked" attribute. -->
53 <menuitem type="checkbox" label="Item14"></menuitem>
54 <!-- Test menuitem of type "checkbox" with "checked" attribute. -->
55 <menuitem type="checkbox" label="Item15" checked></menuitem>
56 <!-- Test default menuitem with "checked" attribute. -->
57 <menuitem label="Item16" checked></menuitem>
58 <!-- Test menuitem of type "radio" with "checked" attribute. -->
59 <menuitem type="radio" radiogroup="group" label="Item17"></menuitem>
60 <menuitem type="radio" radiogroup="group" label="Item18" checked></menui tem>
61 <menuitem type="radio" radiogroup="group" label="Item19"></menuitem>
62 <!-- Test menuitem of with "icon" attribute. -->
63 <menuitem label="Item20" icon="abc.png" checked></menuitem>
64 <!-- Test removal of separator at the end. -->
65 <hr>
66 </menu>
67 </button>
68 <!-- Test with menu element without type attribute specified. -->
69 <button id="button_1" contextmenu="menu_without_type" style="height: 100px; widt h: 100px;">
70 <menu id="menu_without_type">
71 <menuitem label="Item1"></menuitem>
72 <menuitem label="Item2"></menuitem>
73 <menuitem label="Item3"></menuitem>
74 </menu>
75 </button>
76 <!-- Test cancelling show event. -->
77 <button id="button_2" contextmenu="menu_2" style="height: 100px; width: 100px;">
78 <menu id="menu_2" type="popup">
79 <menuitem label="Item1"></menuitem>
80 <menuitem label="Item2"></menuitem>
81 <menuitem label="Item3"></menuitem>
82 </menu>
83 </button>
84 <!-- Test removing menu element inside show event handler. -->
85 <button id="button_3" contextmenu="menu_3" style="height: 100px; width: 100px;">
86 <menu id="menu_3" type="popup">
87 <menuitem label="Item1"></menuitem>
88 <menuitem label="Item2"></menuitem>
89 <menuitem label="Item3"></menuitem>
90 </menu>
91 </button>
92 <!-- Test with menu element without any children. -->
93 <button id="button_4" contextmenu="menu_4" style="height: 100px; width: 100px;">
94 <menu id="menu_4" type="popup">
95 </menu>
96 </button>
97 <!-- Test if an element A has a parent element, then A's assigned context menu i s the assigned context menu of its parent element. -->
98 <div contextmenu="menu_5">
99 <div>
100 <button id="button_5" style="height: 100px; width: 100px;"></button>
101 </div>
102 <menu id="menu_5" type="popup">
103 <menuitem label="Item1">
104 <menuitem label="Item2">
105 <menuitem label="Item3">
106 </menu>
107 </div>
108 <script>
109 if (!window.eventSender)
110 debug("This test requires window.eventSender.")
111
112 function contextClickAndGetMenuItems(element) {
113 var x = element.offsetParent.offsetLeft + element.offsetLeft + 4;
114 var y = element.offsetParent.offsetTop + element.offsetTop + element.offsetH eight / 2;
115 eventSender.mouseMoveTo(x, y);
116 return eventSender.contextClick();
117 }
118
119 function cancel(event) {
120 event.preventDefault();
121 }
122
123 function removeMenu(event) {
124 event.target.remove();
125 }
126
127 description("Tests the custom context menu items.");
128 var button = document.getElementById("button");
129 var items = contextClickAndGetMenuItems(button);
130
131 // Esc key to hide the context menu.
132 eventSender.keyDown("escape");
133
134 var buttonWithContextMenu = document.getElementById("button_with_contextmenu");
135 var itemsWithCustomContextMenu = contextClickAndGetMenuItems(buttonWithContextMe nu);
136
137 // Esc key to hide the context menu.
138 eventSender.keyDown("escape");
139
140 var button1 = document.getElementById("button_1");
141 var items1 = contextClickAndGetMenuItems(button1);
142
143 // Esc key to hide the context menu.
144 eventSender.keyDown("escape");
145
146 var button2 = document.getElementById("button_2");
147 document.getElementById("menu_2").addEventListener("show", cancel, false);
148 var items2 = contextClickAndGetMenuItems(button2);
149
150 // Esc key to hide the context menu.
151 eventSender.keyDown("escape");
152
153 var button3 = document.getElementById("button_3");
154 document.getElementById("menu_3").addEventListener("show", removeMenu, false);
155 var items3 = contextClickAndGetMenuItems(button3);
156
157 // Esc key to hide the context menu.
158 eventSender.keyDown("escape");
159
160 var button4 = document.getElementById("button_4");
161 var items4 = contextClickAndGetMenuItems(button4);
162
163 // Esc key to hide the context menu.
164 eventSender.keyDown("escape");
165
166 var button5 = document.getElementById("button_5");
167 var items5 = contextClickAndGetMenuItems(button5);
168
169 shouldBeEqualToNumber("itemsWithCustomContextMenu.length - items.length", 24);
170 shouldBeEqualToString("itemsWithCustomContextMenu[0]", "Item1");
171 shouldBeEqualToString("itemsWithCustomContextMenu[1]", "#Item2");
172 shouldBeEqualToString("itemsWithCustomContextMenu[2]", "---------");
173 shouldBeEqualToString("itemsWithCustomContextMenu[3]", "Item3");
174 shouldBeEqualToString("itemsWithCustomContextMenu[4]", "Submenu >");
175 shouldBeEqualToString("itemsWithCustomContextMenu[5]", "_Item4");
176 shouldBeEqualToString("itemsWithCustomContextMenu[6]", "_Deeper submenu >");
177 shouldBeEqualToString("itemsWithCustomContextMenu[7]", "__Item5");
178 shouldBeEqualToString("itemsWithCustomContextMenu[8]", "__---------");
179 shouldBeEqualToString("itemsWithCustomContextMenu[9]", "__Item6");
180 shouldBeEqualToString("itemsWithCustomContextMenu[10]", "Item7");
181 shouldBeEqualToString("itemsWithCustomContextMenu[11]", "---------");
182 shouldBeEqualToString("itemsWithCustomContextMenu[12]", "Item8");
183 shouldBeEqualToString("itemsWithCustomContextMenu[13]", "Item11");
184 shouldBeEqualToString("itemsWithCustomContextMenu[14]", "Item12");
185 shouldBeEqualToString("itemsWithCustomContextMenu[15]", "---------");
186 shouldBeEqualToString("itemsWithCustomContextMenu[16]", "Item13");
187 shouldBeEqualToString("itemsWithCustomContextMenu[17]", "Item14");
188 shouldBeEqualToString("itemsWithCustomContextMenu[18]", "*Item15");
189 shouldBeEqualToString("itemsWithCustomContextMenu[19]", "Item16");
190 shouldBeEqualToString("itemsWithCustomContextMenu[20]", "Item17");
191 shouldBeEqualToString("itemsWithCustomContextMenu[21]", "*Item18");
192 shouldBeEqualToString("itemsWithCustomContextMenu[22]", "Item19");
193 shouldBeEqualToString("itemsWithCustomContextMenu[23]", "Item20http://127.0.0.1: 8000/misc/abc.png");
194 shouldBeEqualToNumber("items1.length - items.length", 0);
195 shouldBeEqualToNumber("items2.length - items.length", 0);
196 shouldBeEqualToNumber("items3.length - items.length", 0);
197 shouldBeEqualToNumber("items4.length - items.length", 0);
198 shouldBeEqualToNumber("items5.length - items.length", 3);
199 shouldBeEqualToString("items5[0]", "Item1");
200 shouldBeEqualToString("items5[1]", "Item2");
201 shouldBeEqualToString("items5[2]", "Item3");
202
203 </script>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/http/tests/misc/custom-context-menu-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698