Backed out 4 changesets (bug 1555511) for failing at browser_viewport_resizing_minimum_scale.js

Backed out changeset 6988b151bbe7 (bug 1555511)
Backed out changeset aa1c32a38785 (bug 1555511)
Backed out changeset 999f3af17edf (bug 1555511)
Backed out changeset 1069871269f7 (bug 1555511)
This commit is contained in:
Gurzau Raul 2019-06-03 03:25:58 +03:00
Родитель 1ba1047f8f
Коммит aea781583c
7 изменённых файлов: 101 добавлений и 144 удалений

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

@ -81,7 +81,6 @@ fail-if = true # Bug 1547783
[browser_viewport_basics.js]
[browser_viewport_resizing_fixed_width.js]
[browser_viewport_resizing_fixed_width_and_zoom.js]
[browser_viewport_resizing_minimum_scale.js]
[browser_viewport_resizing_scrollbar.js]
fail-if = true # Bug 1547101
[browser_window_close.js]

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

@ -5,6 +5,36 @@
// 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,6 +5,36 @@
// 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>" +

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

@ -1,73 +0,0 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
// Test viewport resizing, with and without meta viewport support.
const TEST_URL = "data:text/html;charset=utf-8," +
"<head><meta name=\"viewport\" content=\"initial-scale=1.0, " +
"minimum-scale=1.0\"></head>" +
"<div style=\"width:100%;background-color:green\">test</div>" +
"</body>";
addRDMTask(TEST_URL, async function({ ui, manager }) {
// Turn on the pref that allows meta viewport support.
await SpecialPowers.pushPrefEnv({
set: [["devtools.responsive.metaViewport.enabled", true]],
});
const store = ui.toolWindow.store;
// Wait until the viewport has been added.
await waitUntilState(store, state => state.viewports.length == 1);
info("--- Starting viewport test output ---");
// We're going to take a 300,600 viewport (before) and resize it
// to 600,300 (after) and then resize it back. At the before and
// after points, we'll measure zoom and the layout viewport width
// and height.
const expected = [
{
before: {
zoom: 1.0,
width: 300,
height: 600,
},
after: {
zoom: 1.0,
width: 600,
height: 300,
},
},
];
for (const e of expected) {
const b = e.before;
const a = e.after;
const message = "Meta Viewport ON";
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, true);
// Get to the initial size and check values.
await setViewportSize(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui, b.zoom, b.width, b.height);
// Move to the smaller size.
await setViewportSize(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui, a.zoom, a.width, a.height);
// Go back to the initial size and check again.
await setViewportSize(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui, b.zoom, b.width, b.height);
}
});

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

@ -9,6 +9,18 @@
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,42 +565,3 @@ 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.");
}
}
}

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

@ -184,13 +184,13 @@ CSSToScreenScale MobileViewportManager::ClampZoom(
CSSToScreenScale MobileViewportManager::ScaleZoomWithDisplayWidth(
const CSSToScreenScale& aZoom, const float& aDisplayWidthChangeRatio,
const CSSSize& aNewViewport, const CSSSize& aOldViewport) {
float inverseCssWidthChangeRatio =
(aNewViewport.width == 0) ? 1.0f
: aOldViewport.width / aNewViewport.width;
CSSToScreenScale newZoom(aZoom.scale * aDisplayWidthChangeRatio *
inverseCssWidthChangeRatio);
MVM_LOG("%p: Old zoom was %f, changed by %f * %f to %f\n", this, aZoom.scale,
aDisplayWidthChangeRatio, inverseCssWidthChangeRatio, newZoom.scale);
float cssViewportChangeRatio = (aOldViewport.width == 0)
? 1.0f
: aNewViewport.width / aOldViewport.width;
CSSToScreenScale newZoom(aZoom.scale * aDisplayWidthChangeRatio /
cssViewportChangeRatio);
MVM_LOG("%p: Old zoom was %f, changed by %f/%f to %f\n", this, aZoom.scale,
aDisplayWidthChangeRatio, cssViewportChangeRatio, newZoom.scale);
return newZoom;
}
@ -295,14 +295,9 @@ void MobileViewportManager::UpdateResolution(
// result of clamping to either the minimum or maximum zoom level
// allowed by the viewport. If we naively scale the zoom level with
// the change in the display width, we might be scaling one of these
// previously clamped values. What we really want to do is to make
// scaling of the zoom aware of these minimum and maximum clamping
// points for the existing content size, so that we keep display
// width changes completely reversible.
// We don't consider here if we are scaling to a zoom value outside
// of our viewport limits, because we'll clamp to the viewport limits
// as a final step.
// clamped values. What we really want to do is to make scaling of the
// zoom aware of these minimum and maximum clamping points, so that we
// keep display width changes completely reversible.
// Because of the behavior of ShrinkToDisplaySizeIfNeeded, we are
// choosing zoom clamping points based on the content size of the
@ -330,7 +325,8 @@ void MobileViewportManager::UpdateResolution(
float c(oldDisplaySize.width);
float d(newDisplaySize.width);
// The oldDisplaySize value is in one of three "zones":
// For both oldDisplaySize and aDisplaySize, the values are in one of
// three "zones":
// 1) Less than or equal to minZoomDisplaySize.
// 2) Between minZoomDisplaySize and maxZoomDisplaySize.
// 3) Greater than or equal to maxZoomDisplaySize.
@ -338,24 +334,26 @@ void MobileViewportManager::UpdateResolution(
// Depending on which zone each are in, the adjusted ratio is shown in
// the table below (using the a-b-c-d coding from above):
// c +---+
// | d |
// 1 | a |
// +---+
// | d |
// 2 | c |
// +---+
// | d |
// 3 | b |
// +---+
// d | 1 | 2 | 3 |
// c +---+---+---+
// | a | d | b |
// 1 | a | a | a |
// +---+---+---+
// | a | d | b |
// 2 | c | c | c |
// +---+---+---+
// | a | d | b |
// 3 | b | b | b |
// +---+---+---+
// Conveniently, the denominator is c clamped to a..b.
// Conveniently, the numerator is just d clamped to a..b, and the
// denominator is c clamped to a..b.
float numerator = clamped(d, a, b);
float denominator = clamped(c, a, b);
float adjustedRatio = d / denominator;
CSSToScreenScale adjustedZoom = ScaleZoomWithDisplayWidth(
zoom, adjustedRatio, viewportSize, mMobileViewportSize);
newZoom = Some(ClampZoom(adjustedZoom, aViewportInfo));
float adjustedRatio = numerator / denominator;
newZoom = Some(ScaleZoomWithDisplayWidth(
zoom, adjustedRatio, viewportSize, mMobileViewportSize));
}
}
} else { // aType == UpdateType::ContentSize