Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / ui / webui / resources / js / cr / ui / menu_test.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="https://cdn.rawgit.com/google/closure-library/master/closure/goog/base.js"></script>
5 <script src="../../cr.js"></script>
6 <script src="../event_target.js"></script>
7 <script src="../ui.js"></script>
8 <script src="command.js"></script>
9 <script src="menu.js"></script>
10 <script src="menu_item.js"></script>
11 <script>
12
13 goog.require('goog.testing.jsunit');
14
15 </script>
16
17 </head>
18 <body>
19
20 <script>
21
22 /**
23  * Tests that if the command attributes are spacified, they are copied to the
24  * corresponding menuitem.
25  */
26 function testCommandMenuItem() {
27   // Test 1: The case that the comamnd label is set.
28   var command = new cr.ui.Command();
29   command.id = 'the-command';
30   command.label = 'CommandLabel';
31   command.disabled = false;
32   command.hidden = false;
33   document.body.appendChild(command);
34
35   var menuItem = new cr.ui.MenuItem();
36   menuItem.command = '#the-command';
37
38   // Confirms the label is copied from the command.
39   assertEquals('CommandLabel', menuItem.label);
40   // Confirms the attributes are copied from the command.
41   assertEquals(false, menuItem.disabled);
42   assertEquals(false, menuItem.hidden);
43
44   // Test 2: The case that the comamnd label is not set.
45   var command2 = new cr.ui.Command();
46   command2.id = 'the-command2';
47   command2.disabled = false;
48   command2.hidden = false;
49   document.body.appendChild(command2);
50
51   var menuItem2 = new cr.ui.MenuItem();
52   menuItem2.label = 'MenuLabel';
53   menuItem2.command = '#the-command2';
54
55   // Confirms the label is not copied, keeping the original label.
56   assertEquals('MenuLabel', menuItem2.label);
57   // Confirms the attributes are copied from the command.
58   assertEquals(false, menuItem2.disabled);
59   assertEquals(false, menuItem2.hidden);
60 }
61
62 </script>
63
64 </body>
65 </html>