Programmatic context menu triggering from tests

43 views
Skip to first unread message

Chris Bentzel

unread,
Feb 2, 2012, 10:13:04 AM2/2/12
to chromium-dev
I'd like to write a browser_test which triggers a context menu on an image and chooses the "Save Image As" option.

Does any mechanism exist for this? 

I saw webkit/glue/context_menu_unittest, which simulates mouse events to trigger it, but am concerned that this will be fragile. For example, on Win we show the context menu at mouse up, but on Mac/Lin we show at mouse down. We'd also have to get the correct screen coordinates for the image, and I also want to choose a particular item from the list.

If nothing exists I'll try to figure out how to do this.


Greg Thompson

unread,
Feb 2, 2012, 10:22:30 AM2/2/12
to cben...@chromium.org, chromium-dev
For what it's worth, the Chrome Frame integration tests post button down/up events at the top-left corner of the window to get the context menu for the page:


I don't have any sage advice for how to get the coordinates of the image, or for how to do it in a nice cross-platform way.

Jochen Eisinger

unread,
Feb 2, 2012, 10:22:37 AM2/2/12
to cben...@chromium.org, chromium-dev
On Thu, Feb 2, 2012 at 4:13 PM, Chris Bentzel <cben...@chromium.org> wrote:
I'd like to write a browser_test which triggers a context menu on an image and chooses the "Save Image As" option.

Does any mechanism exist for this? 

In chrome/browser/extensions/extension_webnavigation_apitest.cc I create a fake (ui-less) context menu and trigger a command on it to test "open link in new tab"

hth
-jochen
 

I saw webkit/glue/context_menu_unittest, which simulates mouse events to trigger it, but am concerned that this will be fragile. For example, on Win we show the context menu at mouse up, but on Mac/Lin we show at mouse down. We'd also have to get the correct screen coordinates for the image, and I also want to choose a particular item from the list.

If nothing exists I'll try to figure out how to do this.


--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

Chris Bentzel

unread,
Feb 2, 2012, 10:23:51 AM2/2/12
to Jochen Eisinger, chromium-dev
On Thu, Feb 2, 2012 at 10:22 AM, Jochen Eisinger <joc...@chromium.org> wrote:


On Thu, Feb 2, 2012 at 4:13 PM, Chris Bentzel <cben...@chromium.org> wrote:
I'd like to write a browser_test which triggers a context menu on an image and chooses the "Save Image As" option.

Does any mechanism exist for this? 

In chrome/browser/extensions/extension_webnavigation_apitest.cc I create a fake (ui-less) context menu and trigger a command on it to test "open link in new tab"

Perfect, thanks.
Reply all
Reply to author
Forward
0 new messages