Bug 1555511 Part 3: Refactor viewport resize test helper functions. r=botond

Differential Revision: https://phabricator.services.mozilla.com/D33362

--HG--
extra : rebase_source : 17a93bbbac7f70f15e3f0ab99005ba2da5dd11d9
extra : source : 8c6e5561abed4b92ab1e722bf24a19b2152e3720
This commit is contained in:
Brad Werth 2019-06-04 22:25:08 +00:00
Родитель 80409f33ea
Коммит 8cac9e2706
4 изменённых файлов: 39 добавлений и 72 удалений

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

@ -5,36 +5,6 @@
// Test viewport resizing, with and without meta viewport support.
// We call this to switch between on/off support for meta viewports.
async function setTouchAndMetaViewportSupport(ui, value) {
const reloadNeeded = await ui.updateTouchSimulation(value);
if (reloadNeeded) {
info("Reload is needed -- waiting for it.");
const reload = waitForViewportLoad(ui);
const browser = ui.getViewportBrowser();
browser.reload();
await reload;
}
}
// This function check that zoom, layout viewport width and height
// are all as expected.
async function testViewportZoomWidthAndHeight(message, ui, zoom, width, height) {
const resolution = await spawnViewportTask(ui, {}, function() {
return content.windowUtils.getResolution();
});
is(resolution, zoom, message + " should have expected zoom.");
const layoutSize = await spawnViewportTask(ui, {}, function() {
return {
width: content.screen.width,
height: content.screen.height,
};
});
is(layoutSize.width, width, message + " should have expected layout width.");
is(layoutSize.height, height, message + " should have expected layout height.");
}
const TEST_URL = "data:text/html;charset=utf-8," +
"<head><meta name=\"viewport\" content=\"width=300\"/></head>" +
"<body>meta viewport width 300</body>";

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

@ -5,36 +5,6 @@
// Test viewport resizing, with and without meta viewport support.
// We call this to switch between on/off support for meta viewports.
async function setTouchAndMetaViewportSupport(ui, value) {
const reloadNeeded = await ui.updateTouchSimulation(value);
if (reloadNeeded) {
info("Reload is needed -- waiting for it.");
const reload = waitForViewportLoad(ui);
const browser = ui.getViewportBrowser();
browser.reload();
await reload;
}
}
// This function check that zoom, layout viewport width and height
// are all as expected.
async function testViewportZoomWidthAndHeight(message, ui, zoom, width, height) {
const resolution = await spawnViewportTask(ui, {}, function() {
return content.windowUtils.getResolution();
});
is(resolution, zoom, message + " should have expected zoom.");
const layoutSize = await spawnViewportTask(ui, {}, function() {
return {
width: content.screen.width,
height: content.screen.height,
};
});
is(layoutSize.width, width, message + " should have expected layout width.");
is(layoutSize.height, height, message + " should have expected layout height.");
}
const TEST_URL = "data:text/html;charset=utf-8," +
"<head><meta name=\"viewport\" content=\"width=device-width, " +
"initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0\"></head>" +

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

@ -9,18 +9,6 @@
Services.scriptloader.loadSubScript(
"chrome://mochikit/content/tests/SimpleTest/WindowSnapshot.js", this);
// We call this to switch between on/off support for meta viewports.
async function setTouchAndMetaViewportSupport(ui, value) {
const reloadNeeded = await ui.updateTouchSimulation(value);
if (reloadNeeded) {
info("Reload is needed -- waiting for it.");
const reload = waitForViewportLoad(ui);
const browser = ui.getViewportBrowser();
browser.reload();
await reload;
}
}
// The quest for a TEST_ROOT: we have to choose a way of addressing the RDM document
// such that two things can happen:
// 1) addRDMTask can load it.

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

@ -565,3 +565,42 @@ function rotateViewport(ui) {
const rotateButton = document.getElementById("rotate-button");
rotateButton.click();
}
// Call this to switch between on/off support for meta viewports.
async function setTouchAndMetaViewportSupport(ui, value) {
const reloadNeeded = await ui.updateTouchSimulation(value);
if (reloadNeeded) {
info("Reload is needed -- waiting for it.");
const reload = waitForViewportLoad(ui);
const browser = ui.getViewportBrowser();
browser.reload();
await reload;
}
return reloadNeeded;
}
// This function checks that zoom, layout viewport width and height
// are all as expected.
async function testViewportZoomWidthAndHeight(message, ui, zoom, width, height) {
if (typeof zoom !== "undefined") {
const resolution = await spawnViewportTask(ui, {}, function() {
return content.windowUtils.getResolution();
});
is(resolution, zoom, message + " should have expected zoom.");
}
if (typeof width !== "undefined" || typeof height !== "undefined") {
const layoutSize = await spawnViewportTask(ui, {}, function() {
return {
width: content.screen.width,
height: content.screen.height,
};
});
if (typeof width !== "undefined") {
is(layoutSize.width, width, message + " should have expected layout width.");
}
if (typeof height !== "undefined") {
is(layoutSize.height, height, message + " should have expected layout height.");
}
}
}