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

Unified Diff: LayoutTests/fast/dom/HTMLMenuElement/custom-context-menu.html

Issue 492753002: Add support to populate custom context menu items. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed comments 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/HTMLMenuElement/custom-context-menu-expected.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: LayoutTests/fast/dom/HTMLMenuElement/custom-context-menu.html
diff --git a/LayoutTests/fast/dom/HTMLMenuElement/custom-context-menu.html b/LayoutTests/fast/dom/HTMLMenuElement/custom-context-menu.html
new file mode 100644
index 0000000000000000000000000000000000000000..7d2d980fe44077025cc768835cf654d77c1cffc0
--- /dev/null
+++ b/LayoutTests/fast/dom/HTMLMenuElement/custom-context-menu.html
@@ -0,0 +1,161 @@
+<!DOCTYPE html>
+<head>
+<script src="../../../resources/js-test.js"></script>
+</head>
+<button id="button" style="height: 100px; width: 100px;">
+</button>
+<button id="button_with_contextmenu" contextmenu="menu_id" style="height: 100px; width: 100px;">
+ <menu id="menu_id" type="PopUp">
+ <!-- Test removal of separator at the start. -->
+ <hr>
+ <menuitem label="Item1"></menuitem>
+ <menuitem label="Item2"></menuitem>
+ <!-- Test addition of separator for <hr>. -->
+ <hr>
+ <menuitem label="Item3"></menuitem>
+ <!-- Test child menu with label. -->
+ <menu label="Submenu">
+ <menuitem label="Item4"></menuitem>
+ <menu label="Deeper submenu">
+ <!-- Test removal of separator at the start inside submenu. -->
+ <hr>
+ <menuitem label="Item5"></menuitem>
+ <hr>
+ <menuitem label="Item6"></menuitem>
+ <!-- Test removal of separator at the end inside submenu. -->
+ <hr>
+ </menu>
+ </menu>
+ <menuitem label="Item7"></menuitem>
+ <!-- Test child menu without label. -->
+ <menu>
+ <menuitem label="Item8"></menuitem>
+ <!-- Test child menu with empty label. -->
+ <menu label="">
+ <menuitem label="Item9"></menuitem>
+ <menuitem label="Item10"></menuitem>
+ </menu>
+ <!-- Test collapsing two or more adjacent separators. -->
+ <hr>
+ <menuitem label="Item11"></menuitem>
+ <menuitem label="Item12"></menuitem>
+ </menu>
+ <!-- Test collapsing two or more adjacent separators. -->
+ <hr>
+ <hr>
+ <hr>
+ <hr>
+ <!-- Test menuitem menu without label. -->
+ <menuitem></menuitem>
+ <!-- Test menuitem menu with empty label. -->
+ <menuitem label=""></menuitem>
+ <menuitem label="Item13"></menuitem>
+ <!-- Test removal of separator at the end. -->
+ <hr>
+ </menu>
+</button>
+<!-- Test with menu element without type attribute specified. -->
+<button id="button_1" contextmenu="menu_without_type" style="height: 100px; width: 100px;">
+ <menu id="menu_without_type">
+ <menuitem label="Item1"></menuitem>
+ <menuitem label="Item2"></menuitem>
+ <menuitem label="Item3"></menuitem>
+ </menu>
+</button>
+<!-- Test cancelling show event. -->
+<button id="button_2" contextmenu="menu_2" style="height: 100px; width: 100px;">
+ <menu id="menu_2" type="popup">
+ <menuitem label="Item1"></menuitem>
+ <menuitem label="Item2"></menuitem>
+ <menuitem label="Item3"></menuitem>
+ </menu>
+</button>
+<!-- Test removing menu element inside show event handler. -->
+<button id="button_3" contextmenu="menu_3" style="height: 100px; width: 100px;">
+ <menu id="menu_3" type="popup">
+ <menuitem label="Item1"></menuitem>
+ <menuitem label="Item2"></menuitem>
+ <menuitem label="Item3"></menuitem>
+ </menu>
+</button>
+<!-- Test with menu element without any children. -->
+<button id="button_4" contextmenu="menu_4" style="height: 100px; width: 100px;">
+ <menu id="menu_4" type="popup">
+ </menu>
+</button>
+<script>
+if (!window.eventSender)
+ debug("This test requires window.eventSender.")
+
+function contextClickAndGetMenuItems(element) {
+ var x = element.offsetParent.offsetLeft + element.offsetLeft + 4;
+ var y = element.offsetParent.offsetTop + element.offsetTop + element.offsetHeight / 2;
+ eventSender.mouseMoveTo(x, y);
+ return eventSender.contextClick();
+}
+
+function cancel(event) {
+ event.preventDefault();
+}
+
+function removeMenu(event) {
+ event.target.remove();
+}
+
+description("Tests the custom context menu items.");
+var button = document.getElementById("button");
+var items = contextClickAndGetMenuItems(button);
+
+// Esc key to hide the context menu.
+eventSender.keyDown("escape");
+
+var buttonWithContextMenu = document.getElementById("button_with_contextmenu");
+var itemsWithCustomContextMenu = contextClickAndGetMenuItems(buttonWithContextMenu);
+
+// Esc key to hide the context menu.
+eventSender.keyDown("escape");
+
+var button1 = document.getElementById("button_1");
+var items1 = contextClickAndGetMenuItems(button1);
+
+// Esc key to hide the context menu.
+eventSender.keyDown("escape");
+
+var button2 = document.getElementById("button_2");
+document.getElementById("menu_2").addEventListener("show", cancel, false);
+var items2 = contextClickAndGetMenuItems(button2);
+
+// Esc key to hide the context menu.
+eventSender.keyDown("escape");
+
+var button3 = document.getElementById("button_3");
+document.getElementById("menu_3").addEventListener("show", removeMenu, false);
+var items3 = contextClickAndGetMenuItems(button3);
+
+// Esc key to hide the context menu.
+eventSender.keyDown("escape");
+
+var button4 = document.getElementById("button_4");
+var items4 = contextClickAndGetMenuItems(button4);
+
+shouldBeEqualToNumber("itemsWithCustomContextMenu.length - items.length", 21);
+shouldBeEqualToString("itemsWithCustomContextMenu[0]", "Item1");
+shouldBeEqualToString("itemsWithCustomContextMenu[4]", "Submenu >");
+shouldBeEqualToString("itemsWithCustomContextMenu[5]", "_Item4");
+shouldBeEqualToString("itemsWithCustomContextMenu[6]", "_Deeper submenu >");
+shouldBeEqualToString("itemsWithCustomContextMenu[7]", "__Item5");
+shouldBeEqualToString("itemsWithCustomContextMenu[8]", "__---------");
+shouldBeEqualToString("itemsWithCustomContextMenu[10]", "Item7");
+shouldBeEqualToString("itemsWithCustomContextMenu[11]", "---------");
+shouldBeEqualToString("itemsWithCustomContextMenu[12]", "Item8");
+shouldBeEqualToString("itemsWithCustomContextMenu[13]", "---------");
+shouldBeEqualToString("itemsWithCustomContextMenu[14]", "Item9");
+shouldBeEqualToString("itemsWithCustomContextMenu[16]", "---------");
+shouldBeEqualToString("itemsWithCustomContextMenu[19]", "---------");
+shouldBeEqualToString("itemsWithCustomContextMenu[20]", "Item13");
+shouldBeEqualToNumber("items1.length - items.length", 0);
+shouldBeEqualToNumber("items2.length - items.length", 0);
+shouldBeEqualToNumber("items3.length - items.length", 0);
+shouldBeEqualToNumber("items4.length - items.length", 0);
+
+</script>
« no previous file with comments | « no previous file | LayoutTests/fast/dom/HTMLMenuElement/custom-context-menu-expected.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698