blob: 4857a71db63af2c4ffccb4f240c9683161d0f9c8 [file] [edit]
<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script src="../../resources/js-test.js"></script>
<script src="../../resources/basic-gestures.js"></script>
<script src="../../resources/ui-helper.js"></script>
<style>
html, body {
padding: 0;
margin: 0;
}
#overflow_container {
height: 300px;
overflow: scroll;
border: 2px solid black;
}
#overflow {
background: linear-gradient(180deg, rgba(255, 199, 153, 1) 0%, rgba(255, 0, 102, 1) 100%);
height: 600px;
}
</style>
</head>
<script>
jsTestIsAsync = true;
testRunner.dumpAsText();
async function scroll() {
var fromX = overflow_container.offsetLeft + 50;
var fromY = overflow_container.offsetTop + overflow_container.offsetHeight - 5;
var toX = fromX;
var toY = fromY - 100;
await touchAndDragFromPointToPoint(fromX, fromY, toX, toY);
await liftUpAtPoint(toX, toY);
overflow_container.scrollTop = 0;
}
async function scrollAndCheckIfPositionInformationUpdated(correctValue) {
await scroll();
didWait = await UIHelper.didCallEnsurePositionInformationIsUpToDateSinceLastCheck();
const msg = "didCallEnsurePositionInformationIsUpToDateSinceLastCheck was " + didWait + ", expected " + correctValue;
if (didWait == correctValue)
testPassed(msg);
else
testFailed(msg);
}
addEventListener("load", async () => {
var didWait;
var modelContainer = document.getElementById("model-container");
var editableDivClicked = false;
var buttonClicked = false;
var initialScrollPosition = overflow_container.scrollTop;
if (window.testRunner) {
await UIHelper.clearEnsurePositionInformationIsUpToDateTracking();
description(`ensurePositionInformationIsUpToDate should only be called when a scroll gesture occurs if a model
element exists in the page.`);
// Page has one model element.
await scrollAndCheckIfPositionInformationUpdated(true);
model.remove(); // Page now has no model elements.
await scrollAndCheckIfPositionInformationUpdated(false);
var newModel = document.createElement("model");
modelContainer.appendChild(newModel); // Page now has one model element.
await scrollAndCheckIfPositionInformationUpdated(true);
var anotherModel = document.createElement("model");
modelContainer.appendChild(anotherModel); // Page now has two model elements.
newModel.remove(); // Page now has one model elements.
await scrollAndCheckIfPositionInformationUpdated(true);
anotherModel.remove(); // Page now has zero model elements.
await scrollAndCheckIfPositionInformationUpdated(false);
modelContainer.innerHTML = "<model id='model'></model>" // Page now has one model elements.
await scrollAndCheckIfPositionInformationUpdated(true);
modelContainer.innerHTML = ""; // Page now has zero model elements.
await scrollAndCheckIfPositionInformationUpdated(false);
finishJSTest();
}
});
</script>
<body>
<div id="overflow_container">
<div id="overflow"></div>
</div>
<div id="model-container">
<model id="model"></model>
</div>
<div id="console"></div>
</body>
</html>