Bug 1489700 - allow window positioning to be asynchronous, r=jgraham
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 12 Sep 2018 12:23:51 +0000
changeset 436046 8675ff71202cb14c8ff3d7138d8166ff5870b5cb
parent 436045 a66a85285cb09523916bc95e30a42056b798e935
child 436047 ec5fe5d123b1baac235d978858c5226f7c8d9ed0
push id34625
push userdvarga@mozilla.com
push dateThu, 13 Sep 2018 02:31:40 +0000
treeherdermozilla-central@51e9e9660b3e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgraham
bugs1489700
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1489700 - allow window positioning to be asynchronous, r=jgraham Differential Revision: https://phabricator.services.mozilla.com/D5666
testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/resources/message-opener.html
--- a/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/resources/message-opener.html
+++ b/testing/web-platform/tests/html/browsers/the-window-object/apis-for-creating-and-navigating-browsing-contexts-by-name/resources/message-opener.html
@@ -1,12 +1,22 @@
 <script src="/common/PrefixedPostMessage.js"></script>
 <script>
 var prefixedMessage = new PrefixedMessageResource();
-window.addEventListener('load', () => {
+var max = 50, attempts = 0;
+function sendCoordinates() {
+  // Certain windowing systems position windows asynchronously.
+  // As a result, the window may not be positioned yet when the
+  // load event fires. To accommodate this, allow waiting up to
+  // 5 seconds for positioning to take place.
+  if (!window.screenX && !window.screenY && ++attempts < max) {
+    setTimeout(sendCoordinates, 100);
+    return;
+  }
   prefixedMessage.postToOpener({
     left: window.screenX,
     top: window.screenY,
     width: window.innerWidth,
     height: window.innerHeight
   });
-});
+}
+window.addEventListener('load', sendCoordinates);
 </script>