- Electron version: 1.2.8
- Operating system: Windows

Hi,

I've been trying to get a context menu containing some [predefined web contents roles](https://github.com/electron/electron/blob/master/lib/browser/api/menu-item-roles.js#L17) working for an application where we have multiple windows simultaneously. I've noticed that when a context menu is opened for a window that was created later than others, the role commands don't seem to execute when clicked. However, if don't use a role and instead define a click handler that calls the command on the web contents manually, it behaves normally.

I've been doing some digging and it seems that the reason is because, for a role, [`electron.webContents.getFocusedWebContents`](https://github.com/electron/electron/blob/master/lib/browser/api/web-contents.js#L257) is used to determine which web contents to call the command on (see [menu.js](https://github.com/electron/electron/blob/master/lib/browser/api/menu.js#L121)).

This function iterates through all existing web contents, then returns the first in the collection that is in a `webview`, otherwise the first that returns `true` from `contents.isFocused()`. However, it seems to be entirely possible that there are web contents other than the one that the context menu was raised for, who think they are focused (or perhaps are within a `webview`), and who were created earlier and therefore appear earlier in the collection.

This means there are situations when the 'wrong' web contents is returned from `getFocusedWebContents`, and therefore the role command is called on that 'wrong' web contents, which leads to the unexpected behaviour described above.

Is this a bug? And if so, is there a fix and/or workaround for this? I'm happy to contribute a PR if needed.

atom/browser/api/atom_api_web_contents.cc
auto view = web_contents()->GetRenderWidgetHostView();
  return view && view->HasFocus();
}
#endif
void WebContents::TabTraverse(bool reverse) {
  web_contents()->FocusThroughTabTraversal(reverse);
}
bool WebContents::SendIPCMessage(bool all_frames,
                                 const base::string16& channel,
                                 const base::ListValue& args) {
  return Send(new AtomViewMsg_Message(routing_id(), all_frames, channel, args));
}
void WebContents::SendInputEvent(v8::Isolate* isolate,
                                 v8::Local<v8::Value> input_event) {
  const auto view = web_contents()->GetRenderWidgetHostView();
  if (!view)
    return;
  const auto host = view->GetRenderWidgetHost();
  if (!host)
    return;
  int type = mate::GetWebInputEventType(isolate, input_event);
  if (blink::WebInputEvent::isMouseEventType(type)) {
    blink::WebMouseEvent mouse_event;
    if (mate::ConvertFromV8(isolate, input_event, &mouse_event)) {
      host->ForwardMouseEvent(mouse_event);
      return;
    }
  } else if (blink::WebInputEvent::isKeyboardEventType(type)) {
    content::NativeWebKeyboardEvent keyboard_event;