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

Side by Side Diff: LayoutTests/fast/dom/HTMLElement/contextmenu.html

Issue 464903002: Add contextmenu attribute for HTMLElement. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added more tests Created 6 years, 4 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/dom/HTMLElement/contextmenu-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 <script>
7
8 description("Tests the contextmenu attribute.");
9
10 debug("Test with valid contextmenu attribute");
11 document.write("<div id='container1' contextmenu='menu1'><menu id='menu1' type=' popup' label='menu 1'></menu></div>");
12 shouldBeEqualToString("document.getElementById('container1').contextMenu.id", "m enu1");
13 shouldBeEqualToString("document.getElementById('container1').contextMenu.type", "popup");
14 shouldBeEqualToString("document.getElementById('container1').contextMenu.label", "menu 1");
15
16 debug("Test with invalid contextmenu attribute");
17 document.write("<div id='container2' contextmenu='nonexistent_menu'><menu id='me nu2' type='popup' label='menu 2'></menu></div>");
18 shouldBeNull("document.getElementById('container2').contextMenu");
19
20 debug("Test setting contextmenu attribute to non-popup type menu element");
21 document.write("<div id='container11' contextmenu='menu11'><menu id='menu11' typ e='toolbar' label='menu 11'></menu></div>");
22 var container11 = document.getElementById('container11');
23 shouldBeEqualToString("container11.contextMenu.id", "menu11");
24 shouldBeEqualToString("container11.contextMenu.type", "toolbar");
25 shouldBeEqualToString("container11.contextMenu.label", "menu 11");
26
27 debug("Test setting contextmenu attribute to non-menu element");
28 document.write("<div id='container12' contextmenu='button'><button id='button'>< /button></div>");
29 var container12 = document.getElementById('container12');
30 shouldBeNull("container12.contextMenu");
31
32 debug("Test setting contextmenu attribute to an ID which multiple elements have" );
33 document.write("<div id='container13' contextmenu='menu13'><button id='menu13'>< /button><menu id='menu13' type='popup' label='menu 13'></menu></div>");
34 var container13 = document.getElementById('container13');
35 shouldBeNull("container13.contextMenu");
36 document.write("<div id='container14' contextmenu='menu14'><menu id='menu14' typ e='popup' label='menu 14'></menu><button id='menu14'></button></div>");
37 var container14 = document.getElementById('container14');
38 shouldBeEqualToString("container14.contextMenu.id", "menu14");
39 shouldBeEqualToString("container14.contextMenu.type", "popup");
40 shouldBeEqualToString("container14.contextMenu.label", "menu 14");
41
42 debug("Test setting contextmenu attribute");
43 document.write("<div id='container3'></div>");
44 var menu = document.createElement('menu');
45 menu.id = 'menu3';
46 menu.type = 'popup';
47 menu.label = 'menu 3';
48 document.getElementById('container3').appendChild(menu);
49 var container3 = document.getElementById('container3');
50 container3.contextMenu = menu;
51 shouldBeEqualToString("container3.contextMenu.id", "menu3");
52 shouldBeEqualToString("container3.contextMenu.type", "popup");
53 shouldBeEqualToString("container3.contextMenu.label", "menu 3");
54
55 debug("Test setting contextmenu attribute with menu element without id");
56 document.write("<div id='container4'></div>");
57 var menu1 = document.createElement('menu');
58 menu1.type = 'popup';
59 menu1.label = 'menu 4';
60 document.getElementById('container4').appendChild(menu1);
61 var container4 = document.getElementById('container4');
62 container4.contextMenu = menu1;
63 shouldBeNull("container4.contextMenu");
64 shouldBeTrue("container4.hasAttribute('contextmenu')");
65 shouldBeEqualToString("container4.getAttribute('contextmenu')", "");
66
67 debug("Test setting contextmenu attribute with multiple menu element with same i d");
68 document.write("<div id='container5'></div>");
69 var menu2 = document.createElement('menu');
70 menu2.id = 'menu5';
71 menu2.type = 'popup';
72 menu2.label = 'menu 5';
73 var menu3 = document.createElement('menu');
74 menu3.id = 'menu5';
75 menu3.type = 'popup';
76 menu3.label = 'menu 6';
77 document.getElementById('container5').appendChild(menu2);
78 document.getElementById('container5').appendChild(menu3);
79 var container5 = document.getElementById('container5');
80 container5.contextMenu = menu3;
81 shouldBeNull("container5.contextMenu");
82 container5.contextMenu = menu2;
83 shouldBe("container5.contextMenu", "menu2");
84
85 debug("Test setting contextmenu attribute to null");
86 document.write("<div id='container6' contextmenu='menu6'><menu id='menu6'></menu ></div>");
87 var container6 = document.getElementById('container6');
88 container6.contextMenu = null;
89 shouldBeNull("container6.contextMenu");
90 shouldBeTrue("container6.hasAttribute('contextmenu')");
91 shouldBeEqualToString("container6.getAttribute('contextmenu')", "");
92
93 debug("Test setting contextmenu attribute to some text");
94 document.write("<div id='container7'></div>");
95 var container7 = document.getElementById('container7');
96 container7.contextMenu = "foobar";
97 shouldBeNull("container7.contextMenu");
98
99 debug("Test setting contextmenu attribute to comment");
100 document.write("<div id='container8'></div>");
101 var container8 = document.getElementById('container8');
102 container8.contextMenu = document.createComment('foo');
103 shouldBeNull("container8.contextMenu");
104
105 debug("Test setting contextmenu attribute to menu without type");
106 document.write("<div id='container9'></div>");
107 var menu4 = document.createElement('menu');
108 menu4.id = 'menu_without_type';
109 menu4.label = 'menu without type';
110 document.getElementById('container9').appendChild(menu4);
111 var container9 = document.getElementById('container9');
112 container9.contextMenu = menu4;
113 shouldBeEqualToString("container9.contextMenu.id", "menu_without_type");
114 shouldBeEqualToString("container9.contextMenu.type", "");
115 shouldBeEqualToString("container9.contextMenu.label", "menu without type");
116
117 debug("Test setting contextmenu attribute to menu element which is in shadow dom ");
118 document.write("<div id='container10'></div>");
119 var menu5 = document.createElement('menu');
120 menu5.id = 'menu_in_shadow_dom';
121 menu5.label = 'menu in shadow dom';
122 var container10 = document.getElementById('container10');
123 container10.createShadowRoot().appendChild(menu5);
124 container10.contextMenu = menu5;
125 shouldBeNull("container10.contextMenu");
126
127 </script>
128 </html>
OLDNEW
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLElement/contextmenu-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698