Bug 1430380 - Wait for the next tick after sizemodechange event to apply media feature changes. r?xidorn
On Linux, media feature changes is processed after dispatching sizemodechange
event, so we need to wait for the next tick before checking style changes that
caused by the media feature changes.
MozReview-Commit-ID: 2kb0kToXA6e
--- a/layout/style/test/chrome/test_display_mode.html
+++ b/layout/style/test/chrome/test_display_mode.html
@@ -59,27 +59,27 @@ 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;
+ // Wait for the next tick to apply media feature changes. See bug 1430380.
+ await promiseNextTick();
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;
+ // Wait for the next tick to apply media feature changes. See bug 1430380.
+ await promiseNextTick();
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();
await fullScreenEntered
ok(document.mozFullScreenElement, "window entered fullscreen");
--- a/layout/style/test/chrome/test_display_mode_reflow.html
+++ b/layout/style/test/chrome/test_display_mode_reflow.html
@@ -38,26 +38,28 @@ add_task(async function() {
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;
+
+ // Wait for the next tick to apply media feature changes. See bug 1430380.
+ await promiseNextTick();
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;
+
+ // Wait for the next tick to apply media feature changes. See bug 1430380.
+ await promiseNextTick();
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();
await fullScreenEntered
ok(offsetTop !== secondDiv.offsetTop, "offset top changes");