Bug 1585121 Part 9: Fix and activate RDM tests browser_v* through browser_z*. r=mtigley

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2020-03-02 22:56:19 +00:00
Родитель 70879323f1
Коммит d331c0080c
8 изменённых файлов: 373 добавлений и 374 удалений

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

@ -13,84 +13,83 @@ const TEST_URL =
'<div style="width:100%;height:1100px;background-color:lightblue"></div>' +
"</body>";
addRDMTask(TEST_URL, async function({ ui, manager }) {
const store = ui.toolWindow.store;
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
info("--- Starting viewport test output ---");
// Wait until the viewport has been added.
await waitUntilState(store, state => state.viewports.length == 1);
// We're going to take a 300,600 viewport (before), reload it,
// then 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 = [
{
metaSupport: false,
before: [1.0, 300, 600],
after: [1.0, 600, 300],
},
{
metaSupport: true,
before: [0.5, 300, 600],
after: [1.0, 600, 300],
},
];
info("--- Starting viewport test output ---");
for (const e of expected) {
const b = e.before;
const a = e.after;
// We're going to take a 300,600 viewport (before), reload it,
// then 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 = [
{
metaSupport: false,
before: [1.0, 300, 600],
after: [1.0, 600, 300],
},
{
metaSupport: true,
before: [0.5, 300, 600],
after: [1.0, 600, 300],
},
];
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
for (const e of expected) {
const b = e.before;
const a = e.after;
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b[0],
b[1],
b[2]
);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Force a reload.
const reload = waitForViewportLoad(ui);
const browser = ui.getViewportBrowser();
browser.reload();
await reload;
// Get to the initial size and check values.
await setViewportSize(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b[0],
b[1],
b[2]
);
// Check initial values again.
await testViewportZoomWidthAndHeight(
message + " after reload",
ui,
b[0],
b[1],
b[2]
);
// Force a reload.
const reload = waitForViewportLoad(ui);
const browser = ui.getViewportBrowser();
browser.reload();
await reload;
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a[0],
a[1],
a[2]
);
// Check initial values again.
await testViewportZoomWidthAndHeight(
message + " after reload",
ui,
b[0],
b[1],
b[2]
);
// Move to the smaller size.
await setViewportSize(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a[0],
a[1],
a[2]
);
// Go back to the initial size and check again.
await setViewportSize(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b[0],
b[1],
b[2]
);
}
});
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b[0],
b[1],
b[2]
);
}
},
{ usingBrowserUI: true }
);

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

@ -9,69 +9,68 @@ const TEST_URL =
"data:text/html;charset=utf-8," +
'<head><meta name="viewport" content="width=300"/></head>' +
"<body>meta viewport width 300</body>";
addRDMTask(TEST_URL, async function({ ui, manager }) {
const store = ui.toolWindow.store;
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
info("--- Starting viewport test output ---");
// Wait until the viewport has been added.
await waitUntilState(store, state => state.viewports.length == 1);
// We're going to take a 600,300 viewport (before) and resize it
// to 50,50 (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 = [
{
metaSupport: false,
before: [1.0, 600, 300],
after: [1.0, 50, 50], // Zoom is unaffected.
},
{
metaSupport: true,
before: [2.0, 300, 150],
after: [0.25, 300, 300], // This checks that min-zoom is active.
},
];
info("--- Starting viewport test output ---");
for (const e of expected) {
const b = e.before;
const a = e.after;
// We're going to take a 600,300 viewport (before) and resize it
// to 50,50 (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 = [
{
metaSupport: false,
before: [1.0, 600, 300],
after: [1.0, 50, 50], // Zoom is unaffected.
},
{
metaSupport: true,
before: [2.0, 300, 150],
after: [0.25, 300, 300], // This checks that min-zoom is active.
},
];
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
for (const e of expected) {
const b = e.before;
const a = e.after;
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b[0],
b[1],
b[2]
);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 50, 50);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a[0],
a[1],
a[2]
);
// Get to the initial size and check values.
await setViewportSize(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b[0],
b[1],
b[2]
);
// Move to the smaller size.
await setViewportSize(ui, manager, 50, 50);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a[0],
a[1],
a[2]
);
// Go back to the initial size and check again.
await setViewportSize(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b[0],
b[1],
b[2]
);
}
});
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b[0],
b[1],
b[2]
);
}
},
{ usingBrowserUI: true }
);

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

@ -10,85 +10,84 @@ const TEST_URL =
'<head><meta name="viewport" content="width=device-width, ' +
'initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0"></head>' +
"<body>meta viewport scaled locked at 1.0</body>";
addRDMTask(TEST_URL, async function({ ui, manager }) {
const store = ui.toolWindow.store;
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
info("--- Starting viewport test output ---");
// 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 = [
{
metaSupport: false,
before: {
zoom: 1.0,
width: 300,
height: 600,
// 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 = [
{
metaSupport: false,
before: {
zoom: 1.0,
width: 300,
height: 600,
},
after: {
zoom: 1.0,
width: 600,
height: 300,
},
},
after: {
zoom: 1.0,
width: 600,
height: 300,
{
metaSupport: true,
before: {
zoom: 1.0,
width: 300,
height: 600,
},
after: {
zoom: 1.0,
width: 600,
height: 300,
},
},
},
{
metaSupport: true,
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;
for (const e of expected) {
const b = e.before;
const a = e.after;
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// 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
);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(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
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(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
);
}
});
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b.zoom,
b.width,
b.height
);
}
},
{ usingBrowserUI: true }
);

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

@ -11,71 +11,70 @@ const TEST_URL =
'minimum-scale=1.0, width=device-width"></head>' +
'<div style="width:100%;background-color:green">test</div>' +
"</body>";
addRDMTask(TEST_URL, async function({ ui, manager }) {
const store = ui.toolWindow.store;
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
info("--- Starting viewport test output ---");
// 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,
// 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,
},
},
after: {
zoom: 1.0,
width: 600,
height: 300,
},
},
];
];
for (const e of expected) {
const b = e.before;
const a = e.after;
for (const e of expected) {
const b = e.before;
const a = e.after;
const message = "Meta Viewport ON";
const message = "Meta Viewport ON";
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, true);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, true);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b.zoom,
b.width,
b.height
);
// Get to the initial size and check values.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " before resize",
ui,
b.zoom,
b.width,
b.height
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
await testViewportZoomWidthAndHeight(
message + " after resize",
ui,
a.zoom,
a.width,
a.height
);
// Move to the smaller size.
await setViewportSizeAndAwaitReflow(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 setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b.zoom,
b.width,
b.height
);
}
});
// Go back to the initial size and check again.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
await testViewportZoomWidthAndHeight(
message + " return to initial size",
ui,
b.zoom,
b.width,
b.height
);
}
},
{ usingBrowserUI: true }
);

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

@ -48,58 +48,49 @@ const TEST_URL =
"</head>" +
'<body><div style="background:orange; width:1000px; height:1000px"></div></body>';
addRDMTask(TEST_URL, async function({ ui, manager }) {
// Turn on the prefs that force overlay scrollbars to always be visible, and to allow
// data URIs to be considered as same-origin.
await SpecialPowers.pushPrefEnv({
set: [
["layout.testing.overlay-scrollbars.always-visible", true],
["security.data_uri.unique_opaque_origin", false],
],
});
addRDMTask(
TEST_URL,
async function({ ui, manager }) {
// Turn on the prefs that force overlay scrollbars to always be visible, and to allow
// data URIs to be considered as same-origin.
await SpecialPowers.pushPrefEnv({
set: [
["layout.testing.overlay-scrollbars.always-visible", true],
["security.data_uri.unique_opaque_origin", false],
],
});
const store = ui.toolWindow.store;
info("--- Starting viewport test output ---");
// Wait until the viewport has been added.
await waitUntilState(store, state => state.viewports.length == 1);
const browser = ui.getViewportBrowser();
info("--- Starting viewport test output ---");
const expected = [false, true];
for (const e of expected) {
const message = "Meta Viewport " + (e ? "ON" : "OFF");
const browser = ui.getViewportBrowser();
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
const expected = [
{
metaSupport: false,
},
{
metaSupport: true,
},
];
// Get to the initial size and snapshot the window.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
const initialSnapshot = await snapshotWindow(browser);
for (const e of expected) {
const message = "Meta Viewport " + (e.metaSupport ? "ON" : "OFF");
// Move to the rotated size.
await setViewportSizeAndAwaitReflow(ui, manager, 600, 300);
// Ensure meta viewport is set.
info(message + " setting meta viewport support.");
await setTouchAndMetaViewportSupport(ui, e.metaSupport);
// Reload the window.
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
// Get to the initial size and snapshot the window.
await setViewportSize(ui, manager, 300, 600);
const initialSnapshot = await snapshotWindow(browser.contentWindow);
// Go back to the initial size and take another snapshot.
await setViewportSizeAndAwaitReflow(ui, manager, 300, 600);
const finalSnapshot = await snapshotWindow(browser);
// Move to the rotated size.
await setViewportSize(ui, manager, 600, 300);
// Reload the window.
const reload = waitForViewportLoad(ui);
browser.reload();
await reload;
// Go back to the initial size and take another snapshot.
await setViewportSize(ui, manager, 300, 600);
const finalSnapshot = await snapshotWindow(browser.contentWindow);
const result = compareSnapshots(initialSnapshot, finalSnapshot, true);
is(result[2], result[1], "Window snapshots should match.");
}
});
const result = compareSnapshots(initialSnapshot, finalSnapshot, true);
is(result[2], result[1], "Window snapshots should match.");
}
},
{ usingBrowserUI: true }
);

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

@ -59,6 +59,6 @@ for (const { content, res_restore } of TESTS) {
`${content} resolution should be near ${res_target}, and we got ${resolution}.`
);
},
true
{ usingBrowserUI: true }
);
}

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

@ -78,8 +78,7 @@ for (const { content, res_target } of TESTS) {
`${content} zoom ${zoom} resolution should be near ${res_target}, and we got ${resolution}.`
);
}
}
// XXX: Enable testing against new browser UI.
// true
},
{ usingBrowserUI: true }
);
}

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

@ -15,76 +15,89 @@ function setZoomForBrowser(browser, zoom) {
ZoomManager.setZoomForBrowser(browser, zoom);
}
add_task(async function() {
const INITIAL_ZOOM_LEVEL = 1;
const PRE_RDM_ZOOM_LEVEL = 1.5;
const MID_RDM_ZOOM_LEVEL = 2;
addRDMTask(
null,
async function({ message }) {
const INITIAL_ZOOM_LEVEL = 1;
const PRE_RDM_ZOOM_LEVEL = 1.5;
const MID_RDM_ZOOM_LEVEL = 2;
const tab = await addTab(TEST_URL);
const browser = tab.linkedBrowser;
const tab = await addTab(TEST_URL);
const browser = tab.linkedBrowser;
await load(browser, TEST_URL);
await load(browser, TEST_URL);
// Get the initial zoom level.
const initialOuterZoom = getZoomForBrowser(browser);
is(
initialOuterZoom,
INITIAL_ZOOM_LEVEL,
"Initial outer zoom should be " + INITIAL_ZOOM_LEVEL + "."
);
// Get the initial zoom level.
const initialOuterZoom = getZoomForBrowser(browser);
is(
initialOuterZoom,
INITIAL_ZOOM_LEVEL,
"Initial outer zoom should be " + INITIAL_ZOOM_LEVEL + "."
);
// Change the zoom level before we open RDM.
setZoomForBrowser(browser, PRE_RDM_ZOOM_LEVEL);
// Change the zoom level before we open RDM.
setZoomForBrowser(browser, PRE_RDM_ZOOM_LEVEL);
const preRDMOuterZoom = getZoomForBrowser(browser);
is(
preRDMOuterZoom,
PRE_RDM_ZOOM_LEVEL,
"Pre-RDM outer zoom should be " + PRE_RDM_ZOOM_LEVEL + "."
);
const preRDMOuterZoom = getZoomForBrowser(browser);
is(
preRDMOuterZoom,
PRE_RDM_ZOOM_LEVEL,
"Pre-RDM outer zoom should be " + PRE_RDM_ZOOM_LEVEL + "."
);
// Start RDM on the tab. This will fundamentally change the way that browser behaves.
// It will now pass all of its messages through to the RDM docshell, meaning that when
// we request zoom level from it now, we are getting the RDM zoom level.
const { ui } = await openRDM(tab);
const uiDocShell = ui.toolWindow.docShell;
// Start RDM on the tab. This will fundamentally change the way that browser behaves.
// It will now pass all of its messages through to the RDM docshell, meaning that when
// we request zoom level from it now, we are getting the RDM zoom level.
const { ui } = await openRDM(tab);
// Bug 1541692: openRDM behaves differently in the test harness than it does
// interactively. Interactively, many features of the container docShell -- including
// zoom -- are copied over to the RDM browser. In the test harness, this seems to first
// reset the docShell before toggling RDM, which makes checking the initial zoom of the
// RDM pane not useful.
// Always wait for the post-init message.
await message.wait(ui.toolWindow, "post-init");
const preZoomUIZoom = uiDocShell.contentViewer.fullZoom;
is(
preZoomUIZoom,
INITIAL_ZOOM_LEVEL,
"Pre-zoom UI zoom should be " + INITIAL_ZOOM_LEVEL + "."
);
const uiDocShell = ui.toolWindow.docShell;
// Set the zoom level. This should tunnel to the inner browser and leave the UI alone.
setZoomForBrowser(browser, MID_RDM_ZOOM_LEVEL);
// Bug 1541692: openRDM behaves differently in the test harness than it does
// interactively. Interactively, many features of the container docShell -- including
// zoom -- are copied over to the RDM browser. In the test harness, this seems to first
// reset the docShell before toggling RDM, which makes checking the initial zoom of the
// RDM pane not useful.
// The UI zoom should be unchanged by this.
const postZoomUIZoom = uiDocShell.contentViewer.fullZoom;
is(postZoomUIZoom, preZoomUIZoom, "UI zoom should be unchanged by RDM zoom.");
const preZoomUIZoom = uiDocShell.contentViewer.fullZoom;
is(
preZoomUIZoom,
INITIAL_ZOOM_LEVEL,
"Pre-zoom UI zoom should be " + INITIAL_ZOOM_LEVEL + "."
);
// The RDM zoom should be changed.
const finalRDMZoom = getZoomForBrowser(browser);
is(
finalRDMZoom,
MID_RDM_ZOOM_LEVEL,
"RDM zoom should be " + MID_RDM_ZOOM_LEVEL + "."
);
// Set the zoom level. This should tunnel to the inner browser and leave the UI alone.
setZoomForBrowser(browser, MID_RDM_ZOOM_LEVEL);
// Leave RDM. This should cause the outer pane to take on the full zoom of the RDM pane.
await closeRDM(tab);
// The UI zoom should be unchanged by this.
const postZoomUIZoom = uiDocShell.contentViewer.fullZoom;
is(
postZoomUIZoom,
preZoomUIZoom,
"UI zoom should be unchanged by RDM zoom."
);
// Bug 1541692: the following todo_is check will become an is check when this bug lands.
const finalOuterZoom = getZoomForBrowser(browser);
todo_is(
finalOuterZoom,
finalRDMZoom,
"Final outer zoom should match last RDM zoom."
);
});
// The RDM zoom should be changed.
const finalRDMZoom = getZoomForBrowser(browser);
is(
finalRDMZoom,
MID_RDM_ZOOM_LEVEL,
"RDM zoom should be " + MID_RDM_ZOOM_LEVEL + "."
);
// Leave RDM. This should cause the outer pane to take on the full zoom of the RDM pane.
await closeRDM(tab);
const finalOuterZoom = getZoomForBrowser(browser);
is(
finalOuterZoom,
finalRDMZoom,
"Final outer zoom should match last RDM zoom."
);
await removeTab(tab);
},
{ usingBrowserUI: true, onlyPrefAndTask: true }
);