Bug 1423011 - Part 3: Add mochitests. r?botond
MozReview-Commit-ID: Cb1kDLaM1RJ
new file mode 100644
--- /dev/null
+++ b/gfx/layers/apz/test/mochitest/helper_zoomed_pan.html
@@ -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>
+
--- a/gfx/layers/apz/test/mochitest/test_group_zoom.html
+++ b/gfx/layers/apz/test/mochitest/test_group_zoom.html
@@ -12,37 +12,43 @@ var prefs = [
// We need the APZ paint logging information
["apz.test.logging_enabled", true],
// Dropping the touch slop to 0 makes the tests easier to write because
// we can just do a one-pixel drag to get over the pan threshold rather
// than having to hard-code some larger value.
["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 velocity requirement absurdly high.
+ ["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],
];
// 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 zoom_prefs = doubletap_prefs.slice();
+zoom_prefs.push(["browser.chrome.dynamictoolbar", false]);
+
var subtests = [
{'file': 'helper_bug1280013.html', 'prefs': prefs},
{'file': 'helper_basic_zoom.html', 'prefs': prefs},
{'file': 'helper_basic_doubletap_zoom.html', 'prefs': doubletap_prefs},
+ {'file': 'helper_zoomed_pan.html', 'prefs': zoom_prefs},
];
if (isApzEnabled()) {
+ // This has a lot of subtests, and Android emulators are slow.
+ SimpleTest.requestLongerTimeout(2);
SimpleTest.waitForExplicitFinish();
window.onload = function() {
runSubtestsSeriallyInFreshWindows(subtests)
.then(SimpleTest.finish, SimpleTest.finish);
};
}
</script>