Bug 1374166 - Use waitUntilApzStable to increase test robustness. r?botond
The important part here is that the test parent page
(test_bug1151663.html) waits for paints to complete before spawning the
helper window. Otherwise, the helper window might think it's done
painting (because it is) and start running the test even though its
layer tree has not been attached to the chrome layer tree. In such a
scenario reading the APZ test data produces an empty tree for the
content layers id and causes the test to fail.
This test was written before we had waitUntilApzStable so sprinkling some
of that into the test makes it more robust in general as well.
MozReview-Commit-ID: J8rqW6dcy23
--- a/gfx/layers/apz/test/mochitest/helper_bug1151663.html
+++ b/gfx/layers/apz/test/mochitest/helper_bug1151663.html
@@ -2,38 +2,24 @@
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1151663
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1151663, helper page</title>
<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">
// -------------------------------------------------------------------
// Infrastructure to get the test assertions to run at the right time.
// -------------------------------------------------------------------
var SimpleTest = window.opener.SimpleTest;
-
- window.onload = function() {
- window.addEventListener("MozAfterPaint", afterPaint);
- };
var utils = SpecialPowers.getDOMWindowUtils(window);
- function afterPaint(e) {
- // If there is another paint pending, wait for it.
- if (utils.isMozAfterPaintPending) {
- return;
- }
-
- // Once there are no more paints pending, remove the
- // MozAfterPaint listener and run the test logic.
- window.removeEventListener("MozAfterPaint", afterPaint);
- testBug1151663();
- }
// --------------------------------------------------------------------
// The actual logic for testing bug 1151663.
//
// In this test we have a simple page which is scrollable, with a
// scrollable <div> which is also scrollable. We test that the
// <div> does not get an initial APZC, since primary scrollable
// frame is the page's root scroll frame.
@@ -64,16 +50,18 @@ https://bugzilla.mozilla.org/show_bug.cg
// which either is the RCD with no child APZCs (e10s/B2G case) or has a
// single child APZC which is for the RCD (fennec case).
var rcd = findRcdNode(apzcTree);
SimpleTest.ok(rcd != null, "found the RCD node");
SimpleTest.is(rcd.children.length, 0, "expected no children on the RCD");
window.opener.finishTest();
}
+
+ waitUntilApzStable().then(testBug1151663);
</script>
</head>
<body style="height: 500px; overflow: scroll">
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1151663">Mozilla Bug 1151663</a>
<div style="height: 50px; width: 50px; overflow: scroll">
<!-- Put enough content into the subframe to make it have a nonzero scroll range -->
<div style="height: 100px; width: 50px"></div>
</div>
--- a/gfx/layers/apz/test/mochitest/test_bug1151663.html
+++ b/gfx/layers/apz/test/mochitest/test_bug1151663.html
@@ -3,31 +3,32 @@
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1151663
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1151663</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<script type="application/javascript" src="apz_test_utils.js"></script>
+ <script type="application/javascript" src="/tests/SimpleTest/paint_listener.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
<script type="application/javascript">
if (isApzEnabled()) {
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]]).then(function() {
- w = window.open("helper_bug1151663.html", "_blank");
- });
- };
+ pushPrefs([["apz.test.logging_enabled", true]])
+ .then(waitUntilApzStable)
+ .then(function() {
+ w = window.open("helper_bug1151663.html", "_blank");
+ });
}
function finishTest() {
w.close();
SimpleTest.finish();
};
</script>