Bug 1423011 - Part 3: Add mochitests. r=botond

MozReview-Commit-ID: Cb1kDLaM1RJ

--HG--
extra : rebase_source : dc1eb8460008bd4368a6b6335e66c6cd3a3d4260
This commit is contained in:
Kashav Madan ext:(%2C%20Tanushree%20Podder%20%3Ctpodder%40mozilla.com%3E) 2018-06-07 17:16:12 -04:00
Родитель 95f6be0331
Коммит 99457f24cb
2 изменённых файлов: 93 добавлений и 5 удалений

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

@ -0,0 +1,80 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<title>Ensure layout viewport responds to panning while pinched</title>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript" src="apz_test_native_event_utils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<style>
body {
margin: 0;
padding: 0;
}
#content {
height: 5000px;
width: 5000px;
background: repeating-linear-gradient(#EEE, #EEE 100px, #DDD 100px, #DDD 200px);
}
</style>
</head>
<body>
<div id="content"></div>
<script type="application/javascript">
const RESOLUTION = 4;
const OFFSET_SCREEN_PX = 50;
const OFFSET_CSS_PX = OFFSET_SCREEN_PX / RESOLUTION;
function computeDelta(visual) {
// Compute the distance from the right/bottom edge of the visual
// viewport to the same edge of the layout viewport and add the desired
// offset to that.
const layout = visual * RESOLUTION;
return layout - visual + OFFSET_SCREEN_PX;
}
function* test(testDriver) {
const target = document.getElementById("content");
const cases = [
{
x: 0,
y: 0,
dx: (width) => -computeDelta(width),
dy: (height) => 0,
expected: {
x: [OFFSET_CSS_PX, "x-offset was adjusted"],
y: [0, "y-offset was not affected"],
},
},
{
x: OFFSET_SCREEN_PX,
y: 0,
dx: (width) => 0,
dy: (height) => -computeDelta(height),
expected: {
x: [OFFSET_CSS_PX, "x-offset was not affected"],
y: [OFFSET_CSS_PX, "y-offset was adjusted"],
},
},
];
for (let c of cases) {
yield synthesizeNativeTouchDrag(target,
c.x,
c.y,
c.dx(document.documentElement.clientWidth),
c.dy(document.documentElement.clientHeight),
testDriver);
yield waitForApzFlushedRepaints(testDriver);
is(window.scrollX, c.expected.x[0], c.expected.x[1]);
is(window.scrollY, c.expected.y[0], c.expected.y[1]);
}
}
SpecialPowers.getDOMWindowUtils(window).setResolutionAndScaleTo(RESOLUTION);
waitUntilApzStable().then(runContinuation(test)).then(subtestDone);
</script>
</body>
</html>

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

@ -17,27 +17,35 @@ var prefs = [
["apz.touch_start_tolerance", "0.0"],
// The subtests in this test do touch-drags to pan the page, but we don't
// want those pans to turn into fling animations, so we increase the
// fling-stop threshold velocity to absurdly high.
["apz.fling_stopped_threshold", "10000"],
// fling-min threshold velocity to an arbitrarily large value.
["apz.fling_min_velocity_threshold", "10000"],
// The helper_bug1280013's div gets a displayport on scroll, but if the
// test takes too long the displayport can expire before we read the value
// out of the test. So we disable displayport expiry for these tests.
["apz.displayport_expiry_ms", 0],
// Prevent the dynamic toolbar from interfering with main-thread scroll
// offset values.
["browser.chrome.dynamictoolbar", false],
];
// Increase the tap timeouts so the double-tap is still detected in case of
// random delays during testing.
var doubletap_prefs = prefs.slice(); // make a copy
doubletap_prefs.push(["ui.click_hold_context_menus.delay", 10000]);
doubletap_prefs.push(["apz.max_tap_time", 10000]);
var doubletap_prefs = [
...prefs,
["ui.click_hold_context_menus.delay", 10000],
["apz.max_tap_time", 10000],
];
var subtests = [
{'file': 'helper_bug1280013.html', 'prefs': prefs},
{'file': 'helper_basic_zoom.html', 'prefs': prefs},
{'file': 'helper_zoomed_pan.html', 'prefs': prefs},
{'file': 'helper_basic_doubletap_zoom.html', 'prefs': doubletap_prefs},
];
if (isApzEnabled()) {
// This has a lot of subtests, and Android emulators are slow.
SimpleTest.requestLongerTimeout(2);
SimpleTest.waitForExplicitFinish();
window.onload = function() {
runSubtestsSeriallyInFreshWindows(subtests)