Bug 1489700 - allow window positioning to be asynchronous, r=jgraham
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 12 Sep 2018 12:23:51 +0000
changeset 435896 60b86111e7f7
parent 435895 1b27177d4eef
child 435897 91fc6c048c07
push id69154
push usergijskruitbosch@gmail.com
push dateWed, 12 Sep 2018 13:59:49 +0000
treeherderautoland@60b86111e7f7 [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>