Bug 1516413 Part 3: Update a zoom test to wait on the outcome, not the trigger. r=smaug

Now that the zoom behavior involves more event round-trips, this test should
wait on the outcome of the input, instead of on the triggering event itself.
The way that SimpleTest.promiseWaitForCondition works, if the condition is
not reached quickly, instead of timing out, the test continues and the
following isnot check will fail.

Depends on D59260

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Brad Werth 2020-01-30 17:19:25 +00:00
Родитель 67081368c7
Коммит b6077e9965
1 изменённых файлов: 18 добавлений и 21 удалений

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

@ -17,28 +17,25 @@
<select id="select"><option></option></select>
<script>
function testControl(id) {
return new Promise(function(resolve) {
var initialZoom = SpecialPowers.getFullZoom(window);
var element = document.getElementById(id);
element.onwheel = function() {
window.requestAnimationFrame(function() {
setTimeout(function() {
isnot(SpecialPowers.getFullZoom(window), initialZoom,
"Should have zoomed");
SpecialPowers.setFullZoom(window, initialZoom);
setTimeout(resolve);
});
});
}
async function testControl(id) {
var initialZoom = SpecialPowers.getFullZoom(window);
var element = document.getElementById(id);
let event = {
deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaY: 3,
ctrlKey: true
};
synthesizeWheel(element, 5, 5, event);
});
const zoomHasHappened = SimpleTest.promiseWaitForCondition(() => {
const zoom = SpecialPowers.getFullZoom(window);
return (zoom != initialZoom);
}, id + ": wheel event changed the zoom.");
let event = {
deltaMode: WheelEvent.DOM_DELTA_LINE,
deltaY: 3,
ctrlKey: true
};
synthesizeWheel(element, 5, 5, event);
await zoomHasHappened;
isnot(SpecialPowers.getFullZoom(window), initialZoom, id + ": should have zoomed");
SpecialPowers.setFullZoom(window, initialZoom);
}
async function test() {