Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / HTMLMenuItemElement / menuitem-click.html
blob5440f5eadc5957008de6d7c735158271de8f95f9
1 <script src="../../../resources/js-test.js"></script>
2 <menu type=popup>
3 <menuitem id=mi1 type=checkbox>
4 <menuitem id=mi2 type=radio radiogroup="g1" checked>
5 <menuitem id=mi3 type=radio radiogroup="g1">
6 <menuitem id=mi4 type=radio radiogroup="g1">
7 <menu label="Submenu">
8 <menuitem id=_mi1 type=radio radiogroup="g1">
9 <menuitem id=_mi2 type=radio radiogroup="g1">
10 <menuitem id=_mi3 type=radio radiogroup="g1">
11 </menu>
12 <menuitem id=mi5 type=radio radiogroup="g2" checked>
13 <menuitem id=mi6 type=radio radiogroup="G2">
14 <menuitem id=mi7 type=radio radiogroup=" g3 " checked>
15 <menuitem id=mi8 type=radio radiogroup=" g3">
16 <menuitem id=mi9 type=radio radiogroup="" checked>
17 <menuitem id=mi10 type=radio>
18 <menuitem id=mi11 type=radio radiogroup="g4">
19 <menuitem id=mi12 type=checkbox radiogroup="g4" checked>
20 </menu>
21 <script>
23 description('Test that the "checked" attribute of menuitem is toggled with click.');
25 var element = document.getElementById('mi1');
26 element.click();
27 shouldBeTrue('element.hasAttribute("checked")');
28 element.click();
29 shouldBeFalse('element.hasAttribute("checked")');
30 var mi2 = document.getElementById('mi2');
31 var mi3 = document.getElementById('mi3');
32 var mi4 = document.getElementById('mi4');
33 shouldBeTrue('mi2.hasAttribute("checked")');
34 mi3.click();
35 shouldBeFalse('mi2.hasAttribute("checked")');
36 shouldBeTrue('mi3.hasAttribute("checked")');
37 mi4.click();
38 shouldBeFalse('mi3.hasAttribute("checked")');
39 shouldBeTrue('mi4.hasAttribute("checked")');
40 // Test clicking menuitem of type=radio which is already checked.
41 mi4.click();
42 shouldBeTrue('mi4.hasAttribute("checked")');
43 // Test radiogroup in a submenu.
44 var _mi1 = document.getElementById('_mi1');
45 _mi1.click();
46 shouldBeTrue('mi4.hasAttribute("checked")');
47 shouldBeTrue('_mi1.hasAttribute("checked")');
48 // Test radiogroup case matching.
49 var mi5 = document.getElementById('mi5');
50 var mi6 = document.getElementById('mi6');
51 mi6.click();
52 shouldBeTrue('mi5.hasAttribute("checked")');
53 shouldBeTrue('mi6.hasAttribute("checked")');
54 // Test radiogroup white space matching.
55 var mi7 = document.getElementById('mi7');
56 var mi8 = document.getElementById('mi8');
57 mi8.click();
58 shouldBeTrue('mi7.hasAttribute("checked")');
59 shouldBeTrue('mi8.hasAttribute("checked")');
60 // Test empty radiogroup.
61 var mi9 = document.getElementById('mi9');
62 var mi10 = document.getElementById('mi10');
63 mi10.click();
64 shouldBeFalse('mi9.hasAttribute("checked")');
65 shouldBeTrue('mi10.hasAttribute("checked")');
66 // Test that radiogroup attribute is ignored if type is not radio.
67 var mi11 = document.getElementById('mi11');
68 var mi12 = document.getElementById('mi12');
69 mi11.click();
70 shouldBeTrue('mi11.hasAttribute("checked")');
71 shouldBeFalse('mi12.hasAttribute("checked")');
72 </script>