mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 15:23:51 +00:00
Bug 1069572: Add maximise_window() to Marionette to allow maximising the browser window; r=jgriffin
This commit is contained in:
parent
f112480895
commit
cd46869ea2
@ -1560,3 +1560,10 @@ class Marionette(object):
|
||||
|
||||
"""
|
||||
self._send_message("setWindowSize", "ok", width=width, height=height)
|
||||
|
||||
def maximize_window(self):
|
||||
""" Resize the browser window currently receiving commands. The action
|
||||
should be equivalent to the user pressing the the maximize button
|
||||
"""
|
||||
|
||||
return self._send_message("maximizeWindow", "ok")
|
||||
|
@ -53,3 +53,23 @@ class TestSetWindowSize(MarionetteTestCase):
|
||||
size = self.marionette.window_size
|
||||
self.assertEqual(size['width'], width, "Window width should not have changed")
|
||||
self.assertEqual(size['height'], height, "Window height should not have changed")
|
||||
|
||||
def test_that_we_can_maximise_the_window(self):
|
||||
# valid size
|
||||
width = self.max_width - 100
|
||||
height = self.max_height - 100
|
||||
self.marionette.set_window_size(width, height)
|
||||
|
||||
# event handler
|
||||
self.marionette.execute_script("""
|
||||
window.wrappedJSObject.rcvd_event = false;
|
||||
window.onresize = function() {
|
||||
window.wrappedJSObject.rcvd_event = true;
|
||||
};
|
||||
""")
|
||||
self.marionette.maximize_window()
|
||||
self.wait_for_condition(lambda m: m.execute_script("return window.wrappedJSObject.rcvd_event;"))
|
||||
|
||||
size = self.marionette.window_size
|
||||
self.assertEqual(size['width'], self.max_width, "Window width does not use availWidth")
|
||||
self.assertEqual(size['height'], self.max_height, "Window height does not use availHeight")
|
||||
|
@ -2444,6 +2444,25 @@ MarionetteServerConnection.prototype = {
|
||||
this.sendOk(this.command_id);
|
||||
},
|
||||
|
||||
/**
|
||||
* Maximizes the Browser Window as if the user pressed the maximise button
|
||||
*
|
||||
* Not Supported on B2G or Fennec
|
||||
*/
|
||||
maximizeWindow: function MDA_maximizeWindow (aRequest) {
|
||||
this.command_id = this.getCommandId();
|
||||
|
||||
if (appName !== "Firefox") {
|
||||
this.sendError("Not supported for mobile", 405, null, this.command_id);
|
||||
return;
|
||||
}
|
||||
|
||||
let curWindow = this.getCurrentWindow();
|
||||
curWindow.moveTo(0,0);
|
||||
curWindow.resizeTo(curWindow.screen.availWidth, curWindow.screen.availHeight);
|
||||
this.sendOk(this.command_id);
|
||||
},
|
||||
|
||||
/**
|
||||
* Helper function to convert an outerWindowID into a UID that Marionette
|
||||
* tracks.
|
||||
@ -2653,7 +2672,8 @@ MarionetteServerConnection.prototype.requestTypes = {
|
||||
"getScreenOrientation": MarionetteServerConnection.prototype.getScreenOrientation,
|
||||
"setScreenOrientation": MarionetteServerConnection.prototype.setScreenOrientation,
|
||||
"getWindowSize": MarionetteServerConnection.prototype.getWindowSize,
|
||||
"setWindowSize": MarionetteServerConnection.prototype.setWindowSize
|
||||
"setWindowSize": MarionetteServerConnection.prototype.setWindowSize,
|
||||
"maximizeWindow": MarionetteServerConnection.prototype.maximizeWindow
|
||||
};
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user