1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
6 * Enum for modifier keys, same as DevTools protocol.
17 * Dispatches a context menu event at the given location.
19 * @param {number} x The X coordinate to dispatch the event at.
20 * @param {number} y The Y coordinate to dispatch the event at.
21 * @param {modifiers} modifiers The modifiers to use for the event.
23 function dispatchContextMenuEvent(x
, y
, modifiers
) {
24 var event
= new MouseEvent(
33 ctrlKey
: modifiers
& ModifierMask
.CTRL
,
34 altKey
: modifiers
& ModifierMask
.ALT
,
35 shiftKey
: modifiers
& ModifierMask
.SHIFT
,
36 metaKey
: modifiers
& ModifierMask
.META
,
39 var elem
= document
.elementFromPoint(x
, y
);
41 throw new Error('cannot right click outside the visible bounds of the ' +
42 'document: (' + x
+ ', ' + y
+ ')');
44 elem
.dispatchEvent(event
);