Bug 1415781 part 2 - Make test_display_mode tests wait for the next tick before synthesizing F11 key press. r?heycam draft
authorXidorn Quan <me@upsuper.org>
Thu, 21 Dec 2017 11:53:18 +1100
changeset 719350 60ffa1b2c34d714c9bb87555150ddb1fdfec8e8c
parent 719349 04d953f1be992b2b73b07900853be2db23d0b0fb
child 719419 58a004548359314a788b8c14cf854418f1fb7471
push id95231
push userxquan@mozilla.com
push dateFri, 12 Jan 2018 01:21:05 +0000
reviewersheycam
bugs1415781
milestone59.0a1
Bug 1415781 part 2 - Make test_display_mode tests wait for the next tick before synthesizing F11 key press. r?heycam MozReview-Commit-ID: 12k7zRHw77F
layout/style/test/chrome/test_display_mode.html
layout/style/test/chrome/test_display_mode_reflow.html
--- a/layout/style/test/chrome/test_display_mode.html
+++ b/layout/style/test/chrome/test_display_mode.html
@@ -20,16 +20,20 @@ Components.utils.import("resource://gre/
 function waitOneEvent(element, name) {
   return new Promise(function(resolve, reject) {
     element.addEventListener(name, function() {
       resolve();
     }, {once: true});
   });
 }
 
+function promiseNextTick() {
+  return new Promise(resolve => setTimeout(resolve, 0));
+}
+
 add_task(async function() {
   await waitOneEvent(window, "load");
 
   var iframe = document.getElementById("subdoc");
   var subdoc = iframe.contentDocument;
   var style = subdoc.getElementById("style");
   var bodyComputedStyled = subdoc.defaultView.getComputedStyle(subdoc.body);
   var win = Services.wm.getMostRecentWindow("navigator:browser");
@@ -55,21 +59,25 @@ add_task(async function() {
 
   shouldApply("all and (display-mode: browser)");
   shouldNotApply("all and (display-mode: fullscreen)");
   shouldNotApply("all and (display-mode: standalone)");
   shouldNotApply("all and (display-mode: minimal-ui)");
 
   // Test entering the OS's fullscreen mode.
   var fullScreenEntered = waitOneEvent(win, "sizemodechange");
+  await promiseNextTick();
   synthesizeKey("VK_F11", {});
   await fullScreenEntered;
   shouldApply("all and (display-mode: fullscreen)");
   shouldNotApply("all and (display-mode: browser)");
   var fullScreenExited = waitOneEvent(win, "sizemodechange");
+  // Need to wait for the next tick to to avoid nested fullscreen change
+  // in different direction. See bug 1415781.
+  await promiseNextTick();
   synthesizeKey("VK_F11", {});
   await fullScreenExited;
   shouldNotApply("all and (display-mode: fullscreen)");
   shouldApply("all and (display-mode: browser)");
 
   // Test entering fullscreen through document requestFullScreen.
   fullScreenEntered = waitOneEvent(document, "mozfullscreenchange");
   document.body.mozRequestFullScreen();
--- a/layout/style/test/chrome/test_display_mode_reflow.html
+++ b/layout/style/test/chrome/test_display_mode_reflow.html
@@ -20,34 +20,42 @@ Components.utils.import("resource://gre/
 function waitOneEvent(element, name) {
   return new Promise(function(resolve, reject) {
     element.addEventListener(name, function() {
       resolve();
     }, {once: true});
   });
 }
 
+function promiseNextTick() {
+  return new Promise(resolve => setTimeout(resolve, 0));
+}
+
 add_task(async function() {
   await waitOneEvent(window, "load");
 
   var iframe = document.getElementById("subdoc");
   var subdoc = iframe.contentDocument;
   var style = subdoc.getElementById("style");
   var bodyComputedStyled = subdoc.defaultView.getComputedStyle(subdoc.body);
   var win = Services.wm.getMostRecentWindow("navigator:browser");
 
   var secondDiv = subdoc.getElementById("b");
   var offsetTop = secondDiv.offsetTop;
 
   // Test entering the OS's fullscreen mode.
   var fullScreenEntered = waitOneEvent(win, "sizemodechange");
+  await promiseNextTick();
   synthesizeKey("VK_F11", {});
   await fullScreenEntered;
   ok(offsetTop !== secondDiv.offsetTop, "offset top changes");
   var fullScreenExited = waitOneEvent(win, "sizemodechange");
+  // Need to wait for the next tick to to avoid nested fullscreen change
+  // in different direction. See bug 1415781.
+  await promiseNextTick();
   synthesizeKey("VK_F11", {});
   await fullScreenExited;
   ok(offsetTop === secondDiv.offsetTop, "offset top returns to original value");
 
   offsetTop = secondDiv.offsetTop;
   // Test entering fullscreen through document requestFullScreen.
   fullScreenEntered = waitOneEvent(document, "mozfullscreenchange");
   document.body.mozRequestFullScreen();