Index: LayoutTests/fast/dom/HTMLElement/script-tests/contextmenu.js |
diff --git a/LayoutTests/fast/dom/HTMLElement/script-tests/contextmenu.js b/LayoutTests/fast/dom/HTMLElement/script-tests/contextmenu.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..134bc1d028351fb17a63cdb1ea8c47830a5f68cc |
--- /dev/null |
+++ b/LayoutTests/fast/dom/HTMLElement/script-tests/contextmenu.js |
@@ -0,0 +1,52 @@ |
+description('Tests the contextmenu attribute.'); |
+ |
+debug("Test with valid contextmenu attribute"); |
+document.write("<div id='container1' contextmenu='menu1'><menu id='menu1' type='popup' label='menu 1'></menu></div>"); |
+shouldBe("document.getElementById('container1').contextMenu.id", "'menu1'"); |
+shouldBe("document.getElementById('container1').contextMenu.type", "'popup'"); |
+shouldBe("document.getElementById('container1').contextMenu.label", "'menu 1'"); |
+ |
+debug("Test with invalid contextmenu attribute"); |
+document.write("<div id='container2' contextmenu='nonexistent_menu'><menu id='menu2' type='popup' label='menu 2'></menu></div>"); |
+shouldBe("document.getElementById('container2').contextMenu", "null"); |
+ |
+debug("Test setting contextmenu attribute"); |
+document.write("<div id='container3'></div>"); |
+var menu = document.createElement('menu'); |
+menu.id = 'menu3'; |
+menu.type = 'popup'; |
+menu.label = 'menu 3'; |
+document.getElementById('container3').appendChild(menu); |
+var container3 = document.getElementById('container3'); |
+container3.contextMenu = menu; |
+shouldBe("container3.contextMenu.id", "'menu3'"); |
+shouldBe("container3.contextMenu.type", "'popup'"); |
+shouldBe("container3.contextMenu.label", "'menu 3'"); |
+ |
+debug("Test setting contextmenu attribute with menu element without id"); |
+document.write("<div id='container4'></div>"); |
+var menu1 = document.createElement('menu'); |
+menu1.type = 'popup'; |
+menu1.label = 'menu 4'; |
+document.getElementById('container4').appendChild(menu1); |
+var container4 = document.getElementById('container4'); |
+container4.contextMenu = menu1; |
+shouldBe("container4.contextMenu", "null"); |
+ |
+debug("Test setting contextmenu attribute with multiple menu element with same id"); |
+document.write("<div id='container5'></div>"); |
+var menu2 = document.createElement('menu'); |
+menu2.id = 'menu5'; |
+menu2.type = 'popup'; |
+menu2.label = 'menu 5'; |
+var menu3 = document.createElement('menu'); |
+menu3.id = 'menu5'; |
+menu3.type = 'popup'; |
+menu3.label = 'menu 6'; |
+document.getElementById('container5').appendChild(menu2); |
+document.getElementById('container5').appendChild(menu3); |
+var container5 = document.getElementById('container5'); |
+container5.contextMenu = menu2; |
+shouldBe("container5.contextMenu.id", "'menu5'"); |
+shouldBe("container5.contextMenu.type", "'popup'"); |
+shouldBe("container5.contextMenu.label", "'menu 5'"); |