зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1383365 - Add a test to assert async key scrolling happens. r=botond
MozReview-Commit-ID: 13XydDOHXUE --HG-- extra : rebase_source : 6824ddf0e0d00134b49147fee21ee4e75455ff29 extra : source : 1db44c2e79032184d3fb96d34e84052aa73b603a extra : histedit_source : 9acc007ccd27100af79a297f24a3221cd63337f2
This commit is contained in:
Родитель
52d2be54b8
Коммит
0599df77a5
|
@ -852,6 +852,8 @@ APZCTreeManager::PrepareNodeForLayer(const ScrollNode& aLayer,
|
|||
// Note that the async scroll offset is in ParentLayer pixels
|
||||
aState.mPaintLogger.LogTestData(aMetrics.GetScrollId(), "asyncScrollOffset",
|
||||
apzc->GetCurrentAsyncScrollOffset(AsyncPanZoomController::eForHitTesting));
|
||||
aState.mPaintLogger.LogTestData(aMetrics.GetScrollId(), "hasAsyncKeyScrolled",
|
||||
apzc->TestHasAsyncKeyScrolled());
|
||||
}
|
||||
|
||||
if (newApzc) {
|
||||
|
|
|
@ -737,6 +737,7 @@ AsyncPanZoomController::AsyncPanZoomController(uint64_t aLayersId,
|
|||
mAPZCId(sAsyncPanZoomControllerCount++),
|
||||
mSharedLock(nullptr),
|
||||
mAsyncTransformAppliedToContent(false),
|
||||
mTestHasAsyncKeyScrolled(false),
|
||||
mCheckerboardEventLock("APZCBELock")
|
||||
{
|
||||
if (aGestures == USE_GESTURE_DETECTOR) {
|
||||
|
@ -1703,6 +1704,9 @@ AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent)
|
|||
// Report the type of scroll action to telemetry
|
||||
ReportKeyboardScrollAction(aEvent.mAction);
|
||||
|
||||
// Mark that this APZC has async key scrolled
|
||||
mTestHasAsyncKeyScrolled = true;
|
||||
|
||||
// Calculate the destination for this keyboard scroll action
|
||||
CSSPoint destination = GetKeyboardDestination(aEvent.mAction);
|
||||
nsIScrollableFrame::ScrollUnit scrollUnit = KeyboardScrollAction::GetScrollUnit(aEvent.mAction.mType);
|
||||
|
|
|
@ -1215,6 +1215,14 @@ private:
|
|||
* and assertion purposes only.
|
||||
*/
|
||||
public:
|
||||
/**
|
||||
* Gets whether this APZC has performed async key scrolling.
|
||||
*/
|
||||
bool TestHasAsyncKeyScrolled() const
|
||||
{
|
||||
return mTestHasAsyncKeyScrolled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an extra offset for testing async scrolling.
|
||||
*/
|
||||
|
@ -1252,8 +1260,9 @@ private:
|
|||
LayerToParentLayerScale mTestAsyncZoom;
|
||||
// Flag to track whether or not the APZ transform is not used. This
|
||||
// flag is recomputed for every composition frame.
|
||||
bool mAsyncTransformAppliedToContent;
|
||||
|
||||
bool mAsyncTransformAppliedToContent : 1;
|
||||
// Flag to track whether or not this APZC has ever async key scrolled.
|
||||
bool mTestHasAsyncKeyScrolled : 1;
|
||||
|
||||
/* ===================================================================
|
||||
* The functions and members in this section are used for checkerboard
|
||||
|
|
|
@ -275,6 +275,10 @@ function isApzEnabled() {
|
|||
return enabled;
|
||||
}
|
||||
|
||||
function isKeyApzEnabled() {
|
||||
return isApzEnabled() && SpecialPowers.getBoolPref("apz.keyboard.enabled");
|
||||
}
|
||||
|
||||
// Despite what this function name says, this does not *directly* run the
|
||||
// provided continuation testFunction. Instead, it returns a function that
|
||||
// can be used to run the continuation. The extra level of indirection allows
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1383365
|
||||
-->
|
||||
<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");
|
||||
|
||||
// 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("VK_END", {});
|
||||
};
|
||||
|
||||
function waitForScrollBottom() {
|
||||
if (window.scrollY < window.scrollYMax) {
|
||||
return;
|
||||
}
|
||||
window.removeEventListener("scroll", waitForScrollBottom);
|
||||
|
||||
// Wait for scrolling to finish before dispatching the next key input or
|
||||
// the default action won't occur.
|
||||
waitForApzFlushedRepaints(function () {
|
||||
// This scroll should be asynchronous now that the focus state is up to date.
|
||||
window.addEventListener("scroll", waitForScrollTop);
|
||||
window.synthesizeKey("VK_HOME", {});
|
||||
});
|
||||
};
|
||||
|
||||
function waitForScrollTop() {
|
||||
if (window.scrollY > 0) {
|
||||
return;
|
||||
}
|
||||
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();
|
||||
});
|
||||
};
|
||||
|
||||
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,
|
||||
"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;
|
||||
|
||||
// Convert the test data into a representation that's easier to navigate.
|
||||
compositorTestData = convertTestData(compositorTestData);
|
||||
|
||||
// Reconstruct the APZC tree structure in the last paint.
|
||||
var apzcTree = buildApzcTree(compositorTestData.paints[lastPaintSeqNo]);
|
||||
var rcd = findRcdNode(apzcTree);
|
||||
|
||||
if (rcd) {
|
||||
return rcd.hasAsyncKeyScrolled === "1";
|
||||
} else {
|
||||
SimpleTest.info("Last paint rcd is null");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</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>
|
|
@ -18,6 +18,7 @@
|
|||
helper_iframe_pan.html
|
||||
helper_iframe1.html
|
||||
helper_iframe2.html
|
||||
helper_key_scroll.html
|
||||
helper_long_tap.html
|
||||
helper_scroll_inactive_perspective.html
|
||||
helper_scroll_inactive_zindex.html
|
||||
|
@ -53,6 +54,7 @@
|
|||
[test_group_zoom.html]
|
||||
skip-if = (toolkit != 'android') # only android supports zoom
|
||||
[test_interrupted_reflow.html]
|
||||
[test_key_scroll.html]
|
||||
[test_layerization.html]
|
||||
skip-if = (os == 'android') # wheel events not supported on mobile
|
||||
[test_scroll_inactive_bug1190112.html]
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=1383365
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Async key scrolling test</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">
|
||||
|
||||
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");
|
||||
});
|
||||
};
|
||||
} 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>
|
Загрузка…
Ссылка в новой задаче