Bug 1445288 - Turn test_key_scroll into a group test and robustify it a bit. r?botond
MozReview-Commit-ID: 7yIg1JckgfR
--- a/gfx/layers/apz/test/mochitest/helper_key_scroll.html
+++ b/gfx/layers/apz/test/mochitest/helper_key_scroll.html
@@ -5,37 +5,33 @@ https://bugzilla.mozilla.org/show_bug.cg
-->
<head>
<meta charset="utf-8">
<title>Async key scrolling test, helper page</title>
<script type="application/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
<script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
<script type="application/javascript">
- var SimpleTest = window.opener.SimpleTest;
-
- SimpleTest.waitForFocus(runTests, window);
-
// --------------------------------------------------------------------
// Async key scrolling test
//
// This test checks that a key scroll occurs asynchronously.
//
// The page contains a <div> that is large enough to make the page
// scrollable. We first synthesize a page down to scroll to the bottom
// of the page. Once we have reached the bottom of the page, we synthesize
// a page up to get us back to the top of the page.
//
// Once at the top, we request test data from APZ, rebuild the APZC tree
// structure, and use it to check that async key scrolling happened.
// --------------------------------------------------------------------
function runTests() {
// Sanity check
- SimpleTest.is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before test");
+ is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before test");
// Send a key to initiate a page scroll to take us to the bottom of the
// page. This scroll is done synchronously because APZ doesn't have
// current focus state at page load.
window.addEventListener("scroll", waitForScrollBottom);
window.synthesizeKey("KEY_End");
};
@@ -53,45 +49,45 @@ https://bugzilla.mozilla.org/show_bug.cg
for (var i = 0; i < 10; i++) {
utils.advanceTimeAndRefresh(50);
}
utils.restoreNormalRefresh();
// Wait for the APZ to reach a stable state as well, before dispatching
// the next key input or the default action won't occur.
waitForApzFlushedRepaints(function () {
- SimpleTest.is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before KEY_Home dispatch");
+ is(checkHasAsyncKeyScrolled(false), false, "expected no async key scrolling before KEY_Home dispatch");
// This scroll should be asynchronous now that the focus state is up to date.
window.addEventListener("scroll", waitForScrollTop);
window.synthesizeKey("KEY_Home");
});
};
function waitForScrollTop() {
if (window.scrollY > 0) {
return;
}
SimpleTest.info("Reached final scroll position of async KEY_Home scroll");
window.removeEventListener("scroll", waitForScrollTop);
// Wait for APZ to settle and then check that async scrolling happened.
waitForApzFlushedRepaints(function () {
- SimpleTest.is(checkHasAsyncKeyScrolled(true), true, "expected async key scrolling after test");
- window.opener.finishTest();
+ is(checkHasAsyncKeyScrolled(true), true, "expected async key scrolling after test");
+ subtestDone();
});
};
function checkHasAsyncKeyScrolled(requirePaints) {
// Get the compositor-side test data from nsIDOMWindowUtils.
var utils = SpecialPowers.getDOMWindowUtils(window);
var compositorTestData = utils.getCompositorAPZTestData();
if (requirePaints) {
- SimpleTest.ok(compositorTestData.paints.length > 0,
+ ok(compositorTestData.paints.length > 0,
"expected at least one paint in compositor test data");
}
// Get the sequence number of the last paint on the compositor side.
// We do this before converting the APZ test data because the conversion
// loses the order of the paints.
var lastPaint = compositorTestData.paints[compositorTestData.paints.length - 1];
var lastPaintSeqNo = lastPaint.sequenceNumber;
@@ -105,16 +101,18 @@ https://bugzilla.mozilla.org/show_bug.cg
if (rcd) {
return rcd.hasAsyncKeyScrolled === "1";
} else {
SimpleTest.info("Last paint rcd is null");
return false;
}
}
+
+ waitUntilApzStable().then(runTests);
</script>
</head>
<body style="height: 500px; overflow: scroll">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1383365">Async key scrolling test</a>
<!-- Put enough content into the page to make it have a nonzero scroll range -->
<div style="height: 5000px"></div>
</body>
</html>
--- a/gfx/layers/apz/test/mochitest/mochitest.ini
+++ b/gfx/layers/apz/test/mochitest/mochitest.ini
@@ -63,17 +63,17 @@
[test_group_touchevents.html]
skip-if = webrender # bug 1424752
[test_group_wheelevents.html]
skip-if = (toolkit == 'android') || webrender # wheel events not supported on mobile; bug 1429521 for webrender
[test_group_zoom.html]
skip-if = (toolkit != 'android') # only android supports zoom
[test_interrupted_reflow.html]
skip-if = webrender # bug 1429521 for webrender
-[test_key_scroll.html]
+[test_group_keyboard.html]
[test_layerization.html]
skip-if = (os == 'android') || webrender # wheel events not supported on mobile; bug 1424752 for webrender
[test_scroll_inactive_bug1190112.html]
skip-if = (os == 'android') # wheel events not supported on mobile
[test_scroll_inactive_flattened_frame.html]
skip-if = (os == 'android') # wheel events not supported on mobile
[test_scroll_subframe_scrollbar.html]
skip-if = (os == 'android') # wheel events not supported on mobile
rename from gfx/layers/apz/test/mochitest/test_key_scroll.html
rename to gfx/layers/apz/test/mochitest/test_group_keyboard.html
--- a/gfx/layers/apz/test/mochitest/test_key_scroll.html
+++ b/gfx/layers/apz/test/mochitest/test_group_keyboard.html
@@ -1,41 +1,30 @@
<!DOCTYPE HTML>
<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=1383365
--->
<head>
<meta charset="utf-8">
- <title>Async key scrolling test</title>
+ <title>Various keyboard scrolling tests</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
+var subtests = [
+ {'file': 'helper_key_scroll.html', prefs: [["apz.test.logging_enabled", true],
+ ["test.events.async.enabled", true]]},
+];
+
if (isKeyApzEnabled()) {
SimpleTest.waitForExplicitFinish();
-
- // Run the actual test in its own window, because it requires that the
- // root APZC be scrollable. Mochitest pages themselves often run
- // inside an iframe which means we have no control over the root APZC.
- var w = null;
window.onload = function() {
- pushPrefs([["apz.test.logging_enabled", true],
- ["test.events.async.enabled", true]]).then(function() {
- w = window.open("helper_key_scroll.html", "_blank");
- });
+ runSubtestsSeriallyInFreshWindows(subtests)
+ .then(SimpleTest.finish, SimpleTest.finish);
};
} else {
SimpleTest.ok(true, "Keyboard APZ is disabled");
}
-
- function finishTest() {
- w.close();
- SimpleTest.finish();
- };
-
</script>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1383365">Async key scrolling test</a>
</body>
</html>