Index: content/shell/renderer/test_runner/event_sender.cc |
diff --git a/content/shell/renderer/test_runner/event_sender.cc b/content/shell/renderer/test_runner/event_sender.cc |
index 8791a2f8c1dfb26b4a89dd7a1d54577c6a2faf3d..eebd9500c80bf9fdce532eda86f9438b5c1e8d5a 100644 |
--- a/content/shell/renderer/test_runner/event_sender.cc |
+++ b/content/shell/renderer/test_runner/event_sender.cc |
@@ -32,6 +32,7 @@ using blink::WebFrame; |
using blink::WebGestureEvent; |
using blink::WebInputEvent; |
using blink::WebKeyboardEvent; |
+using blink::WebMenuItemInfo; |
using blink::WebMouseEvent; |
using blink::WebMouseWheelEvent; |
using blink::WebPoint; |
@@ -121,12 +122,26 @@ int GetKeyModifiersFromV8(v8::Handle<v8::Value> value) { |
// double or triple click. |
const double kMultipleClickTimeSec = 1; |
const int kMultipleClickRadiusPixels = 5; |
+const char kSubMenuDepthIdentifier[] = "_"; |
+const char kSubMenuIdentifier[] = " >"; |
bool OutsideMultiClickRadius(const WebPoint& a, const WebPoint& b) { |
return ((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) > |
kMultipleClickRadiusPixels * kMultipleClickRadiusPixels; |
} |
+void PopulateCustomItems(const WebVector<WebMenuItemInfo>& customItems, |
tkent
2014/08/05 09:08:45
This doesn't follow Chromium coding style.
- 'out
pals
2014/08/05 09:17:29
Done.
|
+ std::vector<std::string>& strings, const std::string& prefix) { |
+ for (size_t i = 0; i < customItems.size(); ++i) { |
+ if (customItems[i].type == blink::WebMenuItemInfo::SubMenu) { |
+ strings.push_back(prefix + customItems[i].label.utf8() + kSubMenuIdentifier); |
tkent
2014/08/05 09:08:45
wrap in 80 columns
pals
2014/08/05 09:17:29
Done.
|
+ PopulateCustomItems(customItems[i].subMenuItems, strings, prefix + kSubMenuDepthIdentifier); |
tkent
2014/08/05 09:08:45
Ditto.
pals
2014/08/05 09:17:29
Done.
|
+ } else { |
+ strings.push_back(prefix + customItems[i].label.utf8()); |
+ } |
+ } |
+} |
+ |
// Because actual context menu is implemented by the browser side, |
// this function does only what LayoutTests are expecting: |
// - Many test checks the count of items. So returning non-zero value makes |
@@ -172,6 +187,9 @@ std::vector<std::string> MakeMenuItemStringsFor( |
std::vector<std::string> strings; |
+ // Populate custom menu items if provided by the blink internals. |
tkent
2014/08/05 09:08:45
nit: |by the blink internals.| -> |by Blink.|
pals
2014/08/05 09:17:29
Done.
|
+ PopulateCustomItems(context_menu->customItems, strings, ""); |
+ |
if (context_menu->isEditable) { |
for (const char** item = kEditableMenuStrings; *item; ++item) { |
strings.push_back(*item); |