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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLElement/contextmenu-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/HTMLElement/contextmenu.html
diff --git a/LayoutTests/fast/dom/HTMLElement/contextmenu.html b/LayoutTests/fast/dom/HTMLElement/contextmenu.html
new file mode 100644
index 0000000000000000000000000000000000000000..936c1129c197ab038ed8a36205f846352aba4cd6
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLElement/contextmenu.html
@@ -0,0 +1,128 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+</head>
+<script>
+
+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>");
+shouldBeEqualToString("document.getElementById('container1').contextMenu.id", "menu1");
+shouldBeEqualToString("document.getElementById('container1').contextMenu.type", "popup");
+shouldBeEqualToString("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>");
+shouldBeNull("document.getElementById('container2').contextMenu");
+
+debug("Test setting contextmenu attribute to non-popup type menu element");
+document.write("<div id='container11' contextmenu='menu11'><menu id='menu11' type='toolbar' label='menu 11'></menu></div>");
+var container11 = document.getElementById('container11');
+shouldBeEqualToString("container11.contextMenu.id", "menu11");
+shouldBeEqualToString("container11.contextMenu.type", "toolbar");
+shouldBeEqualToString("container11.contextMenu.label", "menu 11");
+
+debug("Test setting contextmenu attribute to non-menu element");
+document.write("<div id='container12' contextmenu='button'><button id='button'></button></div>");
+var container12 = document.getElementById('container12');
+shouldBeNull("container12.contextMenu");
+
+debug("Test setting contextmenu attribute to an ID which multiple elements have");
+document.write("<div id='container13' contextmenu='menu13'><button id='menu13'></button><menu id='menu13' type='popup' label='menu 13'></menu></div>");
+var container13 = document.getElementById('container13');
+shouldBeNull("container13.contextMenu");
+document.write("<div id='container14' contextmenu='menu14'><menu id='menu14' type='popup' label='menu 14'></menu><button id='menu14'></button></div>");
+var container14 = document.getElementById('container14');
+shouldBeEqualToString("container14.contextMenu.id", "menu14");
+shouldBeEqualToString("container14.contextMenu.type", "popup");
+shouldBeEqualToString("container14.contextMenu.label", "menu 14");
+
+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;
+shouldBeEqualToString("container3.contextMenu.id", "menu3");
+shouldBeEqualToString("container3.contextMenu.type", "popup");
+shouldBeEqualToString("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;
+shouldBeNull("container4.contextMenu");
+shouldBeTrue("container4.hasAttribute('contextmenu')");
+shouldBeEqualToString("container4.getAttribute('contextmenu')", "");
+
+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 = menu3;
+shouldBeNull("container5.contextMenu");
+container5.contextMenu = menu2;
+shouldBe("container5.contextMenu", "menu2");
+
+debug("Test setting contextmenu attribute to null");
+document.write("<div id='container6' contextmenu='menu6'><menu id='menu6'></menu></div>");
+var container6 = document.getElementById('container6');
+container6.contextMenu = null;
+shouldBeNull("container6.contextMenu");
+shouldBeTrue("container6.hasAttribute('contextmenu')");
+shouldBeEqualToString("container6.getAttribute('contextmenu')", "");
+
+debug("Test setting contextmenu attribute to some text");
+document.write("<div id='container7'></div>");
+var container7 = document.getElementById('container7');
+container7.contextMenu = "foobar";
+shouldBeNull("container7.contextMenu");
+
+debug("Test setting contextmenu attribute to comment");
+document.write("<div id='container8'></div>");
+var container8 = document.getElementById('container8');
+container8.contextMenu = document.createComment('foo');
+shouldBeNull("container8.contextMenu");
+
+debug("Test setting contextmenu attribute to menu without type");
+document.write("<div id='container9'></div>");
+var menu4 = document.createElement('menu');
+menu4.id = 'menu_without_type';
+menu4.label = 'menu without type';
+document.getElementById('container9').appendChild(menu4);
+var container9 = document.getElementById('container9');
+container9.contextMenu = menu4;
+shouldBeEqualToString("container9.contextMenu.id", "menu_without_type");
+shouldBeEqualToString("container9.contextMenu.type", "");
+shouldBeEqualToString("container9.contextMenu.label", "menu without type");
+
+debug("Test setting contextmenu attribute to menu element which is in shadow dom");
+document.write("<div id='container10'></div>");
+var menu5 = document.createElement('menu');
+menu5.id = 'menu_in_shadow_dom';
+menu5.label = 'menu in shadow dom';
+var container10 = document.getElementById('container10');
+container10.createShadowRoot().appendChild(menu5);
+container10.contextMenu = menu5;
+shouldBeNull("container10.contextMenu");
+
+</script>
+</html>
« 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