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

Unified Diff: LayoutTests/contextmenu/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: 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
Index: LayoutTests/contextmenu/custom-context-menu.html
diff --git a/LayoutTests/contextmenu/custom-context-menu.html b/LayoutTests/contextmenu/custom-context-menu.html
new file mode 100644
index 0000000000000000000000000000000000000000..5b0c277dfb9b9fd92a7c2f3a6c164935936e8f20
--- /dev/null
+++ b/LayoutTests/contextmenu/custom-context-menu.html
@@ -0,0 +1,51 @@
+<!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">
+ <menuitem label="Item1"></menuitem>
+ <menuitem label="Item2"></menuitem>
+ <menuitem label="Item3"></menuitem>
+ <menu label="Submenu">
+ <menuitem label="Item4"></menuitem>
+ <menu label="Deeper submenu">
+ <menuitem label="Item5"></menuitem>
+ <menuitem label="Item6"></menuitem>
+ </menu>
+ </menu>
+ <menuitem label="Item7"></menuitem>
+ </menu>
+</button>
+<script>
+description("Tests the custom context menu items.");
+var button = document.getElementById("button");
+var buttonWithContextMenu = document.getElementById("button_with_contextmenu");
+
+var x = button.offsetParent.offsetLeft + button.offsetLeft + 4;
+var y = button.offsetParent.offsetTop + button.offsetTop + button.offsetHeight / 2;
+
+var x1 = buttonWithContextMenu.offsetParent.offsetLeft + buttonWithContextMenu.offsetLeft + 4;
+var y1 = buttonWithContextMenu.offsetParent.offsetTop + buttonWithContextMenu.offsetTop + buttonWithContextMenu.offsetHeight / 2;
+
+if (window.eventSender) {
tkent 2014/08/21 01:34:38 Show something if no eventSender.
pals 2014/08/25 14:19:40 Done.
+ eventSender.mouseMoveTo(x, y);
+ var items = eventSender.contextClick();
tkent 2014/08/21 01:34:38 Let's make a function like contextClickAndGetMenuI
pals 2014/08/25 14:19:41 Done.
+
+ // Esc key to hide the context menu.
+ eventSender.keyDown(String.fromCharCode(0x001B), null);
tkent 2014/08/21 01:34:38 Is this necessary?
pals 2014/08/25 14:19:40 Yes, otherwise next contextClick() does not invoke
+
+ eventSender.mouseMoveTo(x1, y1);
+ var itemsWithCustomContextMenu = eventSender.contextClick();
+
+ shouldBeEqualToNumber((itemsWithCustomContextMenu.length - items.length), 9);
tkent 2014/08/21 01:34:38 The first argument should be as string evaluated l
pals 2014/08/25 14:19:40 Done.
+ shouldBeEqualToString("itemsWithCustomContextMenu[0]", "Item1");
+ shouldBeEqualToString("itemsWithCustomContextMenu[3]", "Submenu >");
+ shouldBeEqualToString("itemsWithCustomContextMenu[4]", "_Item4");
+ shouldBeEqualToString("itemsWithCustomContextMenu[5]", "_Deeper submenu >");
+ shouldBeEqualToString("itemsWithCustomContextMenu[7]", "__Item6");
+ shouldBeEqualToString("itemsWithCustomContextMenu[8]", "Item7");
+}
+</script>
« no previous file with comments | « no previous file | LayoutTests/contextmenu/custom-context-menu-expected.txt » ('j') | Source/core/page/ContextMenuController.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698