| <!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; |
| } |
| |
| var testPassesSoFar = true; |
| |
| 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); |
| testPassesSoFar = false; |
| } |
| } |
| |
| addEventListener("load", async () => { |
| var modelContainer = document.getElementById("model-container"); |
| |
| var initialScrollPosition = overflow_container.scrollTop; |
| |
| if (window.testRunner) { |
| description(`ensurePositionInformationIsUpToDate should only be called when a scroll gesture occurs if a model |
| element exists in the page. After navigating from a page with a model element to a page without one and |
| attempting to scroll, ensurePositionInformationIsUpToDate should not be called.`); |
| |
| await UIHelper.clearEnsurePositionInformationIsUpToDateTracking(); |
| |
| // Page has one model element. |
| await scrollAndCheckIfPositionInformationUpdated(true); |
| |
| model.remove(); // Page now has no model elements. |
| |
| var newModel = document.createElement("model"); |
| modelContainer.innerHTML = "<iframe id='iframe' src='resources/models-frame.html'></iframe>"; // Page now has one model elements. |
| var newFrame = document.createElement("iframe"); |
| newFrame.setAttribute("src", "resources/models-frame.html"); |
| modelContainer.appendChild(newFrame); // Page now has two model elements. |
| modelContainer.appendChild(newModel); // Page now has three model elements. |
| await scrollAndCheckIfPositionInformationUpdated(true); |
| |
| if (testPassesSoFar) |
| window.location.href = 'resources/finish-models-navigation.html'; |
| else |
| testRunner.notifyDone(); |
| } |
| }); |
| </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> |