mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1212811 - focused_chrome_window_handle() should wait until focus transition has been finished. r=maja_zf, a=test-only
MozReview-Commit-ID: JXKYAez1PNV Lets make sure that we do not return a focused chrome window handle if a focus transition event is currently happening. In such a case the chrome window handle would be `None`.
This commit is contained in:
parent
ed6cbabb48
commit
ed1d065319
@ -42,24 +42,27 @@ class Windows(BaseLib):
|
||||
def focused_chrome_window_handle(self):
|
||||
"""Returns the currently focused chrome window handle.
|
||||
|
||||
In case of `None` being returned no window is currently active. This can happen
|
||||
when a new window is opened and the currently focused one gets lowered.
|
||||
|
||||
:returns: The `window handle` of the focused chrome window.
|
||||
"""
|
||||
with self.marionette.using_context('chrome'):
|
||||
return self.marionette.execute_script("""
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
def get_active_handle(mn):
|
||||
with self.marionette.using_context('chrome'):
|
||||
return self.marionette.execute_script("""
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
let win = Services.focus.activeWindow;
|
||||
if (win) {
|
||||
return win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils)
|
||||
.outerWindowID.toString();
|
||||
}
|
||||
let win = Services.focus.activeWindow;
|
||||
if (win) {
|
||||
return win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.getInterface(Components.interfaces.nsIDOMWindowUtils)
|
||||
.outerWindowID.toString();
|
||||
}
|
||||
|
||||
return null;
|
||||
""")
|
||||
return null;
|
||||
""")
|
||||
|
||||
# In case of `None` being returned no window is currently active. This can happen
|
||||
# when a focus change action is currently happening. So lets wait until it is done.
|
||||
return Wait(self.marionette).until(get_active_handle,
|
||||
message='No focused window has been found.')
|
||||
|
||||
def close(self, handle):
|
||||
"""Closes the chrome window with the given handle.
|
||||
|
Loading…
Reference in New Issue
Block a user