Bug 1319237 - Make GeckoDriver#setWindowSize synchronous; r?automatedtester draft
authorAndreas Tolfsen <ato@mozilla.com>
Mon, 21 Nov 2016 23:44:22 +0100
changeset 442943 efd85759eb7fe47035492782bb405b2472802081
parent 442942 87f9a058ec1e24a077ae48158024816f581b85d1
child 537941 718e105ee4c16cac7617afa347605af28b94a274
push id36873
push userbmo:ato@mozilla.com
push dateWed, 23 Nov 2016 16:03:30 +0000
reviewersautomatedtester
bugs1319237
milestone53.0a1
Bug 1319237 - Make GeckoDriver#setWindowSize synchronous; r?automatedtester Return from the Set Window Size command only after the window resize DOM event has occurred. MozReview-Commit-ID: 7ygZuNJZzq2
testing/marionette/driver.js
--- a/testing/marionette/driver.js
+++ b/testing/marionette/driver.js
@@ -2472,25 +2472,32 @@ GeckoDriver.prototype.getWindowSize = fu
 
 /**
  * Set the size of the browser window currently in focus.
  *
  * Not supported on B2G. The supplied width and height values refer to
  * the window outerWidth and outerHeight values, which include scroll
  * bars, title bars, etc.
  */
-GeckoDriver.prototype.setWindowSize = function(cmd, resp) {
+GeckoDriver.prototype.setWindowSize = function*(cmd, resp) {
   if (this.appName != "Firefox") {
     throw new UnsupportedOperationError();
   }
 
   let {width, height} = cmd.parameters;
+
   let win = this.getCurrentWindow();
-  win.resizeTo(width, height);
-  this.getWindowSize(cmd, resp);
+  yield new Promise(resolve => {
+    win.addEventListener("resize", resolve, {once: true});
+    win.resizeTo(width, height);
+  });
+  return {
+    width: win.outerWidth,
+    height: win.outerHeight,
+  };
 };
 
 /**
  * Maximizes the user agent window as if the user pressed the maximise
  * button.
  *
  * Not Supported on B2G or Fennec.
  */