[chromium-dev] Re: Access to window handles from plugins?
This is something along the lines of calling IWebBrowser2.get_HWND or (more similarly) using XPCOM's nsIAccessibleDocument-GetWindowHandle () calls: http://msdn.microsoft.com/en-us/library/aa454384.aspx https://developer.mozilla.org/En/NsIAccessibleDocument/windowHandle Both of these provide a mechanism to get a native window handle. The reason for needing this is that webdriver pumps native events to the given HWND, allowing it to closely emulate user behaviour (certainly more closely than doing the same thing by synthesizing events on the DOM) By sending the events to the HWND, it avoids requiring the browser window to have focus. Since webdriver tests tend to run for a long time, it's useful to allow users to do something else with their computer as they run. Regards, Simon On Jul 17, 7:55 pm, John Abd-El-Malek j...@chromium.org wrote: On Fri, Jul 17, 2009 at 10:45 AM, Daniel Wagner-Hall dawag...@gmail.comwrote: Hi, Can anyone help me with this? How can I get the window handle of an element from its JS DOM node? DOM elements, with the exception of plugins and select controls, don't have window handles because they're not implemented as native controls (otherwise we'd run out of OS handles on some pages). Are you asking specifically about a plugin node? Perhaps a little background might help! I'm currently working on WebDriver, a browser testing automation tool[1], to add Chrome support. As suggested by the chrome team, this is being written as an extension with an embedded NPAPI plugin. The original driver worked with the AutomationProxy, but this is not available in release binaries, which means that a user would need to compile a custom version of Chrome; obviously a less than ideal user experience :) We use a native interactions library for sending keys/clicks/etc at the OS level, which requires a window handle to the window containing the element to do its thing. This library is shared between all the drivers for a particular platform (at the moment, only Windows, but X support is coming soon). Thanks, Daniel Wagner-Hall 1:http://code.google.com/p/webdriver/ --~--~-~--~~~---~--~~ Chromium Developers mailing list: chromium-dev@googlegroups.com View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~--~~~~--~~--~--~---
[chromium-dev] Re: Access to window handles from plugins?
On Fri, Jul 17, 2009 at 10:45 AM, Daniel Wagner-Hall dawag...@gmail.comwrote: Hi, Can anyone help me with this? How can I get the window handle of an element from its JS DOM node? DOM elements, with the exception of plugins and select controls, don't have window handles because they're not implemented as native controls (otherwise we'd run out of OS handles on some pages). Are you asking specifically about a plugin node? Perhaps a little background might help! I'm currently working on WebDriver, a browser testing automation tool[1], to add Chrome support. As suggested by the chrome team, this is being written as an extension with an embedded NPAPI plugin. The original driver worked with the AutomationProxy, but this is not available in release binaries, which means that a user would need to compile a custom version of Chrome; obviously a less than ideal user experience :) We use a native interactions library for sending keys/clicks/etc at the OS level, which requires a window handle to the window containing the element to do its thing. This library is shared between all the drivers for a particular platform (at the moment, only Windows, but X support is coming soon). Thanks, Daniel Wagner-Hall 1: http://code.google.com/p/webdriver/ --~--~-~--~~~---~--~~ Chromium Developers mailing list: chromium-dev@googlegroups.com View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~--~~~~--~~--~--~---
[chromium-dev] Re: Access to window handles from plugins?
On Fri, Jul 17, 2009 at 5:45 PM, Daniel Wagner-Halldawag...@gmail.com wrote: Can anyone help me with this? How can I get the window handle of an element from its JS DOM node? Perhaps a little background might help! I'm currently working on WebDriver, a browser testing automation tool[1], to add Chrome support. As suggested by the chrome team, this is being written as an extension with an embedded NPAPI plugin. The original driver worked with the AutomationProxy, but this is not available in release binaries, which means that a user would need to compile a custom version of Chrome; obviously a less than ideal user experience :) We use a native interactions library for sending keys/clicks/etc at the OS level, which requires a window handle to the window containing the element to do its thing. This library is shared between all the drivers for a particular platform (at the moment, only Windows, but X support is coming soon). John would have a more definite answer, but my understanding is: - all content aside from windowed plugins use one OS-level window, wrapping the page - NPAPI has no API for querying for that window Windowed plugins do get a parent window from the SetWindow call of NPAPI. You could imagine walking the window hierarchy upwards to figure that out, but it's surely fragile. On different browsers I expect that to be a window arbitrarily below the outer window described above. Even within Chrome it's different: On Windows the nesting is one extra window in the plugin process, then one more in the browser process, and there's an extra dummy window used in some circumstances I don't quite understand. On Linux there's just one extra wrapping window browser-side. --~--~-~--~~~---~--~~ Chromium Developers mailing list: chromium-dev@googlegroups.com View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~--~~~~--~~--~--~---
[chromium-dev] Re: Access to window handles from plugins?
I can happily get the plugin's window handle using standard NPAPI calls, I'm trying to get the window handle of arbitrary tabs (and indeed frames) which my extension has loaded Specifically, I am opening pages, at the moment using window.open in the background page (though this may change to something slightly more clean, I haven't really considered what/how yet), and manipulating them with Javascript (e.g. grabbing their title). I can interact with them through Javascript from the background page, but would like to be able to generate native OS events to the window handle of the windows/tabs which I open... From my experimenting with Spy++ and the results of NPAPI SetWindow calls, the HWND returned for the plugin has no parent which can be conveniently used, though there may be some clever scheme used which I'm just not seeing by not knowing how things really work. --~--~-~--~~~---~--~~ Chromium Developers mailing list: chromium-dev@googlegroups.com View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~--~~~~--~~--~--~---
[chromium-dev] Re: Access to window handles from plugins?
On Fri, Jul 17, 2009 at 7:06 PM, Daniel Wagner-Halldawag...@gmail.com wrote: From my experimenting with Spy++ and the results of NPAPI SetWindow calls, the HWND returned for the plugin has no parent which can be conveniently used, though there may be some clever scheme used which I'm just not seeing by not knowing how things really work. As I was trying to describe earlier, it's not so much the parent as it is the great-grandparent. If you are willing to write something fragile I think that's your best bet. One trick that might help is that we set a window title (::SetWindowText()) on the window containing the page, while all of the windows in between don't have one. Here's an xwininfo -tree snippet on Linux with one plugin: xwininfo: Window id: 0x31e file:///work/chrome/src/webkit/data/test_shell/plugins/embed4.htm - Chromium Root window id: 0x13b (the root window) (has no name) Parent window id: 0x147981d (has no name) 8 children: 0x344 (has no name): () 617x519+0+93 +515+384 4 children: 0x3000398 (has no name): () 296x21+0+667 +515+1051 1 child: 0x3000399 (has no name): () 294x19+1+1 +516+1052 0x3000176 test_shell home: () 617x518+0+1 +515+385 1 child: 0x30004c9 (has no name): () 300x300+8+71 +523+456 1 child: 0x343 chrome: (chrome Chrome) 300x300+0+0 +523+456 2 children: 0x340001e (has no name): () 300x300+0+0 +523+456 0x344 (has no name): () 1x1+-1+-1 +522+455 0x30004c9 is the window that was passed to NPAPI's SetWindow, and 0x3000176 (which has the page title test_shell home) is the one that contains the page. But the general answer to your question remains: no, there's no non-fragile way of doing this. --~--~-~--~~~---~--~~ Chromium Developers mailing list: chromium-dev@googlegroups.com View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~--~~~~--~~--~--~---
[chromium-dev] Re: Access to window handles from plugins?
On Fri, Jul 17, 2009 at 12:06 PM, Daniel Wagner-Hall dawag...@gmail.comwrote: I can happily get the plugin's window handle using standard NPAPI calls, I'm trying to get the window handle of arbitrary tabs (and indeed frames) which my extension has loaded Specifically, I am opening pages, at the moment using window.open in the background page (though this may change to something slightly more clean, I haven't really considered what/how yet), and manipulating them with Javascript (e.g. grabbing their title). I can interact with them through Javascript from the background page, but would like to be able to generate native OS events to the window handle of the windows/tabs which I open... From my experimenting with Spy++ and the results of NPAPI SetWindow calls, the HWND returned for the plugin has no parent which can be conveniently used, though there may be some clever scheme used which I'm just not seeing by not knowing how things really work. This wouldn't be robust, as Chrome has switched the window hierarchy in the past and it might occur again in the future (even to the extreme of that plugin window not having a parent). What you probably want to do is call NPN_GetValue on NPNVnetscapeWindow to get the HWND of the page where the calling plugin is hosted. To get the HWND of other windows that you open, you can embed a plugin instance in them, and script them using JS which ends up calling into binary code, which then calls NPN_GetValue. --~--~-~--~~~---~--~~ Chromium Developers mailing list: chromium-dev@googlegroups.com View archives, change email options, or unsubscribe: http://groups.google.com/group/chromium-dev -~--~~~~--~~--~--~---