Bug 1525570 - Add a test for preventDefault on pinch zooms. r=botond

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kartikaya Gupta 2019-03-02 11:09:48 +00:00
Родитель bbac39e1ba
Коммит 636fc77e72
2 изменённых файлов: 85 добавлений и 0 удалений

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

@ -0,0 +1,81 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>Checking prevent-default for zooming</title>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript">
function* testPreventDefault(testDriver, aTouchStartToCancel) {
var initial_resolution = getResolution();
ok(initial_resolution > 0,
"The initial_resolution is " + initial_resolution + ", which is some sane value");
// preventDefault exactly one touchstart based on the value of aTouchStartToCancel
var touchStartCount = 0;
var canceller = function(e) {
dump("touchstart listener hit, count: " + touchStartCount + "\n");
touchStartCount++;
if (touchStartCount == aTouchStartToCancel) {
dump("calling preventDefault on touchstart\n");
e.preventDefault();
document.documentElement.removeEventListener("touchstart", canceller, {passive: false});
}
};
document.documentElement.addEventListener("touchstart", canceller, {passive: false});
var waitForTouchEnd = function(e) {
dump("touchend listener hit\n");
setTimeout(testDriver, 0);
};
document.documentElement.addEventListener("touchend", waitForTouchEnd, {passive: true, once: true});
// Ensure that APZ gets updated hit-test info
yield waitForAllPaints(testDriver);
var zoom_in = [
[ { x: 125, y: 250 }, { x: 175, y: 350 } ],
[ { x: 120, y: 220 }, { x: 180, y: 380 } ],
[ { x: 115, y: 190 }, { x: 185, y: 410 } ],
[ { x: 110, y: 160 }, { x: 190, y: 440 } ],
[ { x: 105, y: 130 }, { x: 195, y: 470 } ],
[ { x: 100, y: 100 }, { x: 200, y: 500 } ],
];
var touchIds = [0, 1];
yield* synthesizeNativeTouchSequences(document.body, zoom_in, null, touchIds);
yield; // wait for the touchend listener to fire
// Flush state and get the resolution we're at now
yield waitForApzFlushedRepaints(testDriver);
let final_resolution = getResolution();
is(final_resolution, initial_resolution, "The final resolution (" + final_resolution + ") matches the initial resolution");
}
function* test(testDriver) {
// Register a listener that fails the test if the APZ:TransformEnd event fires,
// because this test shouldn't actually be triggering any transforms
SpecialPowers.Services.obs.addObserver(function() {
ok(false, "The test fired an unexpected APZ:TransformEnd");
}, "APZ:TransformEnd");
yield* testPreventDefault(testDriver, 1);
yield* testPreventDefault(testDriver, 2);
}
waitUntilApzStable()
.then(runContinuation(test))
.then(subtestDone);
</script>
</head>
<body>
Here is some text to stare at as the test runs. It serves no functional
purpose, but gives you an idea of the zoom level. It's harder to tell what
the zoom level is when the page is just solid white.
</body>
</html>

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

@ -32,6 +32,9 @@ var prefs = [
// Pinch-zooming currently requires meta viewport support (this requirement
// will eventually be removed).
["dom.meta-viewport.enabled", true],
// Increase the content response timeout because some tests do preventDefault
// and we want to make sure APZ actually waits for them.
["apz.content_response_timeout", 60000],
];
// Increase the tap timeouts so the double-tap is still detected in case of
@ -45,6 +48,7 @@ var doubletap_prefs = [
var subtests = [
{"file": "helper_bug1280013.html", "prefs": prefs},
{"file": "helper_basic_zoom.html", "prefs": prefs},
{"file": "helper_zoom_prevented.html", "prefs": prefs},
{"file": "helper_zoomed_pan.html", "prefs": prefs},
{"file": "helper_fixed_position_scroll_hittest.html", "prefs": prefs},
{"file": "helper_basic_doubletap_zoom.html", "prefs": doubletap_prefs},