OLD | NEW |
(Empty) | |
| 1 description('Tests the contextmenu attribute.'); |
| 2 |
| 3 debug("Test with valid contextmenu attribute"); |
| 4 document.write("<div id='container1' contextmenu='menu1'><menu id='menu1' type='
popup' label='menu 1'></menu></div>"); |
| 5 shouldBe("document.getElementById('container1').contextMenu.id", "'menu1'"); |
| 6 shouldBe("document.getElementById('container1').contextMenu.type", "'popup'"); |
| 7 shouldBe("document.getElementById('container1').contextMenu.label", "'menu 1'"); |
| 8 |
| 9 debug("Test with invalid contextmenu attribute"); |
| 10 document.write("<div id='container2' contextmenu='nonexistent_menu'><menu id='me
nu2' type='popup' label='menu 2'></menu></div>"); |
| 11 shouldBe("document.getElementById('container2').contextMenu", "null"); |
| 12 |
| 13 debug("Test setting contextmenu attribute"); |
| 14 document.write("<div id='container3'></div>"); |
| 15 var menu = document.createElement('menu'); |
| 16 menu.id = 'menu3'; |
| 17 menu.type = 'popup'; |
| 18 menu.label = 'menu 3'; |
| 19 document.getElementById('container3').appendChild(menu); |
| 20 var container3 = document.getElementById('container3'); |
| 21 container3.contextMenu = menu; |
| 22 shouldBe("container3.contextMenu.id", "'menu3'"); |
| 23 shouldBe("container3.contextMenu.type", "'popup'"); |
| 24 shouldBe("container3.contextMenu.label", "'menu 3'"); |
| 25 |
| 26 debug("Test setting contextmenu attribute with menu element without id"); |
| 27 document.write("<div id='container4'></div>"); |
| 28 var menu1 = document.createElement('menu'); |
| 29 menu1.type = 'popup'; |
| 30 menu1.label = 'menu 4'; |
| 31 document.getElementById('container4').appendChild(menu1); |
| 32 var container4 = document.getElementById('container4'); |
| 33 container4.contextMenu = menu1; |
| 34 shouldBe("container4.contextMenu", "null"); |
| 35 |
| 36 debug("Test setting contextmenu attribute with multiple menu element with same i
d"); |
| 37 document.write("<div id='container5'></div>"); |
| 38 var menu2 = document.createElement('menu'); |
| 39 menu2.id = 'menu5'; |
| 40 menu2.type = 'popup'; |
| 41 menu2.label = 'menu 5'; |
| 42 var menu3 = document.createElement('menu'); |
| 43 menu3.id = 'menu5'; |
| 44 menu3.type = 'popup'; |
| 45 menu3.label = 'menu 6'; |
| 46 document.getElementById('container5').appendChild(menu2); |
| 47 document.getElementById('container5').appendChild(menu3); |
| 48 var container5 = document.getElementById('container5'); |
| 49 container5.contextMenu = menu2; |
| 50 shouldBe("container5.contextMenu.id", "'menu5'"); |
| 51 shouldBe("container5.contextMenu.type", "'popup'"); |
| 52 shouldBe("container5.contextMenu.label", "'menu 5'"); |
OLD | NEW |