Commit 0516fde4 authored by Karl Tomlinson's avatar Karl Tomlinson
Browse files

Bug 1727653 - wait for resize event before testing restoration of persisted...

Bug 1727653 - wait for resize event before testing restoration of persisted sizes. r=niklas, a=RyanVM

Differential Revision: https://phabricator.services.mozilla.com/D149329
parent 489ac60e
......@@ -25,15 +25,22 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1460639
});
}
function resize(win, size) {
let resizePromise = new Promise(resolve => {
if (win.outerWidth === size && win.outerHeight === size) {
function promiseMaybeResizeEvent(win, expectedSize) {
return new Promise(resolve => {
// If the size is already as expected, then there may be no resize
// event.
if (win.outerWidth === expectedSize
&& win.outerHeight === expectedSize) {
resolve();
}
win.addEventListener("resize", () => {
resolve();
}, {once: true});
});
}
function resize(win, size) {
const resizePromise = promiseMaybeResizeEvent(win, size);
win.resizeTo(size, size);
return resizePromise;
}
......@@ -60,6 +67,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1460639
isnot(win.outerHeight, PERSIST_SIZE, "Initial window height is not the persisted size");
await navigateWindowTo(win, "window_navigate_persist.html");
await promiseMaybeResizeEvent(win, PERSIST_SIZE);
is(win.outerWidth, PERSIST_SIZE, "Window width is persisted");
is(win.outerHeight, PERSIST_SIZE, "Window height is persisted");
win.close();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment