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

--HG--
extra : rebase_source : c01ec64a9a819cad8fcf721eb6c6b882d616e872
This commit is contained in:
Xidorn Quan 2017-12-21 11:53:18 +11:00
Родитель 153c970007
Коммит dd155c0445
2 изменённых файлов: 16 добавлений и 0 удалений

Просмотреть файл

@ -25,6 +25,10 @@ function waitOneEvent(element, name) {
});
}
function promiseNextTick() {
return new Promise(resolve => setTimeout(resolve, 0));
}
add_task(async function() {
await waitOneEvent(window, "load");
@ -60,11 +64,15 @@ add_task(async function() {
// 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)");

Просмотреть файл

@ -25,6 +25,10 @@ function waitOneEvent(element, name) {
});
}
function promiseNextTick() {
return new Promise(resolve => setTimeout(resolve, 0));
}
add_task(async function() {
await waitOneEvent(window, "load");
@ -39,10 +43,14 @@ add_task(async function() {
// 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");