Bug 1537719 - move page zoom tests and make them more reliable, r=morgan

This moves a bunch of tests over to a topical directory, and removes the
linux/windows running restrictions around browser_bug1015721.js
(now browser_mousewheel_zoom.js), given that it appears to run fine on try
and there are no recent logs with which we can diagnose failures.

It switches away from using FullZoom.reset repeatedly in the background_zoom
test because that trips https://bugzilla.mozilla.org/show_bug.cgi?id=1604236
which breaks subsequent tests.

Differential Revision: https://phabricator.services.mozilla.com/D89484
This commit is contained in:
Gijs Kruitbosch 2020-09-08 20:34:11 +00:00
Родитель 91500edec4
Коммит 61e522c615
16 изменённых файлов: 104 добавлений и 206 удалений

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

@ -50,7 +50,6 @@ support-files =
web_video.html
web_video1.ogv
web_video1.ogv^headers^
zoom_test.html
!/image/test/mochitest/blue.png
!/toolkit/content/tests/browser/common/mockTransfer.js
@ -72,17 +71,11 @@ skip-if = (verify && !debug && (os == 'win'))
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug380960.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug386835.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug406216.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug416661.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug417483.js]
skip-if = (verify && debug && (os == 'mac')) || (os == 'mac') || (os == 'linux') #Bug 1444703
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug419612.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug423833.js]
skip-if = true # bug 428712
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
@ -94,8 +87,6 @@ skip-if = true # bug 428712
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug432599.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug441778.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug455852.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug462289.js]
@ -130,11 +121,6 @@ skip-if = true # bug 1393813
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug537474.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug555224.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug559991.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
skip-if = (debug && os == "linux" && bits == 64) || (!debug && webrender && os == "win") # Bug 1652383
[browser_bug563588.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug565575.js]
@ -149,9 +135,6 @@ skip-if = toolkit != "cocoa" # Because of tests for supporting pasting from Serv
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug575561.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug575830.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
skip-if = (os == "mac") #Bug 1526628
[browser_bug577121.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug578534.js]
@ -186,9 +169,6 @@ skip-if = (verify && debug && (os == 'linux'))
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug710878.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug719271.js]
skip-if = os == "win" && debug && e10s || (verify && debug && (os == 'linux')) # Bug 1315042
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug724239.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug734076.js]
@ -207,9 +187,6 @@ skip-if = os == 'linux' && !debug && bits == 64 # Bug 1556066
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug882977.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_bug1015721.js]
skip-if = os == 'win' || os == 'linux' # Bug 1537719 - for linux failures
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_accesskeys.js]
# DO NOT ADD MORE TESTS HERE. USE A TOPICAL DIRECTORY INSTEAD.
[browser_clipboard.js]

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

@ -389,8 +389,8 @@ add_task(async function test_dragging_zoom_handling() {
);
win2.FullZoom.setZoom(ZOOM_FACTOR);
FullZoomHelper.zoomTest(
tab2,
is(
ZoomManager.getZoomForBrowser(tab2.linkedBrowser),
ZOOM_FACTOR,
"Original tab should have correct zoom factor"
);
@ -409,8 +409,8 @@ add_task(async function test_dragging_zoom_handling() {
// chains in the zoom code.
await new Promise(resolve => setTimeout(resolve, 0));
FullZoomHelper.zoomTest(
win1.gBrowser.selectedTab,
is(
ZoomManager.getZoomForBrowser(win1.gBrowser.selectedBrowser),
ZOOM_FACTOR,
"Dragged tab should have correct zoom factor"
);

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

@ -258,124 +258,6 @@ function promiseTabLoaded(aTab) {
});
}
var FullZoomHelper = {
selectTabAndWaitForLocationChange: function selectTabAndWaitForLocationChange(
tab
) {
if (!tab) {
throw new Error("tab must be given.");
}
if (gBrowser.selectedTab == tab) {
return Promise.resolve();
}
return Promise.all([
BrowserTestUtils.switchTab(gBrowser, tab),
this.waitForLocationChange(),
]);
},
removeTabAndWaitForLocationChange: function removeTabAndWaitForLocationChange(
tab
) {
tab = tab || gBrowser.selectedTab;
let selected = gBrowser.selectedTab == tab;
gBrowser.removeTab(tab);
if (selected) {
return this.waitForLocationChange();
}
return Promise.resolve();
},
waitForLocationChange: function waitForLocationChange() {
return new Promise(resolve => {
Services.obs.addObserver(function obs(subj, topic, data) {
Services.obs.removeObserver(obs, topic);
resolve();
}, "browser-fullZoom:location-change");
});
},
load: function load(tab, url) {
return new Promise(resolve => {
let didLoad = false;
let didZoom = false;
promiseTabLoadEvent(tab).then(event => {
didLoad = true;
if (didZoom) {
resolve();
}
}, true);
this.waitForLocationChange().then(function() {
didZoom = true;
if (didLoad) {
resolve();
}
});
BrowserTestUtils.loadURI(tab.linkedBrowser, url);
});
},
zoomTest: function zoomTest(tab, val, msg) {
is(ZoomManager.getZoomForBrowser(tab.linkedBrowser), val, msg);
},
enlarge: function enlarge() {
return new Promise(resolve => FullZoom.enlarge(resolve));
},
reduce: function reduce() {
return new Promise(resolve => FullZoom.reduce(resolve));
},
reset: function reset() {
return FullZoom.reset();
},
BACK: 0,
FORWARD: 1,
navigate: function navigate(direction) {
return new Promise(resolve => {
let didPs = false;
let didZoom = false;
BrowserTestUtils.waitForContentEvent(
gBrowser.selectedBrowser,
"pageshow",
true
).then(() => {
didPs = true;
if (didZoom) {
resolve();
}
});
if (direction == this.BACK) {
gBrowser.goBack();
} else if (direction == this.FORWARD) {
gBrowser.goForward();
}
this.waitForLocationChange().then(function() {
didZoom = true;
if (didPs) {
resolve();
}
});
});
},
failAndContinue: function failAndContinue(func) {
return function(err) {
ok(false, err);
func();
};
},
};
/**
* Waits for a load (or custom) event to finish in a given tab. If provided
* load an uri into the tab.

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

@ -1,8 +1,24 @@
[DEFAULT]
support-files =
head.js
../general/moz.png
zoom_test.html
[browser_background_link_zoom_reset.js]
[browser_background_zoom.js]
[browser_default_zoom.js]
[browser_default_zoom_multitab.js]
[browser_default_zoom_fission.js]
[browser_default_zoom_sitespecific.js]
[browser_image_zoom_tabswitch.js]
skip-if = (os == "mac") #Bug 1526628
[browser_mousewheel_zoom.js]
[browser_sitespecific_background_pref.js]
[browser_sitespecific_image_zoom.js]
[browser_sitespecific_video_zoom.js]
support-files =
../general/video.ogg
skip-if = os == "win" && debug || (verify && debug && (os == 'linux')) # Bug 1315042
[browser_subframe_textzoom.js]
[browser_tabswitch_zoom_flicker.js]
skip-if = (debug && os == "linux" && bits == 64) || (!debug && webrender && os == "win") # Bug 1652383

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

@ -1,7 +1,7 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const TEST_PAGE = "/browser/browser/base/content/test/general/dummy_page.html";
const TEST_PAGE = "/browser/browser/base/content/test/zoom/zoom_test.html";
var gTestTab, gBgTab, gTestZoom;
function testBackgroundLoad() {

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

@ -1,14 +1,19 @@
var gTestPage =
"http://example.org/browser/browser/base/content/test/general/dummy_page.html";
"http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
var gTestImage =
"http://example.org/browser/browser/base/content/test/general/moz.png";
var gTab1, gTab2, gTab3;
var gLevel;
const BACK = 0;
const FORWARD = 1;
function test() {
waitForExplicitFinish();
registerCleanupFunction(async () => {
await new Promise(resolve => {
ContentPrefService2.removeByName(FullZoom.name, Cu.createLoadContext(), {
handleCompletion: resolve,
});
});
});
(async function() {
gTab1 = BrowserTestUtils.addTab(gBrowser, gTestPage);
@ -78,8 +83,8 @@ function imageLoaded() {
function imageZoomSwitch() {
(async function() {
await FullZoomHelper.navigate(BACK);
await FullZoomHelper.navigate(FORWARD);
await FullZoomHelper.navigate(FullZoomHelper.BACK);
await FullZoomHelper.navigate(FullZoomHelper.FORWARD);
FullZoomHelper.zoomTest(
gTab1,
1,
@ -101,11 +106,8 @@ function finishTest() {
ok(!finishTestStarted, "finishTest called more than once");
finishTestStarted = true;
await FullZoomHelper.selectTabAndWaitForLocationChange(gTab1);
await FullZoom.reset();
await FullZoomHelper.removeTabAndWaitForLocationChange(gTab1);
await FullZoom.reset();
await FullZoomHelper.removeTabAndWaitForLocationChange(gTab2);
await FullZoom.reset();
await FullZoomHelper.removeTabAndWaitForLocationChange(gTab3);
})().then(finish, FullZoomHelper.failAndContinue(finish));
}

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

@ -8,13 +8,13 @@ add_task(async function test_init_default_zoom() {
"data:text/html;charset=utf-8,<body>test_init_default_zoom</body>";
// Prepare the test tab
console.log("Creating tab");
info("Creating tab");
let tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
let tabBrowser = gBrowser.getBrowserForTab(tab);
await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
// 100% global zoom
console.log("Getting default zoom");
info("Getting default zoom");
let defaultZoom = await FullZoomHelper.getGlobalValue();
is(defaultZoom, 1, "Global zoom is init at 100%");
// 100% tab zoom
@ -23,7 +23,7 @@ add_task(async function test_init_default_zoom() {
1,
"Current zoom is init at 100%"
);
console.log("Removing tab");
info("Removing tab");
await FullZoomHelper.removeTabAndWaitForLocationChange();
});
@ -32,20 +32,20 @@ add_task(async function test_set_default_zoom() {
"data:text/html;charset=utf-8,<body>test_set_default_zoom</body>";
// Prepare the test tab
console.log("Creating tab");
info("Creating tab");
let tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
let tabBrowser = gBrowser.getBrowserForTab(tab);
await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
// 120% global zoom
console.log("Changing default zoom");
info("Changing default zoom");
await FullZoomHelper.changeDefaultZoom(120);
let defaultZoom = await FullZoomHelper.getGlobalValue();
is(defaultZoom, 1.2, "Global zoom is at 120%");
// 120% tab zoom
await TestUtils.waitForCondition(() => {
console.log("Current zoom is: ", ZoomManager.getZoomForBrowser(tabBrowser));
info("Current zoom is: " + ZoomManager.getZoomForBrowser(tabBrowser));
return ZoomManager.getZoomForBrowser(tabBrowser) == 1.2;
});
is(
@ -53,7 +53,7 @@ add_task(async function test_set_default_zoom() {
1.2,
"Current zoom matches changed default zoom"
);
console.log("Removing tab");
info("Removing tab");
await FullZoomHelper.removeTabAndWaitForLocationChange();
});
@ -62,22 +62,19 @@ add_task(async function test_enlarge_reduce_reset_local_zoom() {
"data:text/html;charset=utf-8,<body>test_enlarge_reduce_reset_local_zoom</body>";
// Prepare the test tab
console.log("Creating tab");
info("Creating tab");
let tab = BrowserTestUtils.addTab(gBrowser, TEST_PAGE_URL);
let tabBrowser = gBrowser.getBrowserForTab(tab);
await FullZoomHelper.selectTabAndWaitForLocationChange(tab);
// 120% global zoom
console.log("Changing default zoom");
info("Changing default zoom");
await FullZoomHelper.changeDefaultZoom(120);
let defaultZoom = await FullZoomHelper.getGlobalValue();
is(defaultZoom, 1.2, "Global zoom is at 120%");
await TestUtils.waitForCondition(() => {
console.log(
"Current tab zoom is ",
ZoomManager.getZoomForBrowser(tabBrowser)
);
info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
return ZoomManager.getZoomForBrowser(tabBrowser) == 1.2;
});
is(
@ -87,16 +84,13 @@ add_task(async function test_enlarge_reduce_reset_local_zoom() {
);
await FullZoom.enlarge();
console.log("Enlarged!");
info("Enlarged!");
defaultZoom = await FullZoomHelper.getGlobalValue();
console.log("Current global zoom is ", defaultZoom);
info("Current global zoom is " + defaultZoom);
// 133% tab zoom
await TestUtils.waitForCondition(() => {
console.log(
"Current tab zoom is ",
ZoomManager.getZoomForBrowser(tabBrowser)
);
info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
return ZoomManager.getZoomForBrowser(tabBrowser) == 1.33;
});
is(
@ -111,32 +105,17 @@ add_task(async function test_enlarge_reduce_reset_local_zoom() {
1.2,
"Increasing zoom of current tab doesn't change default zoom."
);
console.log("Reducing...");
console.log(
"Current tab zoom is ",
ZoomManager.getZoomForBrowser(tabBrowser)
);
info("Reducing...");
info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
await FullZoom.reduce(); // 120% tab zoom
console.log(
"Current tab zoom is ",
ZoomManager.getZoomForBrowser(tabBrowser)
);
info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
await FullZoom.reduce(); // 110% tab zoom
console.log(
"Current tab zoom is ",
ZoomManager.getZoomForBrowser(tabBrowser)
);
info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
await FullZoom.reduce(); // 100% tab zoom
console.log(
"Current tab zoom is ",
ZoomManager.getZoomForBrowser(tabBrowser)
);
info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
await TestUtils.waitForCondition(() => {
console.log(
"Current tab zoom is ",
ZoomManager.getZoomForBrowser(tabBrowser)
);
info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
return ZoomManager.getZoomForBrowser(tabBrowser) == 1;
});
is(
@ -151,13 +130,10 @@ add_task(async function test_enlarge_reduce_reset_local_zoom() {
1.2,
"Decreasing zoom of current tab doesn't change default zoom."
);
console.log("Resetting...");
info("Resetting...");
FullZoom.reset(); // 120% tab zoom
await TestUtils.waitForCondition(() => {
console.log(
"Current tab zoom is ",
ZoomManager.getZoomForBrowser(tabBrowser)
);
info("Current tab zoom is ", ZoomManager.getZoomForBrowser(tabBrowser));
return ZoomManager.getZoomForBrowser(tabBrowser) == 1.2;
});
is(
@ -167,6 +143,6 @@ add_task(async function test_enlarge_reduce_reset_local_zoom() {
);
// no reset necessary, it was performed as part of the test
console.log("Removing tab");
info("Removing tab");
await FullZoomHelper.removeTabAndWaitForLocationChange();
});

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

@ -4,7 +4,7 @@
"use strict";
const TEST_PAGE =
"http://example.org/browser/browser/base/content/test/general/zoom_test.html";
"http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
var gTab1, gTab2, gLevel1;

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

@ -3,7 +3,7 @@ function test() {
(async function() {
let testPage =
"http://example.org/browser/browser/base/content/test/general/dummy_page.html";
"http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
let tab1 = BrowserTestUtils.addTab(gBrowser);
await FullZoomHelper.selectTabAndWaitForLocationChange(tab1);
await FullZoomHelper.load(tab1, testPage);

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

@ -22,7 +22,7 @@ function continue_test_prefNotSet() {
await FullZoomHelper.load(
gBrowser.selectedTab,
"http://mochi.test:8888/browser/browser/base/content/test/general/zoom_test.html"
"http://mochi.test:8888/browser/browser/base/content/test/zoom/zoom_test.html"
);
})().then(end_test_prefNotSet, FullZoomHelper.failAndContinue(finish));
}
@ -46,7 +46,7 @@ function test() {
await FullZoomHelper.selectTabAndWaitForLocationChange(tabElm);
await FullZoomHelper.load(
tabElm,
"http://mochi.test:8888/browser/browser/base/content/test/general/zoom_test.html"
"http://mochi.test:8888/browser/browser/base/content/test/zoom/zoom_test.html"
);
})().then(start_test_prefNotSet, FullZoomHelper.failAndContinue(finish));
}

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

@ -4,7 +4,7 @@
"use strict";
const TEST_PAGE =
"http://example.org/browser/browser/base/content/test/general/zoom_test.html";
"http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
const TEST_VIDEO =
"http://example.org/browser/browser/base/content/test/general/video.ogg";

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

@ -10,7 +10,7 @@ function test() {
Services.prefs.setBoolPref("browser.zoom.siteSpecific", true);
let uri =
"http://example.org/browser/browser/base/content/test/general/dummy_page.html";
"http://example.org/browser/browser/base/content/test/zoom/zoom_test.html";
(async function() {
tab = BrowserTestUtils.addTab(gBrowser);

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

@ -142,6 +142,51 @@ var FullZoomHelper = {
});
});
},
zoomTest: function zoomTest(tab, val, msg) {
is(ZoomManager.getZoomForBrowser(tab.linkedBrowser), val, msg);
},
BACK: 0,
FORWARD: 1,
navigate: function navigate(direction) {
return new Promise(resolve => {
let didPs = false;
let didZoom = false;
BrowserTestUtils.waitForContentEvent(
gBrowser.selectedBrowser,
"pageshow",
true
).then(() => {
didPs = true;
if (didZoom) {
resolve();
}
});
if (direction == this.BACK) {
gBrowser.goBack();
} else if (direction == this.FORWARD) {
gBrowser.goForward();
}
this.waitForLocationChange().then(function() {
didZoom = true;
if (didPs) {
resolve();
}
});
});
},
failAndContinue: function failAndContinue(func) {
return function(err) {
Cu.reportError(err);
ok(false, err);
func();
};
},
};
/**